Hi, I want to write a new syscall in which caller process would create kernel thread which shares the process address space, file descriptor table, parent pid etc. The new kernel thread would be clone of current thread but it would never execute any userspace code.
The kernel_thread() function with following arguments would be ideal to achieve this task: kernel_thread(some_function, some_args, CLONE_FS | CLONE_FILES | CLONE_PARENT) In latest kernels (v3.1x), this function causes segmentation fault in the user process. However same code works perfectly in older kernels (v2.6). According to this link <https://groups.google.com/forum/#%21searchin/linux.kernel/kernel_thread%28%29/linux.kernel/LPWuY2DMMuA/L2hv1x23YqQJ>, and this code <http://lxr.free-electrons.com/source/arch/x86/kernel/process_64.c?v=3.16#L177> (call chain: kernel_thread -> do_fork -> copy_process -> copy_thread), it looks like only the kernel thread can spawn another kernel thread. (I tried to set PF_KTHREAD flag in current->flags before calling kernel_thread function, but the system crashed.) Is there any clean way of creating kernel thread that shares process address space, file descriptor table, parent pid etc? Thanks, Shashank Khasare
_______________________________________________ Kernelnewbies mailing list [email protected] http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
