diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2025-09-29 10:02:35 -0700 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2025-09-29 10:02:35 -0700 |
| commit | e571372101522fa91735dac6d30a160b2abe600c (patch) | |
| tree | 146cc6b5f1a65f974459e88e77b76ad61183e9bc /kernel/pid.c | |
| parent | Merge tag 'vfs-6.18-rc1.iomap' of git://git.kernel.org/pub/scm/linux/kernel/g... (diff) | |
| parent | Merge patch series "Improve pid_nr_ns()" (diff) | |
| download | linux-e571372101522fa91735dac6d30a160b2abe600c.tar.gz linux-e571372101522fa91735dac6d30a160b2abe600c.zip | |
Merge tag 'vfs-6.18-rc1.pidfs' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs
Pull pidfs updates from Christian Brauner:
"This just contains a few changes to pid_nr_ns() to make it more robust
and cleans up or improves a few users that ab- or misuse it currently"
* tag 'vfs-6.18-rc1.pidfs' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs:
pid: change task_state() to use task_ppid_nr_ns()
pid: change bacct_add_tsk() to use task_ppid_nr_ns()
pid: make __task_pid_nr_ns(ns => NULL) safe for zombie callers
pid: Add a judgment for ns null in pid_nr_ns
Diffstat (limited to 'kernel/pid.c')
| -rw-r--r-- | kernel/pid.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/kernel/pid.c b/kernel/pid.c index d94ce0250501..2dbcc4dd90cc 100644 --- a/kernel/pid.c +++ b/kernel/pid.c @@ -491,7 +491,7 @@ pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns) struct upid *upid; pid_t nr = 0; - if (pid && ns->level <= pid->level) { + if (pid && ns && ns->level <= pid->level) { upid = &pid->numbers[ns->level]; if (upid->ns == ns) nr = upid->nr; @@ -514,7 +514,8 @@ 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); - 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; |
