Revert "pid: make __task_pid_nr_ns(ns => NULL) safe for zombie callers"
cover Revert "pid: make __task_pid_nr_ns(ns => NULL) safe for zombie callers"
Christian,
I was going to revert 006568ab4c5c ("pid: Add a judgment for ns null in pid_nr_ns") but then I changed my mind and decided to revert my commit abdfd4948e45 (""pid: make __task_pid_nr_ns(ns => NULL) safe for zombie callers"). See the changelog.
2/2 is offtopic and purely cosmetic.
Oleg.
fs/pidfs.c | 2 +- include/linux/pid.h | 5 +++++ kernel/pid.c | 3 +-- 3 files changed, 7 insertions(+), 3 deletions(-)
PATCH 1/2 Revert "pid: make __task_pid_nr_ns(ns => NULL) safe for zombie callers"
This reverts commit abdfd4948e45c51b19162cf8b3f5003f8f53c9b9.
The changelog in this commit explains why it is not easy to avoid ns == NULL when the caller is exiting, but pid_vnr() is equally unsafe in this case.
However, commit 006568ab4c5c ("pid: Add a judgment for ns null in pid_nr_ns") already added the ns != NULL check in pid_nr_ns(), so we can remove the same check from __task_pid_nr_ns().
--- kernel/pid.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
kernel/pid.c +1 -2
@@ -515,8 +515,7 @@ pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,rcu_read_lock ();if (!ns) ns =task_active_pid_ns (current); -if (ns) - nr =pid_nr_ns (rcu_dereference (*task_pid_ptr (task, type)), ns); + nr =pid_nr_ns (rcu_dereference (*task_pid_ptr (task, type)), ns);rcu_read_unlock ();return nr;
Signature · 1 line
2.25.1.362.g51ebf55
PATCH 2/2 pid: introduce task_ppid_vnr() helper
In reply to Oleg NesterovCosmetic change. Unlike all other similar helpers task_ppid_nr_ns() doesn't have a _vnr() version; add one for consistency.
--- fs/pidfs.c | 2 +- include/linux/pid.h | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-)
fs/pidfs.c +1 -1
@@ -400,7 +400,7 @@ static long pidfd_info(struct file *file, unsigned int cmd, unsigned long arg)* the fields are set correctly, or return ESRCH to avoid providing * incomplete information. */ - kinfo.ppid =task_ppid_nr_ns (task,NULL ); + kinfo.ppid =task_ppid_vnr (task); kinfo.tgid =task_tgid_vnr (task); kinfo.pid =task_pid_vnr (task); kinfo.mask |=PIDFD_INFO_PID ;
include/linux/pid.h +5 -0
@@ -310,6 +310,11 @@ static inline pid_t task_ppid_nr_ns(const struct task_struct *tsk, struct pid_nareturn pid; } +static inline pid_t task_ppid_vnr (const struct task_struct *tsk) +{ +return task_ppid_nr_ns (tsk,NULL ); +} +static inline pid_t task_ppid_nr (const struct task_struct *tsk) {return task_ppid_nr_ns (tsk, &init_pid_ns);
Signature · 1 line
2.25.1.362.g51ebf55
Quoted 9 lines · Oleg Nesterov
Christian,
I was going to revert
006568ab4c5c("pid: Add a judgment for ns null inpid_nr_ns") but then I changed my mind and decided to revert my commitabdfd4948e45(""pid: make__task_pid_nr_ns(ns => NULL)safe for zombie callers"). See the changelog.2/2 is offtopic and purely cosmetic.
[...]
Applied to the kernel-7.0.misc branch of the vfs/vfs.git tree. Patches in the kernel-7.0.misc branch should appear in linux-next soon.
Please report any outstanding bugs that were missed during review in a new review to the original patch series allowing us to drop it.
It's encouraged to provide Acked-bys and Reviewed-bys even though the patch has now been applied. If possible patch trailers will be updated.
Note that commit hashes shown below are subject to change due to rebase, trailer updates or similar. If in doubt, please check the listed branch.
tree: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git branch: kernel-7.0.misc
[1/2] Revert "pid: make __task_pid_nr_ns(ns => NULL) safe for zombie callers"
https://git.kernel.org/vfs/vfs/c/2cf72670a7bb [2/2] pid: introduce task_ppid_vnr() helper https://git.kernel.org/vfs/vfs/c/6ac9f2b2f8e4