public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] Revert "pid: make __task_pid_nr_ns(ns => NULL) safe for zombie callers"
@ 2025-10-15 12:35 Oleg Nesterov
  2025-10-15 12:36 ` [PATCH 1/2] " Oleg Nesterov
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Oleg Nesterov @ 2025-10-15 12:35 UTC (permalink / raw)
  To: Christian Brauner; +Cc: gaoxiang17, Mateusz Guzik, linux-kernel

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(-)


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] Revert "pid: make __task_pid_nr_ns(ns => NULL) safe for zombie callers"
  2025-10-15 12:35 [PATCH 0/2] Revert "pid: make __task_pid_nr_ns(ns => NULL) safe for zombie callers" Oleg Nesterov
@ 2025-10-15 12:36 ` Oleg Nesterov
  2025-10-15 12:36 ` [PATCH 2/2] pid: introduce task_ppid_vnr() helper Oleg Nesterov
  2026-01-29 14:59 ` [PATCH 0/2] Revert "pid: make __task_pid_nr_ns(ns => NULL) safe for zombie callers" Christian Brauner
  2 siblings, 0 replies; 4+ messages in thread
From: Oleg Nesterov @ 2025-10-15 12:36 UTC (permalink / raw)
  To: Christian Brauner; +Cc: gaoxiang17, Mateusz Guzik, linux-kernel

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().

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
---
 kernel/pid.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/kernel/pid.c b/kernel/pid.c
index 4fffec767a63..be69ae771e3c 100644
--- a/kernel/pid.c
+++ b/kernel/pid.c
@@ -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;
-- 
2.25.1.362.g51ebf55



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] pid: introduce task_ppid_vnr() helper
  2025-10-15 12:35 [PATCH 0/2] Revert "pid: make __task_pid_nr_ns(ns => NULL) safe for zombie callers" Oleg Nesterov
  2025-10-15 12:36 ` [PATCH 1/2] " Oleg Nesterov
@ 2025-10-15 12:36 ` Oleg Nesterov
  2026-01-29 14:59 ` [PATCH 0/2] Revert "pid: make __task_pid_nr_ns(ns => NULL) safe for zombie callers" Christian Brauner
  2 siblings, 0 replies; 4+ messages in thread
From: Oleg Nesterov @ 2025-10-15 12:36 UTC (permalink / raw)
  To: Christian Brauner; +Cc: gaoxiang17, Mateusz Guzik, linux-kernel

Cosmetic change. Unlike all other similar helpers task_ppid_nr_ns() doesn't
have a _vnr() version; add one for consistency.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
---
 fs/pidfs.c          | 2 +-
 include/linux/pid.h | 5 +++++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/fs/pidfs.c b/fs/pidfs.c
index 0ef5b47d796a..43bc0113ba71 100644
--- a/fs/pidfs.c
+++ b/fs/pidfs.c
@@ -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;
diff --git a/include/linux/pid.h b/include/linux/pid.h
index 003a1027d219..dd51bb08354c 100644
--- a/include/linux/pid.h
+++ b/include/linux/pid.h
@@ -310,6 +310,11 @@ static inline pid_t task_ppid_nr_ns(const struct task_struct *tsk, struct pid_na
 	return 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);
-- 
2.25.1.362.g51ebf55



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 0/2] Revert "pid: make __task_pid_nr_ns(ns => NULL) safe for zombie callers"
  2025-10-15 12:35 [PATCH 0/2] Revert "pid: make __task_pid_nr_ns(ns => NULL) safe for zombie callers" Oleg Nesterov
  2025-10-15 12:36 ` [PATCH 1/2] " Oleg Nesterov
  2025-10-15 12:36 ` [PATCH 2/2] pid: introduce task_ppid_vnr() helper Oleg Nesterov
@ 2026-01-29 14:59 ` Christian Brauner
  2 siblings, 0 replies; 4+ messages in thread
From: Christian Brauner @ 2026-01-29 14:59 UTC (permalink / raw)
  To: Oleg Nesterov; +Cc: Christian Brauner, gaoxiang17, Mateusz Guzik, linux-kernel

On Wed, 15 Oct 2025 14:35:50 +0200, Oleg Nesterov wrote:
> 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.
> 
> [...]

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-01-29 14:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-15 12:35 [PATCH 0/2] Revert "pid: make __task_pid_nr_ns(ns => NULL) safe for zombie callers" Oleg Nesterov
2025-10-15 12:36 ` [PATCH 1/2] " Oleg Nesterov
2025-10-15 12:36 ` [PATCH 2/2] pid: introduce task_ppid_vnr() helper Oleg Nesterov
2026-01-29 14:59 ` [PATCH 0/2] Revert "pid: make __task_pid_nr_ns(ns => NULL) safe for zombie callers" Christian Brauner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox