FAILED: patch "[PATCH] pidfd: prevent creation of pidfds for kthreads" failed to apply to 5.15-stable tree
Subsystems (4)
[email protected]
maintainerThe patch below does not apply to the 5.15-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.15.y
git checkout FETCH_HEAD
git cherry-pick -x 3b5bbe798b2451820e74243b738268f51901e7d0
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2024081910-grid-bobsled-6cb3@gregkh' --subject-prefix 'PATCH 5.15.y' HEAD^..
Possible dependencies:
3b5bbe798b24 ("pidfd: prevent creation of pidfds for kthreads")83b290c9e3b5 ("pidfd: clone: allow CLONE_THREAD | CLONE_PIDFD together")64bef697d33b ("pidfd: implement PIDFD_THREAD flag for pidfd_open()")21e25205d7f9 ("pidfd: don't do_notify_pidfd() if !thread_group_empty()")cdefbf2324ce ("pidfd: cleanup the usage of __pidfd_prepare's flags")932562a6045e ("rseq: Split out rseq.h from sched.h")cba6167f0adb ("restart_block: Trim includes")f038cc1379c0 ("locking/seqlock: Split out seqlock_types.h")53d31ba842d9 ("posix-cpu-timers: Split out posix-timers_types.h")f995443f01b4 ("locking/seqlock: Simplify SEQCOUNT_LOCKNAME()")58390c8ce1bd ("Merge tag 'iommu-updates-v6.4' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu")
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 3b5bbe798b2451820e74243b738268f51901e7d0 Mon Sep 17 00:00:00 2001
From: Christian Brauner <[email protected]>
Date: Wed, 31 Jul 2024 12:01:12 +0200
Subject: [PATCH] pidfd: prevent creation of pidfds for kthreads
It's currently possible to create pidfds for kthreads but it is unclear what that is supposed to mean. Until we have use-cases for it and we figured out what behavior we want block the creation of pidfds for kthreads.
kernel/fork.c +22 -3
@@ -2053,11 +2053,24 @@ static int __pidfd_prepare(struct pid *pid, unsigned int flags, struct file **re*/ int pidfd_prepare (struct pid *pid,unsigned int flags,struct file **ret) { -bool thread = flags &PIDFD_THREAD ; - -if (!pid || !pid_has_task (pid, thread ?PIDTYPE_PID :PIDTYPE_TGID )) +if (!pid)return -EINVAL ; +scoped_guard (rcu) { +struct task_struct *tsk; + +if (flags &PIDFD_THREAD ) + tsk =pid_task (pid,PIDTYPE_PID ); +else + tsk =pid_task (pid,PIDTYPE_TGID ); +if (!tsk) +return -EINVAL ; + +/* Don't create pidfds for kernel threads for now. */ +if (tsk->flags &PF_KTHREAD ) +return -EINVAL ; + } +return __pidfd_prepare (pid, flags, ret); }
@@ -2403,6 +2416,12 @@ __latent_entropy struct task_struct *copy_process(if (clone_flags &CLONE_PIDFD ) {int flags = (clone_flags &CLONE_THREAD ) ?PIDFD_THREAD :0 ; +/* Don't create pidfds for kernel threads for now. */ +if (args->kthread) { + retval = -EINVAL ; + goto bad_fork_free_pid; + } +/* Note that no task has been attached to @pid yet. */ retval =__pidfd_prepare (pid, flags, &pidfile);if (retval <0 )