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
This commit is contained in:
@@ -157,13 +157,11 @@ static inline void task_state(struct seq_file *m, struct pid_namespace *ns,
|
||||
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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -57,12 +57,11 @@ void bacct_add_tsk(struct user_namespace *user_ns,
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user