diff options
Diffstat (limited to 'fs/proc/base.c')
-rw-r--r-- | fs/proc/base.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/fs/proc/base.c b/fs/proc/base.c index 77a57b5799c4..1a979ea3b379 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c | |||
@@ -371,9 +371,11 @@ static int mounts_open(struct inode *inode, struct file *file) | |||
371 | 371 | ||
372 | if (task) { | 372 | if (task) { |
373 | task_lock(task); | 373 | task_lock(task); |
374 | ns = task->nsproxy->mnt_ns; | 374 | if (task->nsproxy) { |
375 | if (ns) | 375 | ns = task->nsproxy->mnt_ns; |
376 | get_mnt_ns(ns); | 376 | if (ns) |
377 | get_mnt_ns(ns); | ||
378 | } | ||
377 | task_unlock(task); | 379 | task_unlock(task); |
378 | put_task_struct(task); | 380 | put_task_struct(task); |
379 | } | 381 | } |
@@ -2326,13 +2328,23 @@ static int proc_task_readdir(struct file * filp, void * dirent, filldir_t filldi | |||
2326 | { | 2328 | { |
2327 | struct dentry *dentry = filp->f_path.dentry; | 2329 | struct dentry *dentry = filp->f_path.dentry; |
2328 | struct inode *inode = dentry->d_inode; | 2330 | struct inode *inode = dentry->d_inode; |
2329 | struct task_struct *leader = get_proc_task(inode); | 2331 | struct task_struct *leader = NULL; |
2330 | struct task_struct *task; | 2332 | struct task_struct *task; |
2331 | int retval = -ENOENT; | 2333 | int retval = -ENOENT; |
2332 | ino_t ino; | 2334 | ino_t ino; |
2333 | int tid; | 2335 | int tid; |
2334 | unsigned long pos = filp->f_pos; /* avoiding "long long" filp->f_pos */ | 2336 | unsigned long pos = filp->f_pos; /* avoiding "long long" filp->f_pos */ |
2335 | 2337 | ||
2338 | task = get_proc_task(inode); | ||
2339 | if (!task) | ||
2340 | goto out_no_task; | ||
2341 | rcu_read_lock(); | ||
2342 | if (pid_alive(task)) { | ||
2343 | leader = task->group_leader; | ||
2344 | get_task_struct(leader); | ||
2345 | } | ||
2346 | rcu_read_unlock(); | ||
2347 | put_task_struct(task); | ||
2336 | if (!leader) | 2348 | if (!leader) |
2337 | goto out_no_task; | 2349 | goto out_no_task; |
2338 | retval = 0; | 2350 | retval = 0; |