[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: kernel thread and copy_to_user
On Fri, 2002-12-27 at 11:23, zw wrote:
> > But I thought while doing copy_to_user() the task should have
> > a valid task->mm. no?
>
> You mean the kernel thread, or the user task? I think you don't have
> to do anything special on your kernel thread. You kernel thread, I
> think, basically waiting there for a pointer from user space. Then
> you call copy_to_user() in your kernel thread. That's it. I think.
Think about what devnetfs is asking.
The function is prototyped as copy_to_user(to, from, len) where to and
from are pointers.
If current->mm is invalid, then exactly whose "from" are you copying
to? Remember, Linux is a virtual memory operating system: there can be
many mappings at the same address.
Likewise, with copy_from_user(), without a valid ->mm from where exactly
are you copying from?
The functions pull the to/from user addresses from the loaded user
address space. Without a user address space, these functions do not
work. Nor could they.
In short, to answer the original question, kernel threads cannot copy
from user-space since they have no user-space. If you want to get data
into and out of a kernel thread, expose an interface (procfs, sysfs,
syscall, device file, etc.)
Robert Love
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/kernelnewbies/
FAQ: http://kernelnewbies.org/faq/