Welcome to Linux Forums! With a comprehensive Linux Forum, information on various types of Linux software and many Linux Reviews articles, we have all the knowledge you need a click away, or accessible via our knowledgeable members.
Write an article for LinuxForums Today! Win Great Prizes!
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:
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
csmail.o:
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.
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.
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?
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 System.map 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.
Open Source Security Myths Dispelled Dispel the five major myths surrounding Open Source Security and gain the tools necessary to make a truly informed decision for your IT organization subscribe
InformationWeek InformationWeek is the only newsweekly you'll need to stay on top of the latest developments in information technology. subscribe