All of lore.kernel.org
 help / color / mirror / Atom feed
* + pid-make-__task_pid_nr_nsns-=-null-safe-for-zombie-callers.patch added to mm-nonmm-unstable branch
@ 2025-08-12  1:34     ` Andrew Morton
  2025-08-19 11:37       ` + pid-change-task_state-to-use-task_ppid_nr_ns.patch " Christian Brauner
  0 siblings, 1 reply; 6+ messages in thread
From: Andrew Morton @ 2025-08-12  1:34 UTC (permalink / raw)
  To: mm-commits, viro, mjguzik, gaoxiang17, brauner, oleg, akpm

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2827 bytes --]


The patch titled
     Subject: pid: make __task_pid_nr_ns(ns => NULL) safe for zombie callers
has been added to the -mm mm-nonmm-unstable branch.  Its filename is
     pid-make-__task_pid_nr_nsns-=-null-safe-for-zombie-callers.patch

This patch will shortly appear at
     https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/pid-make-__task_pid_nr_nsns-=-null-safe-for-zombie-callers.patch

This patch will later appear in the mm-nonmm-unstable branch at
    git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***

The -mm tree is included into linux-next via the mm-everything
branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there every 2-3 working days

------------------------------------------------------
From: Oleg Nesterov <oleg@redhat.com>
Subject: pid: make __task_pid_nr_ns(ns => NULL) safe for zombie callers
Date: Sun, 10 Aug 2025 19:36:04 +0200

task_pid_vnr(another_task) will crash if the caller was already reaped. 
The pid_alive(current) check can't really help, the parent/debugger can
call release_task() right after this check.

This also means that even task_ppid_nr_ns(current, NULL) is not safe,
pid_alive() only ensures that it is safe to dereference ->real_parent.

Change __task_pid_nr_ns() to ensure ns != NULL.

Link: https://lore.kernel.org/all/20250802022123.3536934-1-gxxa03070307@gmail.com/
Link: https://lkml.kernel.org/r/20250810173604.GA19991@redhat.com
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Originally-by: 高翔 <gaoxiang17@xiaomi.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Christian Brauner <brauner@kernel.org>
Cc: Mateusz Guzik <mjguzik@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 kernel/pid.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

--- a/kernel/pid.c~pid-make-__task_pid_nr_nsns-=-null-safe-for-zombie-callers
+++ a/kernel/pid.c
@@ -514,7 +514,8 @@ pid_t __task_pid_nr_ns(struct task_struc
 	rcu_read_lock();
 	if (!ns)
 		ns = task_active_pid_ns(current);
-	nr = pid_nr_ns(rcu_dereference(*task_pid_ptr(task, type)), ns);
+	if (ns)
+		nr = pid_nr_ns(rcu_dereference(*task_pid_ptr(task, type)), ns);
 	rcu_read_unlock();
 
 	return nr;
_

Patches currently in -mm which might be from oleg@redhat.com are

pid-make-__task_pid_nr_nsns-=-null-safe-for-zombie-callers.patch
pid-introduce-task_ppid_vnr.patch
pid-change-bacct_add_tsk-to-use-task_ppid_nr_ns.patch
pid-change-task_state-to-use-task_ppid_nr_ns.patch


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

* + pid-introduce-task_ppid_vnr.patch added to mm-nonmm-unstable branch
@ 2025-08-12  1:34   ` Andrew Morton
  2025-08-12  1:34     ` + pid-make-__task_pid_nr_nsns-=-null-safe-for-zombie-callers.patch " Andrew Morton
  0 siblings, 1 reply; 6+ messages in thread
From: Andrew Morton @ 2025-08-12  1:34 UTC (permalink / raw)
  To: mm-commits, viro, mjguzik, gaoxiang17, brauner, oleg, akpm


The patch titled
     Subject: pid: introduce task_ppid_vnr()
has been added to the -mm mm-nonmm-unstable branch.  Its filename is
     pid-introduce-task_ppid_vnr.patch

This patch will shortly appear at
     https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/pid-introduce-task_ppid_vnr.patch

This patch will later appear in the mm-nonmm-unstable branch at
    git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***

The -mm tree is included into linux-next via the mm-everything
branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there every 2-3 working days

------------------------------------------------------
From: Oleg Nesterov <oleg@redhat.com>
Subject: pid: introduce task_ppid_vnr()
Date: Sun, 10 Aug 2025 19:36:10 +0200

For consistency with other task_xid_vnr() helpers.

Link: https://lkml.kernel.org/r/20250810173610.GA19995@redhat.com
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Christian Brauner <brauner@kernel.org>
Cc: gaoxiang17 <gaoxiang17@xiaomi.com>
Cc: Mateusz Guzik <mjguzik@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 fs/pidfs.c          |    2 +-
 include/linux/pid.h |    5 +++++
 2 files changed, 6 insertions(+), 1 deletion(-)

--- a/fs/pidfs.c~pid-introduce-task_ppid_vnr
+++ a/fs/pidfs.c
@@ -397,7 +397,7 @@ static long pidfd_info(struct file *file
 	 * 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;
--- a/include/linux/pid.h~pid-introduce-task_ppid_vnr
+++ a/include/linux/pid.h
@@ -310,6 +310,11 @@ static inline pid_t task_ppid_nr_ns(cons
 	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);
_

Patches currently in -mm which might be from oleg@redhat.com are

pid-make-__task_pid_nr_nsns-=-null-safe-for-zombie-callers.patch
pid-introduce-task_ppid_vnr.patch
pid-change-bacct_add_tsk-to-use-task_ppid_nr_ns.patch
pid-change-task_state-to-use-task_ppid_nr_ns.patch


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

* + pid-change-bacct_add_tsk-to-use-task_ppid_nr_ns.patch added to mm-nonmm-unstable branch
@ 2025-08-12  1:34 ` Andrew Morton
  2025-08-12  1:34   ` + pid-introduce-task_ppid_vnr.patch " Andrew Morton
  0 siblings, 1 reply; 6+ messages in thread
From: Andrew Morton @ 2025-08-12  1:34 UTC (permalink / raw)
  To: mm-commits, viro, mjguzik, gaoxiang17, brauner, oleg, akpm


The patch titled
     Subject: pid: change bacct_add_tsk() to use task_ppid_nr_ns()
has been added to the -mm mm-nonmm-unstable branch.  Its filename is
     pid-change-bacct_add_tsk-to-use-task_ppid_nr_ns.patch

This patch will shortly appear at
     https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/pid-change-bacct_add_tsk-to-use-task_ppid_nr_ns.patch

This patch will later appear in the mm-nonmm-unstable branch at
    git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***

The -mm tree is included into linux-next via the mm-everything
branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there every 2-3 working days

------------------------------------------------------
From: Oleg Nesterov <oleg@redhat.com>
Subject: pid: change bacct_add_tsk() to use task_ppid_nr_ns()
Date: Sun, 10 Aug 2025 19:36:15 +0200

To simplify the code.

Link: https://lkml.kernel.org/r/20250810173615.GA20000@redhat.com
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Christian Brauner <brauner@kernel.org>
Cc: gaoxiang17 <gaoxiang17@xiaomi.com>
Cc: Mateusz Guzik <mjguzik@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 kernel/tsacct.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

--- a/kernel/tsacct.c~pid-change-bacct_add_tsk-to-use-task_ppid_nr_ns
+++ a/kernel/tsacct.c
@@ -57,12 +57,11 @@ void bacct_add_tsk(struct user_namespace
 	stats->ac_sched	 = tsk->policy;
 	stats->ac_pid	 = task_pid_nr_ns(tsk, pid_ns);
 	stats->ac_tgid   = task_tgid_nr_ns(tsk, pid_ns);
+	stats->ac_ppid	 = task_ppid_nr_ns(tsk, pid_ns);
 	rcu_read_lock();
 	tcred = __task_cred(tsk);
 	stats->ac_uid	 = from_kuid_munged(user_ns, tcred->uid);
 	stats->ac_gid	 = from_kgid_munged(user_ns, tcred->gid);
-	stats->ac_ppid	 = pid_alive(tsk) ?
-		task_tgid_nr_ns(rcu_dereference(tsk->real_parent), pid_ns) : 0;
 	rcu_read_unlock();
 
 	task_cputime(tsk, &utime, &stime);
_

Patches currently in -mm which might be from oleg@redhat.com are

pid-make-__task_pid_nr_nsns-=-null-safe-for-zombie-callers.patch
pid-introduce-task_ppid_vnr.patch
pid-change-bacct_add_tsk-to-use-task_ppid_nr_ns.patch
pid-change-task_state-to-use-task_ppid_nr_ns.patch


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

* + pid-change-task_state-to-use-task_ppid_nr_ns.patch added to mm-nonmm-unstable branch
@ 2025-08-12  1:34 Andrew Morton
  2025-08-12  1:34 ` + pid-change-bacct_add_tsk-to-use-task_ppid_nr_ns.patch " Andrew Morton
  0 siblings, 1 reply; 6+ messages in thread
From: Andrew Morton @ 2025-08-12  1:34 UTC (permalink / raw)
  To: mm-commits, viro, mjguzik, gaoxiang17, brauner, oleg, akpm


The patch titled
     Subject: pid: change task_state() to use task_ppid_nr_ns()
has been added to the -mm mm-nonmm-unstable branch.  Its filename is
     pid-change-task_state-to-use-task_ppid_nr_ns.patch

This patch will shortly appear at
     https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/pid-change-task_state-to-use-task_ppid_nr_ns.patch

This patch will later appear in the mm-nonmm-unstable branch at
    git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***

The -mm tree is included into linux-next via the mm-everything
branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there every 2-3 working days

------------------------------------------------------
From: Oleg Nesterov <oleg@redhat.com>
Subject: pid: change task_state() to use task_ppid_nr_ns()
Date: Sun, 10 Aug 2025 19:36:20 +0200

To simplify the code.

Note that only tpid and max_fds really need rcu_read_lock(), we could move
task_ppid_nr_ns/task_tgid_nr_ns/task_numa_group_id/get_task_cred outside
of rcu read section.

Link: https://lkml.kernel.org/r/20250810173620.GA20007@redhat.com
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Christian Brauner <brauner@kernel.org>
Cc: gaoxiang17 <gaoxiang17@xiaomi.com>
Cc: Mateusz Guzik <mjguzik@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 fs/proc/array.c |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

--- a/fs/proc/array.c~pid-change-task_state-to-use-task_ppid_nr_ns
+++ a/fs/proc/array.c
@@ -157,13 +157,11 @@ static inline void task_state(struct seq
 	unsigned int max_fds = 0;
 
 	rcu_read_lock();
-	ppid = pid_alive(p) ?
-		task_tgid_nr_ns(rcu_dereference(p->real_parent), ns) : 0;
-
 	tracer = ptrace_parent(p);
 	if (tracer)
 		tpid = task_pid_nr_ns(tracer, ns);
 
+	ppid = task_ppid_nr_ns(p, ns);
 	tgid = task_tgid_nr_ns(p, ns);
 	ngid = task_numa_group_id(p);
 	cred = get_task_cred(p);
_

Patches currently in -mm which might be from oleg@redhat.com are

pid-make-__task_pid_nr_nsns-=-null-safe-for-zombie-callers.patch
pid-introduce-task_ppid_vnr.patch
pid-change-bacct_add_tsk-to-use-task_ppid_nr_ns.patch
pid-change-task_state-to-use-task_ppid_nr_ns.patch


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

* Re: + pid-change-task_state-to-use-task_ppid_nr_ns.patch added to mm-nonmm-unstable branch
  2025-08-12  1:34     ` + pid-make-__task_pid_nr_nsns-=-null-safe-for-zombie-callers.patch " Andrew Morton
@ 2025-08-19 11:37       ` Christian Brauner
  2025-08-19 20:27         ` Andrew Morton
  0 siblings, 1 reply; 6+ messages in thread
From: Christian Brauner @ 2025-08-19 11:37 UTC (permalink / raw)
  To: Andrew Morton; +Cc: mm-commits, viro, mjguzik, gaoxiang17, oleg

Andrew, would you please drop these four patches I'm taking them through
the pid{fs} tree.

On Mon, Aug 11, 2025 at 06:34:50PM -0700, Andrew Morton wrote:
> 
> The patch titled
>      Subject: pid: change task_state() to use task_ppid_nr_ns()
> has been added to the -mm mm-nonmm-unstable branch.  Its filename is
>      pid-change-task_state-to-use-task_ppid_nr_ns.patch
> 
> This patch will shortly appear at
>      https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/pid-change-task_state-to-use-task_ppid_nr_ns.patch
> 
> This patch will later appear in the mm-nonmm-unstable branch at
>     git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
> 
> Before you just go and hit "reply", please:
>    a) Consider who else should be cc'ed
>    b) Prefer to cc a suitable mailing list as well
>    c) Ideally: find the original patch on the mailing list and do a
>       reply-to-all to that, adding suitable additional cc's
> 
> *** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
> 
> The -mm tree is included into linux-next via the mm-everything
> branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
> and is updated there every 2-3 working days
> 
> ------------------------------------------------------
> From: Oleg Nesterov <oleg@redhat.com>
> Subject: pid: change task_state() to use task_ppid_nr_ns()
> Date: Sun, 10 Aug 2025 19:36:20 +0200
> 
> To simplify the code.
> 
> Note that only tpid and max_fds really need rcu_read_lock(), we could move
> task_ppid_nr_ns/task_tgid_nr_ns/task_numa_group_id/get_task_cred outside
> of rcu read section.
> 
> Link: https://lkml.kernel.org/r/20250810173620.GA20007@redhat.com
> Signed-off-by: Oleg Nesterov <oleg@redhat.com>
> Cc: Al Viro <viro@zeniv.linux.org.uk>
> Cc: Christian Brauner <brauner@kernel.org>
> Cc: gaoxiang17 <gaoxiang17@xiaomi.com>
> Cc: Mateusz Guzik <mjguzik@gmail.com>
> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
> ---
> 
>  fs/proc/array.c |    4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> --- a/fs/proc/array.c~pid-change-task_state-to-use-task_ppid_nr_ns
> +++ a/fs/proc/array.c
> @@ -157,13 +157,11 @@ static inline void task_state(struct seq
>  	unsigned int max_fds = 0;
>  
>  	rcu_read_lock();
> -	ppid = pid_alive(p) ?
> -		task_tgid_nr_ns(rcu_dereference(p->real_parent), ns) : 0;
> -
>  	tracer = ptrace_parent(p);
>  	if (tracer)
>  		tpid = task_pid_nr_ns(tracer, ns);
>  
> +	ppid = task_ppid_nr_ns(p, ns);
>  	tgid = task_tgid_nr_ns(p, ns);
>  	ngid = task_numa_group_id(p);
>  	cred = get_task_cred(p);
> _
> 
> Patches currently in -mm which might be from oleg@redhat.com are
> 
> pid-make-__task_pid_nr_nsns-=-null-safe-for-zombie-callers.patch
> pid-introduce-task_ppid_vnr.patch
> pid-change-bacct_add_tsk-to-use-task_ppid_nr_ns.patch
> pid-change-task_state-to-use-task_ppid_nr_ns.patch
> 

On Mon, Aug 11, 2025 at 06:34:48PM -0700, Andrew Morton wrote:
> 
> The patch titled
>      Subject: pid: change bacct_add_tsk() to use task_ppid_nr_ns()
> has been added to the -mm mm-nonmm-unstable branch.  Its filename is
>      pid-change-bacct_add_tsk-to-use-task_ppid_nr_ns.patch
> 
> This patch will shortly appear at
>      https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/pid-change-bacct_add_tsk-to-use-task_ppid_nr_ns.patch
> 
> This patch will later appear in the mm-nonmm-unstable branch at
>     git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
> 
> Before you just go and hit "reply", please:
>    a) Consider who else should be cc'ed
>    b) Prefer to cc a suitable mailing list as well
>    c) Ideally: find the original patch on the mailing list and do a
>       reply-to-all to that, adding suitable additional cc's
> 
> *** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
> 
> The -mm tree is included into linux-next via the mm-everything
> branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
> and is updated there every 2-3 working days
> 
> ------------------------------------------------------
> From: Oleg Nesterov <oleg@redhat.com>
> Subject: pid: change bacct_add_tsk() to use task_ppid_nr_ns()
> Date: Sun, 10 Aug 2025 19:36:15 +0200
> 
> To simplify the code.
> 
> Link: https://lkml.kernel.org/r/20250810173615.GA20000@redhat.com
> Signed-off-by: Oleg Nesterov <oleg@redhat.com>
> Cc: Al Viro <viro@zeniv.linux.org.uk>
> Cc: Christian Brauner <brauner@kernel.org>
> Cc: gaoxiang17 <gaoxiang17@xiaomi.com>
> Cc: Mateusz Guzik <mjguzik@gmail.com>
> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
> ---
> 
>  kernel/tsacct.c |    3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> --- a/kernel/tsacct.c~pid-change-bacct_add_tsk-to-use-task_ppid_nr_ns
> +++ a/kernel/tsacct.c
> @@ -57,12 +57,11 @@ void bacct_add_tsk(struct user_namespace
>  	stats->ac_sched	 = tsk->policy;
>  	stats->ac_pid	 = task_pid_nr_ns(tsk, pid_ns);
>  	stats->ac_tgid   = task_tgid_nr_ns(tsk, pid_ns);
> +	stats->ac_ppid	 = task_ppid_nr_ns(tsk, pid_ns);
>  	rcu_read_lock();
>  	tcred = __task_cred(tsk);
>  	stats->ac_uid	 = from_kuid_munged(user_ns, tcred->uid);
>  	stats->ac_gid	 = from_kgid_munged(user_ns, tcred->gid);
> -	stats->ac_ppid	 = pid_alive(tsk) ?
> -		task_tgid_nr_ns(rcu_dereference(tsk->real_parent), pid_ns) : 0;
>  	rcu_read_unlock();
>  
>  	task_cputime(tsk, &utime, &stime);
> _
> 
> Patches currently in -mm which might be from oleg@redhat.com are
> 
> pid-make-__task_pid_nr_nsns-=-null-safe-for-zombie-callers.patch
> pid-introduce-task_ppid_vnr.patch
> pid-change-bacct_add_tsk-to-use-task_ppid_nr_ns.patch
> pid-change-task_state-to-use-task_ppid_nr_ns.patch
> 

On Mon, Aug 11, 2025 at 06:34:46PM -0700, Andrew Morton wrote:
> 
> The patch titled
>      Subject: pid: introduce task_ppid_vnr()
> has been added to the -mm mm-nonmm-unstable branch.  Its filename is
>      pid-introduce-task_ppid_vnr.patch
> 
> This patch will shortly appear at
>      https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/pid-introduce-task_ppid_vnr.patch
> 
> This patch will later appear in the mm-nonmm-unstable branch at
>     git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
> 
> Before you just go and hit "reply", please:
>    a) Consider who else should be cc'ed
>    b) Prefer to cc a suitable mailing list as well
>    c) Ideally: find the original patch on the mailing list and do a
>       reply-to-all to that, adding suitable additional cc's
> 
> *** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
> 
> The -mm tree is included into linux-next via the mm-everything
> branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
> and is updated there every 2-3 working days
> 
> ------------------------------------------------------
> From: Oleg Nesterov <oleg@redhat.com>
> Subject: pid: introduce task_ppid_vnr()
> Date: Sun, 10 Aug 2025 19:36:10 +0200
> 
> For consistency with other task_xid_vnr() helpers.
> 
> Link: https://lkml.kernel.org/r/20250810173610.GA19995@redhat.com
> Signed-off-by: Oleg Nesterov <oleg@redhat.com>
> Cc: Al Viro <viro@zeniv.linux.org.uk>
> Cc: Christian Brauner <brauner@kernel.org>
> Cc: gaoxiang17 <gaoxiang17@xiaomi.com>
> Cc: Mateusz Guzik <mjguzik@gmail.com>
> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
> ---
> 
>  fs/pidfs.c          |    2 +-
>  include/linux/pid.h |    5 +++++
>  2 files changed, 6 insertions(+), 1 deletion(-)
> 
> --- a/fs/pidfs.c~pid-introduce-task_ppid_vnr
> +++ a/fs/pidfs.c
> @@ -397,7 +397,7 @@ static long pidfd_info(struct file *file
>  	 * 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;
> --- a/include/linux/pid.h~pid-introduce-task_ppid_vnr
> +++ a/include/linux/pid.h
> @@ -310,6 +310,11 @@ static inline pid_t task_ppid_nr_ns(cons
>  	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);
> _
> 
> Patches currently in -mm which might be from oleg@redhat.com are
> 
> pid-make-__task_pid_nr_nsns-=-null-safe-for-zombie-callers.patch
> pid-introduce-task_ppid_vnr.patch
> pid-change-bacct_add_tsk-to-use-task_ppid_nr_ns.patch
> pid-change-task_state-to-use-task_ppid_nr_ns.patch
> 

On Mon, Aug 11, 2025 at 06:34:44PM -0700, Andrew Morton wrote:
> 
> The patch titled
>      Subject: pid: make __task_pid_nr_ns(ns => NULL) safe for zombie callers
> has been added to the -mm mm-nonmm-unstable branch.  Its filename is
>      pid-make-__task_pid_nr_nsns-=-null-safe-for-zombie-callers.patch
> 
> This patch will shortly appear at
>      https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/pid-make-__task_pid_nr_nsns-=-null-safe-for-zombie-callers.patch
> 
> This patch will later appear in the mm-nonmm-unstable branch at
>     git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
> 
> Before you just go and hit "reply", please:
>    a) Consider who else should be cc'ed
>    b) Prefer to cc a suitable mailing list as well
>    c) Ideally: find the original patch on the mailing list and do a
>       reply-to-all to that, adding suitable additional cc's
> 
> *** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
> 
> The -mm tree is included into linux-next via the mm-everything
> branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
> and is updated there every 2-3 working days
> 
> ------------------------------------------------------
> From: Oleg Nesterov <oleg@redhat.com>
> Subject: pid: make __task_pid_nr_ns(ns => NULL) safe for zombie callers
> Date: Sun, 10 Aug 2025 19:36:04 +0200
> 
> task_pid_vnr(another_task) will crash if the caller was already reaped. 
> The pid_alive(current) check can't really help, the parent/debugger can
> call release_task() right after this check.
> 
> This also means that even task_ppid_nr_ns(current, NULL) is not safe,
> pid_alive() only ensures that it is safe to dereference ->real_parent.
> 
> Change __task_pid_nr_ns() to ensure ns != NULL.
> 
> Link: https://lore.kernel.org/all/20250802022123.3536934-1-gxxa03070307@gmail.com/
> Link: https://lkml.kernel.org/r/20250810173604.GA19991@redhat.com
> Signed-off-by: Oleg Nesterov <oleg@redhat.com>
> Originally-by: 高翔 <gaoxiang17@xiaomi.com>
> Cc: Al Viro <viro@zeniv.linux.org.uk>
> Cc: Christian Brauner <brauner@kernel.org>
> Cc: Mateusz Guzik <mjguzik@gmail.com>
> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
> ---
> 
>  kernel/pid.c |    3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> --- a/kernel/pid.c~pid-make-__task_pid_nr_nsns-=-null-safe-for-zombie-callers
> +++ a/kernel/pid.c
> @@ -514,7 +514,8 @@ pid_t __task_pid_nr_ns(struct task_struc
>  	rcu_read_lock();
>  	if (!ns)
>  		ns = task_active_pid_ns(current);
> -	nr = pid_nr_ns(rcu_dereference(*task_pid_ptr(task, type)), ns);
> +	if (ns)
> +		nr = pid_nr_ns(rcu_dereference(*task_pid_ptr(task, type)), ns);
>  	rcu_read_unlock();
>  
>  	return nr;
> _
> 
> Patches currently in -mm which might be from oleg@redhat.com are
> 
> pid-make-__task_pid_nr_nsns-=-null-safe-for-zombie-callers.patch
> pid-introduce-task_ppid_vnr.patch
> pid-change-bacct_add_tsk-to-use-task_ppid_nr_ns.patch
> pid-change-task_state-to-use-task_ppid_nr_ns.patch
> 

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

* Re: + pid-change-task_state-to-use-task_ppid_nr_ns.patch added to mm-nonmm-unstable branch
  2025-08-19 11:37       ` + pid-change-task_state-to-use-task_ppid_nr_ns.patch " Christian Brauner
@ 2025-08-19 20:27         ` Andrew Morton
  0 siblings, 0 replies; 6+ messages in thread
From: Andrew Morton @ 2025-08-19 20:27 UTC (permalink / raw)
  To: Christian Brauner; +Cc: mm-commits, viro, mjguzik, gaoxiang17, oleg

On Tue, 19 Aug 2025 13:37:39 +0200 Christian Brauner <brauner@kernel.org> wrote:

> Andrew, would you please drop these four patches I'm taking them through
> the pid{fs} tree.
> 

Gone.

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

end of thread, other threads:[~2025-08-19 20:27 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-12  1:34 + pid-change-task_state-to-use-task_ppid_nr_ns.patch added to mm-nonmm-unstable branch Andrew Morton
2025-08-12  1:34 ` + pid-change-bacct_add_tsk-to-use-task_ppid_nr_ns.patch " Andrew Morton
2025-08-12  1:34   ` + pid-introduce-task_ppid_vnr.patch " Andrew Morton
2025-08-12  1:34     ` + pid-make-__task_pid_nr_nsns-=-null-safe-for-zombie-callers.patch " Andrew Morton
2025-08-19 11:37       ` + pid-change-task_state-to-use-task_ppid_nr_ns.patch " Christian Brauner
2025-08-19 20:27         ` Andrew Morton

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.