Re: strange about copy_from_user
From: Richard B. Johnson
Date: Fri Jul 09 2004 - 16:59:12 EST
On Fri, 9 Jul 2004, Qiuyu Zhang wrote:
> Hi all,
> I am working on writing a module driver.
>
> I am trying to use API copy_from_user to copy a bunch of memory from
> user space to kernel space. I write a ioctl function to register the
> pointer of the memory to kernel. And in the ioctl function I can use
> copy_from_user to get the correct data, but the strange thing is that
> when I use copy_from_user in other kernel function such as
> dev_hard_xmit function , I cannot
> get the correct result. I don't konw what the reason is . Thx.
> -
Without looking at the code it's hard to figure out what you
may be doing. However, copy_from_user() and copy_to_user() may
not ever be executed with a spin-lock held. Generally, if
you need to put user data into kernel "things", you need
to buffer it, i.e., copy_from_user() into a kmalloc(ed) buffer,
then work with it in kernel space.
Cheers,
Dick Johnson
Penguin : Linux version 2.4.26 on an i686 machine (5570.56 BogoMips).
Note 96.31% of all statistics are fiction.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/