From: Eric W. Biederman Date: Mon, 11 Apr 2022 19:13:56 +0000 (-0500) Subject: fork: Explicitly set PF_KTHREAD X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=753550eb0ce1fea4b5cbd989f2e06ef80b2feb28;p=linux.git 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. Link: https://lkml.kernel.org/r/20220506141512.516114-6-ebiederm@xmission.com Signed-off-by: "Eric W. Biederman" --- diff --git a/kernel/fork.c b/kernel/fork.c index 8e17c3fbce423..35645f57bd2f3 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -2068,6 +2068,9 @@ static __latent_entropy struct task_struct *copy_process( p = dup_task_struct(current, node); if (!p) goto fork_out; + p->flags &= ~PF_KTHREAD; + if (args->kthread) + p->flags |= PF_KTHREAD; if (args->io_thread) { /* * Mark us an IO worker, and block any signal that isn't