All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: mm-commits@vger.kernel.org,viro@zeniv.linux.org.uk,mjguzik@gmail.com,gaoxiang17@xiaomi.com,brauner@kernel.org,oleg@redhat.com,akpm@linux-foundation.org
Subject: + pid-make-__task_pid_nr_nsns-=-null-safe-for-zombie-callers.patch added to mm-nonmm-unstable branch
Date: Mon, 11 Aug 2025 18:34:44 -0700	[thread overview]
Message-ID: <20250812013445.046F8C4CEED@smtp.kernel.org> (raw)

[-- 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


         reply	other threads:[~2025-08-12  1:34 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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     ` Andrew Morton [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250812013445.046F8C4CEED@smtp.kernel.org \
    --to=akpm@linux-foundation.org \
    --cc=brauner@kernel.org \
    --cc=gaoxiang17@xiaomi.com \
    --cc=mjguzik@gmail.com \
    --cc=mm-commits@vger.kernel.org \
    --cc=oleg@redhat.com \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.