copy_from_user( ) problem...help

Hollis Blanchard hollis at penguinppc.org
Thu Jun 2 01:31:09 EST 2005


On Jun 1, 2005, at 9:00 AM, Garcia Jérémie wrote:

> Hi everybody,
> I'm tryin to write some device drivers modules in order to manage some 
> of our devices of our ppc405EP based board.
> I read the Allessandro Rubini book (Linux Kernel device drivers) in 
> order to help me.
> Before going on difficult stuff, I'd like to make some basic training 
> and experiments.
> What I want to do seems to be very easy (but...):
>  - a user space programm has a global structure and contains an 
> integer and a char
>  - the user space programm loads the module with a parameter: the 
> structure address
>  - during the init_module(),I check that the address can be accessed 
> in R/W mode with the access_ok()
>  - the module copies the user structure in its own context and prints 
> the values retreived

When you do your copy_from_user, what guarantee do you have that the 
user process is your test application? If anything, I would expect it 
to be insmod (you can printk current->comm to see). Instead you could 
implement a write method and create a device node for the user app to 
open and write to.

However, for this specific example that's not in good style. If all you 
really want to do is communicate settings to a kernel module, have a 
look at sysfs.

-Hollis



More information about the Linuxppc-dev mailing list