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.
Find the answer to your Linux question:
New to Linux Forums? Register here for free!
    Linux Forums > GNU Linux Zone > The Linux Kernel > user-mode Linux, __generic_copy_to_user problem

Forgot Password?
 The Linux Kernel   Compiling, theory, programming or other discussion about the linux kernel

Site Navigation
Linux Articles
Linux Forums
Linux Downloads
Linux Hosting
Free Magazines
Job Board
IRC Chat
RSS Feeds


Linux Forum Topics
Linux Forums
Your Distro
Linux Resources
GNU Linux Zone
The Community
Reply
 
Thread Tools Display Modes
Old 11-14-2004   #1 (permalink)
Just Joined!
 
Join Date: Nov 2004
Posts: 3
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 \
-c

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.

--David
dlobron is offline  


Reply With Quote
Old 11-14-2004   #2 (permalink)
Linux Guru
 
Join Date: Oct 2001
Location: Täby, Sweden
Posts: 7,578
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.
Dolda2000 is offline   Reply With Quote
Old 11-14-2004   #3 (permalink)
Just Joined!
 
Join Date: Nov 2004
Posts: 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,

David
dlobron is offline   Reply With Quote
Old 11-14-2004   #4 (permalink)
Linux Guru
 
Join Date: Oct 2001
Location: Täby, Sweden
Posts: 7,578
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.
Dolda2000 is offline   Reply With Quote
Old 11-14-2004   #5 (permalink)
Just Joined!
 
Join Date: Nov 2004
Posts: 3
Thanks!

Thank you...I will try that!
dlobron is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Free Magazines
Run Your Own Web Server Using Linux & Apache - Free 191 Page Preview
Learn about everything you'll need to build and maintain your Linux servers, and to deploy Web applications to them.
subscribe
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



All times are GMT. The time now is 05:51 PM.






© 2000 - 2009 - All Rights Reserved - Property of  MAS Media

Content Relevant URLs by vBSEO 3.3.0 RC2