aboutsummaryrefslogtreecommitdiffstats
path: root/fs/proc/base.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/proc/base.c')
-rw-r--r--fs/proc/base.c51
1 files changed, 28 insertions, 23 deletions
diff --git a/fs/proc/base.c b/fs/proc/base.c
index 437195f204e1..2772208338f8 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -1427,16 +1427,19 @@ static int proc_exe_link(struct dentry *dentry, struct path *exe_path)
1427static void *proc_pid_follow_link(struct dentry *dentry, struct nameidata *nd) 1427static void *proc_pid_follow_link(struct dentry *dentry, struct nameidata *nd)
1428{ 1428{
1429 struct inode *inode = dentry->d_inode; 1429 struct inode *inode = dentry->d_inode;
1430 struct path path;
1430 int error = -EACCES; 1431 int error = -EACCES;
1431 1432
1432 /* We don't need a base pointer in the /proc filesystem */
1433 path_put(&nd->path);
1434
1435 /* Are we allowed to snoop on the tasks file descriptors? */ 1433 /* Are we allowed to snoop on the tasks file descriptors? */
1436 if (!proc_fd_access_allowed(inode)) 1434 if (!proc_fd_access_allowed(inode))
1437 goto out; 1435 goto out;
1438 1436
1439 error = PROC_I(inode)->op.proc_get_link(dentry, &nd->path); 1437 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
1438 if (error)
1439 goto out;
1440
1441 nd_jump_link(nd, &path);
1442 return NULL;
1440out: 1443out:
1441 return ERR_PTR(error); 1444 return ERR_PTR(error);
1442} 1445}
@@ -1601,13 +1604,13 @@ int pid_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
1601 * made this apply to all per process world readable and executable 1604 * made this apply to all per process world readable and executable
1602 * directories. 1605 * directories.
1603 */ 1606 */
1604int pid_revalidate(struct dentry *dentry, struct nameidata *nd) 1607int pid_revalidate(struct dentry *dentry, unsigned int flags)
1605{ 1608{
1606 struct inode *inode; 1609 struct inode *inode;
1607 struct task_struct *task; 1610 struct task_struct *task;
1608 const struct cred *cred; 1611 const struct cred *cred;
1609 1612
1610 if (nd && nd->flags & LOOKUP_RCU) 1613 if (flags & LOOKUP_RCU)
1611 return -ECHILD; 1614 return -ECHILD;
1612 1615
1613 inode = dentry->d_inode; 1616 inode = dentry->d_inode;
@@ -1781,7 +1784,7 @@ static int proc_fd_link(struct dentry *dentry, struct path *path)
1781 return proc_fd_info(dentry->d_inode, path, NULL); 1784 return proc_fd_info(dentry->d_inode, path, NULL);
1782} 1785}
1783 1786
1784static int tid_fd_revalidate(struct dentry *dentry, struct nameidata *nd) 1787static int tid_fd_revalidate(struct dentry *dentry, unsigned int flags)
1785{ 1788{
1786 struct inode *inode; 1789 struct inode *inode;
1787 struct task_struct *task; 1790 struct task_struct *task;
@@ -1789,7 +1792,7 @@ static int tid_fd_revalidate(struct dentry *dentry, struct nameidata *nd)
1789 struct files_struct *files; 1792 struct files_struct *files;
1790 const struct cred *cred; 1793 const struct cred *cred;
1791 1794
1792 if (nd && nd->flags & LOOKUP_RCU) 1795 if (flags & LOOKUP_RCU)
1793 return -ECHILD; 1796 return -ECHILD;
1794 1797
1795 inode = dentry->d_inode; 1798 inode = dentry->d_inode;
@@ -1868,7 +1871,7 @@ static struct dentry *proc_fd_instantiate(struct inode *dir,
1868 d_set_d_op(dentry, &tid_fd_dentry_operations); 1871 d_set_d_op(dentry, &tid_fd_dentry_operations);
1869 d_add(dentry, inode); 1872 d_add(dentry, inode);
1870 /* Close the race of the process dying before we return the dentry */ 1873 /* Close the race of the process dying before we return the dentry */
1871 if (tid_fd_revalidate(dentry, NULL)) 1874 if (tid_fd_revalidate(dentry, 0))
1872 error = NULL; 1875 error = NULL;
1873 1876
1874 out: 1877 out:
@@ -1956,7 +1959,7 @@ out_no_task:
1956} 1959}
1957 1960
1958static struct dentry *proc_lookupfd(struct inode *dir, struct dentry *dentry, 1961static struct dentry *proc_lookupfd(struct inode *dir, struct dentry *dentry,
1959 struct nameidata *nd) 1962 unsigned int flags)
1960{ 1963{
1961 return proc_lookupfd_common(dir, dentry, proc_fd_instantiate); 1964 return proc_lookupfd_common(dir, dentry, proc_fd_instantiate);
1962} 1965}
@@ -2003,7 +2006,7 @@ static int dname_to_vma_addr(struct dentry *dentry,
2003 return 0; 2006 return 0;
2004} 2007}
2005 2008
2006static int map_files_d_revalidate(struct dentry *dentry, struct nameidata *nd) 2009static int map_files_d_revalidate(struct dentry *dentry, unsigned int flags)
2007{ 2010{
2008 unsigned long vm_start, vm_end; 2011 unsigned long vm_start, vm_end;
2009 bool exact_vma_exists = false; 2012 bool exact_vma_exists = false;
@@ -2013,7 +2016,7 @@ static int map_files_d_revalidate(struct dentry *dentry, struct nameidata *nd)
2013 struct inode *inode; 2016 struct inode *inode;
2014 int status = 0; 2017 int status = 0;
2015 2018
2016 if (nd && nd->flags & LOOKUP_RCU) 2019 if (flags & LOOKUP_RCU)
2017 return -ECHILD; 2020 return -ECHILD;
2018 2021
2019 if (!capable(CAP_SYS_ADMIN)) { 2022 if (!capable(CAP_SYS_ADMIN)) {
@@ -2145,7 +2148,7 @@ proc_map_files_instantiate(struct inode *dir, struct dentry *dentry,
2145} 2148}
2146 2149
2147static struct dentry *proc_map_files_lookup(struct inode *dir, 2150static struct dentry *proc_map_files_lookup(struct inode *dir,
2148 struct dentry *dentry, struct nameidata *nd) 2151 struct dentry *dentry, unsigned int flags)
2149{ 2152{
2150 unsigned long vm_start, vm_end; 2153 unsigned long vm_start, vm_end;
2151 struct vm_area_struct *vma; 2154 struct vm_area_struct *vma;
@@ -2371,7 +2374,7 @@ static struct dentry *proc_fdinfo_instantiate(struct inode *dir,
2371 d_set_d_op(dentry, &tid_fd_dentry_operations); 2374 d_set_d_op(dentry, &tid_fd_dentry_operations);
2372 d_add(dentry, inode); 2375 d_add(dentry, inode);
2373 /* Close the race of the process dying before we return the dentry */ 2376 /* Close the race of the process dying before we return the dentry */
2374 if (tid_fd_revalidate(dentry, NULL)) 2377 if (tid_fd_revalidate(dentry, 0))
2375 error = NULL; 2378 error = NULL;
2376 2379
2377 out: 2380 out:
@@ -2380,7 +2383,7 @@ static struct dentry *proc_fdinfo_instantiate(struct inode *dir,
2380 2383
2381static struct dentry *proc_lookupfdinfo(struct inode *dir, 2384static struct dentry *proc_lookupfdinfo(struct inode *dir,
2382 struct dentry *dentry, 2385 struct dentry *dentry,
2383 struct nameidata *nd) 2386 unsigned int flags)
2384{ 2387{
2385 return proc_lookupfd_common(dir, dentry, proc_fdinfo_instantiate); 2388 return proc_lookupfd_common(dir, dentry, proc_fdinfo_instantiate);
2386} 2389}
@@ -2430,7 +2433,7 @@ static struct dentry *proc_pident_instantiate(struct inode *dir,
2430 d_set_d_op(dentry, &pid_dentry_operations); 2433 d_set_d_op(dentry, &pid_dentry_operations);
2431 d_add(dentry, inode); 2434 d_add(dentry, inode);
2432 /* Close the race of the process dying before we return the dentry */ 2435 /* Close the race of the process dying before we return the dentry */
2433 if (pid_revalidate(dentry, NULL)) 2436 if (pid_revalidate(dentry, 0))
2434 error = NULL; 2437 error = NULL;
2435out: 2438out:
2436 return error; 2439 return error;
@@ -2630,7 +2633,7 @@ static const struct file_operations proc_attr_dir_operations = {
2630}; 2633};
2631 2634
2632static struct dentry *proc_attr_dir_lookup(struct inode *dir, 2635static struct dentry *proc_attr_dir_lookup(struct inode *dir,
2633 struct dentry *dentry, struct nameidata *nd) 2636 struct dentry *dentry, unsigned int flags)
2634{ 2637{
2635 return proc_pident_lookup(dir, dentry, 2638 return proc_pident_lookup(dir, dentry,
2636 attr_dir_stuff, ARRAY_SIZE(attr_dir_stuff)); 2639 attr_dir_stuff, ARRAY_SIZE(attr_dir_stuff));
@@ -3114,7 +3117,8 @@ static const struct file_operations proc_tgid_base_operations = {
3114 .llseek = default_llseek, 3117 .llseek = default_llseek,
3115}; 3118};
3116 3119
3117static struct dentry *proc_tgid_base_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd){ 3120static struct dentry *proc_tgid_base_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags)
3121{
3118 return proc_pident_lookup(dir, dentry, 3122 return proc_pident_lookup(dir, dentry,
3119 tgid_base_stuff, ARRAY_SIZE(tgid_base_stuff)); 3123 tgid_base_stuff, ARRAY_SIZE(tgid_base_stuff));
3120} 3124}
@@ -3237,13 +3241,13 @@ static struct dentry *proc_pid_instantiate(struct inode *dir,
3237 3241
3238 d_add(dentry, inode); 3242 d_add(dentry, inode);
3239 /* Close the race of the process dying before we return the dentry */ 3243 /* Close the race of the process dying before we return the dentry */
3240 if (pid_revalidate(dentry, NULL)) 3244 if (pid_revalidate(dentry, 0))
3241 error = NULL; 3245 error = NULL;
3242out: 3246out:
3243 return error; 3247 return error;
3244} 3248}
3245 3249
3246struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, struct nameidata *nd) 3250struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, unsigned int flags)
3247{ 3251{
3248 struct dentry *result; 3252 struct dentry *result;
3249 struct task_struct *task; 3253 struct task_struct *task;
@@ -3470,7 +3474,8 @@ static int proc_tid_base_readdir(struct file * filp,
3470 tid_base_stuff,ARRAY_SIZE(tid_base_stuff)); 3474 tid_base_stuff,ARRAY_SIZE(tid_base_stuff));
3471} 3475}
3472 3476
3473static struct dentry *proc_tid_base_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd){ 3477static struct dentry *proc_tid_base_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags)
3478{
3474 return proc_pident_lookup(dir, dentry, 3479 return proc_pident_lookup(dir, dentry,
3475 tid_base_stuff, ARRAY_SIZE(tid_base_stuff)); 3480 tid_base_stuff, ARRAY_SIZE(tid_base_stuff));
3476} 3481}
@@ -3508,13 +3513,13 @@ static struct dentry *proc_task_instantiate(struct inode *dir,
3508 3513
3509 d_add(dentry, inode); 3514 d_add(dentry, inode);
3510 /* Close the race of the process dying before we return the dentry */ 3515 /* Close the race of the process dying before we return the dentry */
3511 if (pid_revalidate(dentry, NULL)) 3516 if (pid_revalidate(dentry, 0))
3512 error = NULL; 3517 error = NULL;
3513out: 3518out:
3514 return error; 3519 return error;
3515} 3520}
3516 3521
3517static struct dentry *proc_task_lookup(struct inode *dir, struct dentry * dentry, struct nameidata *nd) 3522static struct dentry *proc_task_lookup(struct inode *dir, struct dentry * dentry, unsigned int flags)
3518{ 3523{
3519 struct dentry *result = ERR_PTR(-ENOENT); 3524 struct dentry *result = ERR_PTR(-ENOENT);
3520 struct task_struct *task; 3525 struct task_struct *task;