Find the answer to your Linux question:
Results 1 to 5 of 5
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    user-mode Linux, __generic_copy_to_user problem

    I am writing a small character device driver for a university course. The driver is somewhat similar to the "scull" module in _Linux Device Drivers_, from O'Reilly: it's basically just a linked list of 4,000-character text blocks. A user can write a text block to the driver or read a text block from the driver. The read and write operations use the copy_to_user and copy_from_user kernel functions.

    I'm finding that I can compile and load my code on my regular Debian system, running kernel 2.4.19. However, the code has a bug, such that when I write to the device, the system immediately crashes. This makes debugging well-nigh impossible. To get around this, our professor provided user-mode Linux (Debian, kernel 2.4.20-8um) on a lab machine. When I compile for UML, I use the following flags:

    gcc -D__KERNEL__ -I/usr/share/include -Wall -Wstrict-prototypes \
    -Wno-trigraphs -O2 -fno-strict-aliasing -fno-common \
    -fomit-frame-pointer -pipe -mpreferred-stack-boundary=2 \
    -march=i686 -DMODULE -nostdinc -iwithprefix include \

    This compiles with no errors or warnings. But when I try to insert the resulting object file into the kernel, I get this error:

    (none):~# /sbin/insmod -f csmail.o
    csmail.o: unresolved symbol __generic_copy_from_user
    csmail.o: unresolved symbol __generic_copy_to_user
    Hint: You are trying to load a module without a GPL compatible license
    and it has unresolved symbols. Contact the module supplier for
    assistance, only they can help you.

    The puzzling thing is that the compiler seems to be finding the copy_to_user function in <asm/uaccess.h> - otherwise, I'd expect to get a warning that the function was implicitly defined. But I still get this error when I try to load.

    Any help with this would be greatly appreciated- thank you in advance.


  2. #2
    Linux Guru
    Join Date
    Oct 2001
    Täby, Sweden
    Are you sure that all the CONFIG directives match those of the actual compiled UML kernel -- in particular the arch? It may be that the linker selects a function according to the default kernel config flags, while the UML kernel has different flags and thus doesn't have that function.

  3. #3

    CONFIG directives

    Many thanks for the reply! I actually don't know the details of how this version of UML was compiled...the university compiled it, and they supplied the compiler flags. I'm pretty sure that the arch is i686, but I'm not sure about the other flags. Is there a way to check this from within UML? Which flags/directives do you think I should check?

    Thank you again,


  4. $spacer_open
  5. #4
    Linux Guru
    Join Date
    Oct 2001
    Täby, Sweden
    Well, I'm not sure exactly, but start by checking the ksym listing from the UML kernel (/proc/kallsyms on 2.6 kernels... I can't remember what to do on 2.4 kernels, see if there's a file for that kernel, a /proc/ksyms or some ksyms-like program to run), and grep for all matches on copy_from_user. Then run cpp manually on your source file and see what file __generic_copy_from_user comes from, and see what compiler flags are necessary to get the file into the compilation and from there try to remedy it.

    I'm sorry that I can't help more specifically, but I have no 2.4 kernel tree to look at. I only run 2.6 kernels nowadays.

  6. #5


    Thank you...I will try that!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts