devnetfs 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.
If you have a normal user-space process running, then you don't have to worry about task struct. All will be dealt with behind your back by proper kernel mechanisms.
If you're talking about where to get the pointer from user-space by your kernel thread. That's just another topic. :) And you may try various kernel-space to user-space communication mechanisms. Such as procfs or netlink etc..
Try harder. :)Sorry. I did try that but got LOTS of results mostly not useful. Can you please point me to a kernel thread (in the source) that does a copy_to_user()?? That will I guess answer my question.
First you try the identifier search for kernel_thread, you will see there're not many kernel threads running in kernel at all. Then you could read their code. Grep for copy_to_user, or if not, maybe no kernel_thread's calling copy_to_user()? That's highly possible. :) Then you could just read a seperate example with copy_to_user. In other words, the task you're trying to achieve is quite normal. I think. :)
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/kernelnewbies/
FAQ: http://kernelnewbies.org/faq/