History

fork: Explicitly set PF_KTHREAD

Instead of implicitly inheriting PF_KTHREAD from the parent process examine arguments in kernel_clone_args to see if PF_KTHREAD should be set. This makes knowledge of which new threads are kernel threads explicit. This also makes it so that init and the user mode helper processes no longer have PF_KTHREAD set.

Eric W. Biederman committed 4 years ago

Commit 753550e1 parent 68d85f01 file · +3 −0Browse files

Unified · Split

kernel/fork.c+3−0
@@ -2068,6 +2068,9 @@ static __latent_entropy struct task_struct *copy_process( · 2067 unmodified lines
20682068 p = dup_task_struct(current, node);
20692069 if (!p)
20702070 goto fork_out;
2071+ p->flags &= ~PF_KTHREAD;
2072+ if (args->kthread)
2073+ p->flags |= PF_KTHREAD;
20712074 if (args->io_thread) {
20722075 /*
20732076 * Mark us an IO worker, and block any signal that isn't