Re: kernel thread and copy_to_user

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Robert Love wrote:
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.)
Thanks for your answer! It seems that I got confused. :)

So it seems that copy_from_user could only happen within a task? I mean, if the user-process get into the kernel with a syscall, then the syscall could do copy_from_user, then do some stuff with that data in kernel-space. But it's all happening within a task. Is that right?

Thanks for the clarification! :)

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/kernelnewbies/
FAQ: http://kernelnewbies.org/faq/



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux