aboutsummaryrefslogtreecommitdiffstats
path: root/fs/proc
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2015-11-17 10:20:54 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2015-12-08 22:41:54 -0500
commit6b2553918d8b4e6de9853fd6315bec7271a2e592 (patch)
tree85540dcb0dc0de3d67c68d0aa7b17058f4e96539 /fs/proc
parent21fc61c73c3903c4c312d0802da01ec2b323d174 (diff)
replace ->follow_link() with new method that could stay in RCU mode
new method: ->get_link(); replacement of ->follow_link(). The differences are: * inode and dentry are passed separately * might be called both in RCU and non-RCU mode; the former is indicated by passing it a NULL dentry. * when called that way it isn't allowed to block and should return ERR_PTR(-ECHILD) if it needs to be called in non-RCU mode. It's a flagday change - the old method is gone, all in-tree instances converted. Conversion isn't hard; said that, so far very few instances do not immediately bail out when called in RCU mode. That'll change in the next commits. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/proc')
-rw-r--r--fs/proc/base.c22
-rw-r--r--fs/proc/inode.c7
-rw-r--r--fs/proc/namespaces.c9
-rw-r--r--fs/proc/self.c9
-rw-r--r--fs/proc/thread_self.c9
5 files changed, 35 insertions, 21 deletions
diff --git a/fs/proc/base.c b/fs/proc/base.c
index bd3e9e68125b..1a489e2b9768 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -1564,12 +1564,15 @@ static int proc_exe_link(struct dentry *dentry, struct path *exe_path)
1564 return -ENOENT; 1564 return -ENOENT;
1565} 1565}
1566 1566
1567static const char *proc_pid_follow_link(struct dentry *dentry, void **cookie) 1567static const char *proc_pid_get_link(struct dentry *dentry,
1568 struct inode *inode, void **cookie)
1568{ 1569{
1569 struct inode *inode = d_inode(dentry);
1570 struct path path; 1570 struct path path;
1571 int error = -EACCES; 1571 int error = -EACCES;
1572 1572
1573 if (!dentry)
1574 return ERR_PTR(-ECHILD);
1575
1573 /* Are we allowed to snoop on the tasks file descriptors? */ 1576 /* Are we allowed to snoop on the tasks file descriptors? */
1574 if (!proc_fd_access_allowed(inode)) 1577 if (!proc_fd_access_allowed(inode))
1575 goto out; 1578 goto out;
@@ -1630,7 +1633,7 @@ out:
1630 1633
1631const struct inode_operations proc_pid_link_inode_operations = { 1634const struct inode_operations proc_pid_link_inode_operations = {
1632 .readlink = proc_pid_readlink, 1635 .readlink = proc_pid_readlink,
1633 .follow_link = proc_pid_follow_link, 1636 .get_link = proc_pid_get_link,
1634 .setattr = proc_setattr, 1637 .setattr = proc_setattr,
1635}; 1638};
1636 1639
@@ -1895,7 +1898,7 @@ static const struct dentry_operations tid_map_files_dentry_operations = {
1895 .d_delete = pid_delete_dentry, 1898 .d_delete = pid_delete_dentry,
1896}; 1899};
1897 1900
1898static int proc_map_files_get_link(struct dentry *dentry, struct path *path) 1901static int map_files_get_link(struct dentry *dentry, struct path *path)
1899{ 1902{
1900 unsigned long vm_start, vm_end; 1903 unsigned long vm_start, vm_end;
1901 struct vm_area_struct *vma; 1904 struct vm_area_struct *vma;
@@ -1945,20 +1948,21 @@ struct map_files_info {
1945 * path to the file in question. 1948 * path to the file in question.
1946 */ 1949 */
1947static const char * 1950static const char *
1948proc_map_files_follow_link(struct dentry *dentry, void **cookie) 1951proc_map_files_get_link(struct dentry *dentry,
1952 struct inode *inode, void **cookie)
1949{ 1953{
1950 if (!capable(CAP_SYS_ADMIN)) 1954 if (!capable(CAP_SYS_ADMIN))
1951 return ERR_PTR(-EPERM); 1955 return ERR_PTR(-EPERM);
1952 1956
1953 return proc_pid_follow_link(dentry, NULL); 1957 return proc_pid_get_link(dentry, inode, NULL);
1954} 1958}
1955 1959
1956/* 1960/*
1957 * Identical to proc_pid_link_inode_operations except for follow_link() 1961 * Identical to proc_pid_link_inode_operations except for get_link()
1958 */ 1962 */
1959static const struct inode_operations proc_map_files_link_inode_operations = { 1963static const struct inode_operations proc_map_files_link_inode_operations = {
1960 .readlink = proc_pid_readlink, 1964 .readlink = proc_pid_readlink,
1961 .follow_link = proc_map_files_follow_link, 1965 .get_link = proc_map_files_get_link,
1962 .setattr = proc_setattr, 1966 .setattr = proc_setattr,
1963}; 1967};
1964 1968
@@ -1975,7 +1979,7 @@ proc_map_files_instantiate(struct inode *dir, struct dentry *dentry,
1975 return -ENOENT; 1979 return -ENOENT;
1976 1980
1977 ei = PROC_I(inode); 1981 ei = PROC_I(inode);
1978 ei->op.proc_get_link = proc_map_files_get_link; 1982 ei->op.proc_get_link = map_files_get_link;
1979 1983
1980 inode->i_op = &proc_map_files_link_inode_operations; 1984 inode->i_op = &proc_map_files_link_inode_operations;
1981 inode->i_size = 64; 1985 inode->i_size = 64;
diff --git a/fs/proc/inode.c b/fs/proc/inode.c
index bd95b9fdebb0..10360b268794 100644
--- a/fs/proc/inode.c
+++ b/fs/proc/inode.c
@@ -393,9 +393,10 @@ static const struct file_operations proc_reg_file_ops_no_compat = {
393}; 393};
394#endif 394#endif
395 395
396static const char *proc_follow_link(struct dentry *dentry, void **cookie) 396static const char *proc_get_link(struct dentry *dentry,
397 struct inode *inode, void **cookie)
397{ 398{
398 struct proc_dir_entry *pde = PDE(d_inode(dentry)); 399 struct proc_dir_entry *pde = PDE(inode);
399 if (unlikely(!use_pde(pde))) 400 if (unlikely(!use_pde(pde)))
400 return ERR_PTR(-EINVAL); 401 return ERR_PTR(-EINVAL);
401 *cookie = pde; 402 *cookie = pde;
@@ -409,7 +410,7 @@ static void proc_put_link(struct inode *unused, void *p)
409 410
410const struct inode_operations proc_link_inode_operations = { 411const struct inode_operations proc_link_inode_operations = {
411 .readlink = generic_readlink, 412 .readlink = generic_readlink,
412 .follow_link = proc_follow_link, 413 .get_link = proc_get_link,
413 .put_link = proc_put_link, 414 .put_link = proc_put_link,
414}; 415};
415 416
diff --git a/fs/proc/namespaces.c b/fs/proc/namespaces.c
index f6e8354b8cea..63861c15e109 100644
--- a/fs/proc/namespaces.c
+++ b/fs/proc/namespaces.c
@@ -30,14 +30,17 @@ static const struct proc_ns_operations *ns_entries[] = {
30 &mntns_operations, 30 &mntns_operations,
31}; 31};
32 32
33static const char *proc_ns_follow_link(struct dentry *dentry, void **cookie) 33static const char *proc_ns_get_link(struct dentry *dentry,
34 struct inode *inode, void **cookie)
34{ 35{
35 struct inode *inode = d_inode(dentry);
36 const struct proc_ns_operations *ns_ops = PROC_I(inode)->ns_ops; 36 const struct proc_ns_operations *ns_ops = PROC_I(inode)->ns_ops;
37 struct task_struct *task; 37 struct task_struct *task;
38 struct path ns_path; 38 struct path ns_path;
39 void *error = ERR_PTR(-EACCES); 39 void *error = ERR_PTR(-EACCES);
40 40
41 if (!dentry)
42 return ERR_PTR(-ECHILD);
43
41 task = get_proc_task(inode); 44 task = get_proc_task(inode);
42 if (!task) 45 if (!task)
43 return error; 46 return error;
@@ -74,7 +77,7 @@ static int proc_ns_readlink(struct dentry *dentry, char __user *buffer, int bufl
74 77
75static const struct inode_operations proc_ns_link_inode_operations = { 78static const struct inode_operations proc_ns_link_inode_operations = {
76 .readlink = proc_ns_readlink, 79 .readlink = proc_ns_readlink,
77 .follow_link = proc_ns_follow_link, 80 .get_link = proc_ns_get_link,
78 .setattr = proc_setattr, 81 .setattr = proc_setattr,
79}; 82};
80 83
diff --git a/fs/proc/self.c b/fs/proc/self.c
index 113b8d061fc0..9dd0ae6aefdb 100644
--- a/fs/proc/self.c
+++ b/fs/proc/self.c
@@ -18,12 +18,15 @@ static int proc_self_readlink(struct dentry *dentry, char __user *buffer,
18 return readlink_copy(buffer, buflen, tmp); 18 return readlink_copy(buffer, buflen, tmp);
19} 19}
20 20
21static const char *proc_self_follow_link(struct dentry *dentry, void **cookie) 21static const char *proc_self_get_link(struct dentry *dentry,
22 struct inode *inode, void **cookie)
22{ 23{
23 struct pid_namespace *ns = dentry->d_sb->s_fs_info; 24 struct pid_namespace *ns = inode->i_sb->s_fs_info;
24 pid_t tgid = task_tgid_nr_ns(current, ns); 25 pid_t tgid = task_tgid_nr_ns(current, ns);
25 char *name; 26 char *name;
26 27
28 if (!dentry)
29 return ERR_PTR(-ECHILD);
27 if (!tgid) 30 if (!tgid)
28 return ERR_PTR(-ENOENT); 31 return ERR_PTR(-ENOENT);
29 /* 11 for max length of signed int in decimal + NULL term */ 32 /* 11 for max length of signed int in decimal + NULL term */
@@ -36,7 +39,7 @@ static const char *proc_self_follow_link(struct dentry *dentry, void **cookie)
36 39
37static const struct inode_operations proc_self_inode_operations = { 40static const struct inode_operations proc_self_inode_operations = {
38 .readlink = proc_self_readlink, 41 .readlink = proc_self_readlink,
39 .follow_link = proc_self_follow_link, 42 .get_link = proc_self_get_link,
40 .put_link = kfree_put_link, 43 .put_link = kfree_put_link,
41}; 44};
42 45
diff --git a/fs/proc/thread_self.c b/fs/proc/thread_self.c
index 947b0f4fd0a1..50eef6f3e671 100644
--- a/fs/proc/thread_self.c
+++ b/fs/proc/thread_self.c
@@ -19,13 +19,16 @@ static int proc_thread_self_readlink(struct dentry *dentry, char __user *buffer,
19 return readlink_copy(buffer, buflen, tmp); 19 return readlink_copy(buffer, buflen, tmp);
20} 20}
21 21
22static const char *proc_thread_self_follow_link(struct dentry *dentry, void **cookie) 22static const char *proc_thread_self_get_link(struct dentry *dentry,
23 struct inode *inode, void **cookie)
23{ 24{
24 struct pid_namespace *ns = dentry->d_sb->s_fs_info; 25 struct pid_namespace *ns = inode->i_sb->s_fs_info;
25 pid_t tgid = task_tgid_nr_ns(current, ns); 26 pid_t tgid = task_tgid_nr_ns(current, ns);
26 pid_t pid = task_pid_nr_ns(current, ns); 27 pid_t pid = task_pid_nr_ns(current, ns);
27 char *name; 28 char *name;
28 29
30 if (!dentry)
31 return ERR_PTR(-ECHILD);
29 if (!pid) 32 if (!pid)
30 return ERR_PTR(-ENOENT); 33 return ERR_PTR(-ENOENT);
31 name = kmalloc(PROC_NUMBUF + 6 + PROC_NUMBUF, GFP_KERNEL); 34 name = kmalloc(PROC_NUMBUF + 6 + PROC_NUMBUF, GFP_KERNEL);
@@ -37,7 +40,7 @@ static const char *proc_thread_self_follow_link(struct dentry *dentry, void **co
37 40
38static const struct inode_operations proc_thread_self_inode_operations = { 41static const struct inode_operations proc_thread_self_inode_operations = {
39 .readlink = proc_thread_self_readlink, 42 .readlink = proc_thread_self_readlink,
40 .follow_link = proc_thread_self_follow_link, 43 .get_link = proc_thread_self_get_link,
41 .put_link = kfree_put_link, 44 .put_link = kfree_put_link,
42}; 45};
43 46