aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/proc/array.c7
-rw-r--r--fs/proc/base.c18
-rw-r--r--fs/proc/self.c4
-rw-r--r--fs/proc/thread_self.c4
-rw-r--r--include/linux/proc_fs.h6
5 files changed, 19 insertions, 20 deletions
diff --git a/fs/proc/array.c b/fs/proc/array.c
index ae2c807fd719..911f66924d81 100644
--- a/fs/proc/array.c
+++ b/fs/proc/array.c
@@ -677,12 +677,7 @@ out:
677 677
678static int children_seq_show(struct seq_file *seq, void *v) 678static int children_seq_show(struct seq_file *seq, void *v)
679{ 679{
680 struct inode *inode = seq->private; 680 seq_printf(seq, "%d ", pid_nr_ns(v, proc_pid_ns(seq->private)));
681 pid_t pid;
682
683 pid = pid_nr_ns(v, inode->i_sb->s_fs_info);
684 seq_printf(seq, "%d ", pid);
685
686 return 0; 681 return 0;
687} 682}
688 683
diff --git a/fs/proc/base.c b/fs/proc/base.c
index 1b2ede6abcdf..29237cad19fd 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -698,7 +698,7 @@ static bool has_pid_permissions(struct pid_namespace *pid,
698 698
699static int proc_pid_permission(struct inode *inode, int mask) 699static int proc_pid_permission(struct inode *inode, int mask)
700{ 700{
701 struct pid_namespace *pid = inode->i_sb->s_fs_info; 701 struct pid_namespace *pid = proc_pid_ns(inode);
702 struct task_struct *task; 702 struct task_struct *task;
703 bool has_perms; 703 bool has_perms;
704 704
@@ -733,13 +733,11 @@ static const struct inode_operations proc_def_inode_operations = {
733static int proc_single_show(struct seq_file *m, void *v) 733static int proc_single_show(struct seq_file *m, void *v)
734{ 734{
735 struct inode *inode = m->private; 735 struct inode *inode = m->private;
736 struct pid_namespace *ns; 736 struct pid_namespace *ns = proc_pid_ns(inode);
737 struct pid *pid; 737 struct pid *pid = proc_pid(inode);
738 struct task_struct *task; 738 struct task_struct *task;
739 int ret; 739 int ret;
740 740
741 ns = inode->i_sb->s_fs_info;
742 pid = proc_pid(inode);
743 task = get_pid_task(pid, PIDTYPE_PID); 741 task = get_pid_task(pid, PIDTYPE_PID);
744 if (!task) 742 if (!task)
745 return -ESRCH; 743 return -ESRCH;
@@ -1410,7 +1408,7 @@ static const struct file_operations proc_fail_nth_operations = {
1410static int sched_show(struct seq_file *m, void *v) 1408static int sched_show(struct seq_file *m, void *v)
1411{ 1409{
1412 struct inode *inode = m->private; 1410 struct inode *inode = m->private;
1413 struct pid_namespace *ns = inode->i_sb->s_fs_info; 1411 struct pid_namespace *ns = proc_pid_ns(inode);
1414 struct task_struct *p; 1412 struct task_struct *p;
1415 1413
1416 p = get_proc_task(inode); 1414 p = get_proc_task(inode);
@@ -1782,8 +1780,8 @@ int pid_getattr(const struct path *path, struct kstat *stat,
1782 u32 request_mask, unsigned int query_flags) 1780 u32 request_mask, unsigned int query_flags)
1783{ 1781{
1784 struct inode *inode = d_inode(path->dentry); 1782 struct inode *inode = d_inode(path->dentry);
1783 struct pid_namespace *pid = proc_pid_ns(inode);
1785 struct task_struct *task; 1784 struct task_struct *task;
1786 struct pid_namespace *pid = path->dentry->d_sb->s_fs_info;
1787 1785
1788 generic_fillattr(inode, stat); 1786 generic_fillattr(inode, stat);
1789 1787
@@ -2337,7 +2335,7 @@ static int proc_timers_open(struct inode *inode, struct file *file)
2337 return -ENOMEM; 2335 return -ENOMEM;
2338 2336
2339 tp->pid = proc_pid(inode); 2337 tp->pid = proc_pid(inode);
2340 tp->ns = inode->i_sb->s_fs_info; 2338 tp->ns = proc_pid_ns(inode);
2341 return 0; 2339 return 0;
2342} 2340}
2343 2341
@@ -3239,7 +3237,7 @@ retry:
3239int proc_pid_readdir(struct file *file, struct dir_context *ctx) 3237int proc_pid_readdir(struct file *file, struct dir_context *ctx)
3240{ 3238{
3241 struct tgid_iter iter; 3239 struct tgid_iter iter;
3242 struct pid_namespace *ns = file_inode(file)->i_sb->s_fs_info; 3240 struct pid_namespace *ns = proc_pid_ns(file_inode(file));
3243 loff_t pos = ctx->pos; 3241 loff_t pos = ctx->pos;
3244 3242
3245 if (pos >= PID_MAX_LIMIT + TGID_OFFSET) 3243 if (pos >= PID_MAX_LIMIT + TGID_OFFSET)
@@ -3588,7 +3586,7 @@ static int proc_task_readdir(struct file *file, struct dir_context *ctx)
3588 /* f_version caches the tgid value that the last readdir call couldn't 3586 /* f_version caches the tgid value that the last readdir call couldn't
3589 * return. lseek aka telldir automagically resets f_version to 0. 3587 * return. lseek aka telldir automagically resets f_version to 0.
3590 */ 3588 */
3591 ns = inode->i_sb->s_fs_info; 3589 ns = proc_pid_ns(inode);
3592 tid = (int)file->f_version; 3590 tid = (int)file->f_version;
3593 file->f_version = 0; 3591 file->f_version = 0;
3594 for (task = first_tid(proc_pid(inode), tid, ctx->pos - 2, ns); 3592 for (task = first_tid(proc_pid(inode), tid, ctx->pos - 2, ns);
diff --git a/fs/proc/self.c b/fs/proc/self.c
index 4d7d061696b3..127265e5c55f 100644
--- a/fs/proc/self.c
+++ b/fs/proc/self.c
@@ -12,7 +12,7 @@ static const char *proc_self_get_link(struct dentry *dentry,
12 struct inode *inode, 12 struct inode *inode,
13 struct delayed_call *done) 13 struct delayed_call *done)
14{ 14{
15 struct pid_namespace *ns = inode->i_sb->s_fs_info; 15 struct pid_namespace *ns = proc_pid_ns(inode);
16 pid_t tgid = task_tgid_nr_ns(current, ns); 16 pid_t tgid = task_tgid_nr_ns(current, ns);
17 char *name; 17 char *name;
18 18
@@ -36,7 +36,7 @@ static unsigned self_inum __ro_after_init;
36int proc_setup_self(struct super_block *s) 36int proc_setup_self(struct super_block *s)
37{ 37{
38 struct inode *root_inode = d_inode(s->s_root); 38 struct inode *root_inode = d_inode(s->s_root);
39 struct pid_namespace *ns = s->s_fs_info; 39 struct pid_namespace *ns = proc_pid_ns(root_inode);
40 struct dentry *self; 40 struct dentry *self;
41 41
42 inode_lock(root_inode); 42 inode_lock(root_inode);
diff --git a/fs/proc/thread_self.c b/fs/proc/thread_self.c
index 9d2efaca499f..b905010ca9eb 100644
--- a/fs/proc/thread_self.c
+++ b/fs/proc/thread_self.c
@@ -12,7 +12,7 @@ static const char *proc_thread_self_get_link(struct dentry *dentry,
12 struct inode *inode, 12 struct inode *inode,
13 struct delayed_call *done) 13 struct delayed_call *done)
14{ 14{
15 struct pid_namespace *ns = inode->i_sb->s_fs_info; 15 struct pid_namespace *ns = proc_pid_ns(inode);
16 pid_t tgid = task_tgid_nr_ns(current, ns); 16 pid_t tgid = task_tgid_nr_ns(current, ns);
17 pid_t pid = task_pid_nr_ns(current, ns); 17 pid_t pid = task_pid_nr_ns(current, ns);
18 char *name; 18 char *name;
@@ -36,7 +36,7 @@ static unsigned thread_self_inum __ro_after_init;
36int proc_setup_thread_self(struct super_block *s) 36int proc_setup_thread_self(struct super_block *s)
37{ 37{
38 struct inode *root_inode = d_inode(s->s_root); 38 struct inode *root_inode = d_inode(s->s_root);
39 struct pid_namespace *ns = s->s_fs_info; 39 struct pid_namespace *ns = proc_pid_ns(root_inode);
40 struct dentry *thread_self; 40 struct dentry *thread_self;
41 41
42 inode_lock(root_inode); 42 inode_lock(root_inode);
diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
index 928ef9e4d912..4edcde510631 100644
--- a/include/linux/proc_fs.h
+++ b/include/linux/proc_fs.h
@@ -83,4 +83,10 @@ struct ns_common;
83int open_related_ns(struct ns_common *ns, 83int open_related_ns(struct ns_common *ns,
84 struct ns_common *(*get_ns)(struct ns_common *ns)); 84 struct ns_common *(*get_ns)(struct ns_common *ns));
85 85
86/* get the associated pid namespace for a file in procfs */
87static inline struct pid_namespace *proc_pid_ns(struct inode *inode)
88{
89 return inode->i_sb->s_fs_info;
90}
91
86#endif /* _LINUX_PROC_FS_H */ 92#endif /* _LINUX_PROC_FS_H */