Skip to content

Commit 3673dd3

Browse files
committed
Merge patch series "Revert "pid: make __task_pid_nr_ns(ns => NULL) safe for zombie callers""
Commit 006568a ("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(). * patches from https://patch.msgid.link/20251015123550.GA9447@redhat.com: pid: introduce task_ppid_vnr() helper Revert "pid: make __task_pid_nr_ns(ns => NULL) safe for zombie callers" Link: https://patch.msgid.link/20251015123550.GA9447@redhat.com Signed-off-by: Christian Brauner <brauner@kernel.org>
2 parents 87caaee + 84f90ab commit 3673dd3

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

fs/pidfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ static long pidfd_info(struct file *file, unsigned int cmd, unsigned long arg)
446446
* the fields are set correctly, or return ESRCH to avoid providing
447447
* incomplete information. */
448448

449-
kinfo.ppid = task_ppid_nr_ns(task, NULL);
449+
kinfo.ppid = task_ppid_vnr(task);
450450
kinfo.tgid = task_tgid_vnr(task);
451451
kinfo.pid = task_pid_vnr(task);
452452
kinfo.mask |= PIDFD_INFO_PID;

include/linux/pid.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,11 @@ static inline pid_t task_ppid_nr_ns(const struct task_struct *tsk, struct pid_na
310310
return pid;
311311
}
312312

313+
static inline pid_t task_ppid_vnr(const struct task_struct *tsk)
314+
{
315+
return task_ppid_nr_ns(tsk, NULL);
316+
}
317+
313318
static inline pid_t task_ppid_nr(const struct task_struct *tsk)
314319
{
315320
return task_ppid_nr_ns(tsk, &init_pid_ns);

kernel/pid.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -558,8 +558,7 @@ pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
558558
rcu_read_lock();
559559
if (!ns)
560560
ns = task_active_pid_ns(current);
561-
if (ns)
562-
nr = pid_nr_ns(rcu_dereference(*task_pid_ptr(task, type)), ns);
561+
nr = pid_nr_ns(rcu_dereference(*task_pid_ptr(task, type)), ns);
563562
rcu_read_unlock();
564563

565564
return nr;

0 commit comments

Comments
 (0)