diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2016-01-11 16:13:23 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-01-11 16:13:23 -0500 |
commit | 32fb378437a1d716e72a442237d7ead1f435ecf0 (patch) | |
tree | 411b25023d4df908fb8ca4517185d49c37c51e10 /fs/proc | |
parent | 19ccb28e296d5afa299db1003d37e5d37994d46e (diff) | |
parent | fceef393a538134f03b778c5d2519e670269342f (diff) |
Merge branch 'work.symlinks' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull vfs RCU symlink updates from Al Viro:
"Replacement of ->follow_link/->put_link, allowing to stay in RCU mode
even if the symlink is not an embedded one.
No changes since the mailbomb on Jan 1"
* 'work.symlinks' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
switch ->get_link() to delayed_call, kill ->put_link()
kill free_page_put_link()
teach nfs_get_link() to work in RCU mode
teach proc_self_get_link()/proc_thread_self_get_link() to work in RCU mode
teach shmem_get_link() to work in RCU mode
teach page_get_link() to work in RCU mode
replace ->follow_link() with new method that could stay in RCU mode
don't put symlink bodies in pagecache into highmem
namei: page_getlink() and page_follow_link_light() are the same thing
ufs: get rid of ->setattr() for symlinks
udf: don't duplicate page_symlink_inode_operations
logfs: don't duplicate page_symlink_inode_operations
switch befs long symlinks to page_symlink_operations
Diffstat (limited to 'fs/proc')
-rw-r--r-- | fs/proc/base.c | 24 | ||||
-rw-r--r-- | fs/proc/inode.c | 21 | ||||
-rw-r--r-- | fs/proc/namespaces.c | 10 | ||||
-rw-r--r-- | fs/proc/self.c | 18 | ||||
-rw-r--r-- | fs/proc/thread_self.c | 19 |
5 files changed, 54 insertions, 38 deletions
diff --git a/fs/proc/base.c b/fs/proc/base.c index 4bd5d3118acd..55e01f88eac9 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c | |||
@@ -1564,12 +1564,16 @@ static int proc_exe_link(struct dentry *dentry, struct path *exe_path) | |||
1564 | return -ENOENT; | 1564 | return -ENOENT; |
1565 | } | 1565 | } |
1566 | 1566 | ||
1567 | static const char *proc_pid_follow_link(struct dentry *dentry, void **cookie) | 1567 | static const char *proc_pid_get_link(struct dentry *dentry, |
1568 | struct inode *inode, | ||
1569 | struct delayed_call *done) | ||
1568 | { | 1570 | { |
1569 | struct inode *inode = d_inode(dentry); | ||
1570 | struct path path; | 1571 | struct path path; |
1571 | int error = -EACCES; | 1572 | int error = -EACCES; |
1572 | 1573 | ||
1574 | if (!dentry) | ||
1575 | return ERR_PTR(-ECHILD); | ||
1576 | |||
1573 | /* Are we allowed to snoop on the tasks file descriptors? */ | 1577 | /* Are we allowed to snoop on the tasks file descriptors? */ |
1574 | if (!proc_fd_access_allowed(inode)) | 1578 | if (!proc_fd_access_allowed(inode)) |
1575 | goto out; | 1579 | goto out; |
@@ -1630,7 +1634,7 @@ out: | |||
1630 | 1634 | ||
1631 | const struct inode_operations proc_pid_link_inode_operations = { | 1635 | const struct inode_operations proc_pid_link_inode_operations = { |
1632 | .readlink = proc_pid_readlink, | 1636 | .readlink = proc_pid_readlink, |
1633 | .follow_link = proc_pid_follow_link, | 1637 | .get_link = proc_pid_get_link, |
1634 | .setattr = proc_setattr, | 1638 | .setattr = proc_setattr, |
1635 | }; | 1639 | }; |
1636 | 1640 | ||
@@ -1895,7 +1899,7 @@ static const struct dentry_operations tid_map_files_dentry_operations = { | |||
1895 | .d_delete = pid_delete_dentry, | 1899 | .d_delete = pid_delete_dentry, |
1896 | }; | 1900 | }; |
1897 | 1901 | ||
1898 | static int proc_map_files_get_link(struct dentry *dentry, struct path *path) | 1902 | static int map_files_get_link(struct dentry *dentry, struct path *path) |
1899 | { | 1903 | { |
1900 | unsigned long vm_start, vm_end; | 1904 | unsigned long vm_start, vm_end; |
1901 | struct vm_area_struct *vma; | 1905 | struct vm_area_struct *vma; |
@@ -1945,20 +1949,22 @@ struct map_files_info { | |||
1945 | * path to the file in question. | 1949 | * path to the file in question. |
1946 | */ | 1950 | */ |
1947 | static const char * | 1951 | static const char * |
1948 | proc_map_files_follow_link(struct dentry *dentry, void **cookie) | 1952 | proc_map_files_get_link(struct dentry *dentry, |
1953 | struct inode *inode, | ||
1954 | struct delayed_call *done) | ||
1949 | { | 1955 | { |
1950 | if (!capable(CAP_SYS_ADMIN)) | 1956 | if (!capable(CAP_SYS_ADMIN)) |
1951 | return ERR_PTR(-EPERM); | 1957 | return ERR_PTR(-EPERM); |
1952 | 1958 | ||
1953 | return proc_pid_follow_link(dentry, NULL); | 1959 | return proc_pid_get_link(dentry, inode, done); |
1954 | } | 1960 | } |
1955 | 1961 | ||
1956 | /* | 1962 | /* |
1957 | * Identical to proc_pid_link_inode_operations except for follow_link() | 1963 | * Identical to proc_pid_link_inode_operations except for get_link() |
1958 | */ | 1964 | */ |
1959 | static const struct inode_operations proc_map_files_link_inode_operations = { | 1965 | static const struct inode_operations proc_map_files_link_inode_operations = { |
1960 | .readlink = proc_pid_readlink, | 1966 | .readlink = proc_pid_readlink, |
1961 | .follow_link = proc_map_files_follow_link, | 1967 | .get_link = proc_map_files_get_link, |
1962 | .setattr = proc_setattr, | 1968 | .setattr = proc_setattr, |
1963 | }; | 1969 | }; |
1964 | 1970 | ||
@@ -1975,7 +1981,7 @@ proc_map_files_instantiate(struct inode *dir, struct dentry *dentry, | |||
1975 | return -ENOENT; | 1981 | return -ENOENT; |
1976 | 1982 | ||
1977 | ei = PROC_I(inode); | 1983 | ei = PROC_I(inode); |
1978 | ei->op.proc_get_link = proc_map_files_get_link; | 1984 | ei->op.proc_get_link = map_files_get_link; |
1979 | 1985 | ||
1980 | inode->i_op = &proc_map_files_link_inode_operations; | 1986 | inode->i_op = &proc_map_files_link_inode_operations; |
1981 | inode->i_size = 64; | 1987 | inode->i_size = 64; |
diff --git a/fs/proc/inode.c b/fs/proc/inode.c index bd95b9fdebb0..d0e9b9b6223e 100644 --- a/fs/proc/inode.c +++ b/fs/proc/inode.c | |||
@@ -393,24 +393,25 @@ static const struct file_operations proc_reg_file_ops_no_compat = { | |||
393 | }; | 393 | }; |
394 | #endif | 394 | #endif |
395 | 395 | ||
396 | static const char *proc_follow_link(struct dentry *dentry, void **cookie) | 396 | static void proc_put_link(void *p) |
397 | { | 397 | { |
398 | struct proc_dir_entry *pde = PDE(d_inode(dentry)); | 398 | unuse_pde(p); |
399 | if (unlikely(!use_pde(pde))) | ||
400 | return ERR_PTR(-EINVAL); | ||
401 | *cookie = pde; | ||
402 | return pde->data; | ||
403 | } | 399 | } |
404 | 400 | ||
405 | static void proc_put_link(struct inode *unused, void *p) | 401 | static const char *proc_get_link(struct dentry *dentry, |
402 | struct inode *inode, | ||
403 | struct delayed_call *done) | ||
406 | { | 404 | { |
407 | unuse_pde(p); | 405 | struct proc_dir_entry *pde = PDE(inode); |
406 | if (unlikely(!use_pde(pde))) | ||
407 | return ERR_PTR(-EINVAL); | ||
408 | set_delayed_call(done, proc_put_link, pde); | ||
409 | return pde->data; | ||
408 | } | 410 | } |
409 | 411 | ||
410 | const struct inode_operations proc_link_inode_operations = { | 412 | const struct inode_operations proc_link_inode_operations = { |
411 | .readlink = generic_readlink, | 413 | .readlink = generic_readlink, |
412 | .follow_link = proc_follow_link, | 414 | .get_link = proc_get_link, |
413 | .put_link = proc_put_link, | ||
414 | }; | 415 | }; |
415 | 416 | ||
416 | struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de) | 417 | struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de) |
diff --git a/fs/proc/namespaces.c b/fs/proc/namespaces.c index f6e8354b8cea..1dece8781f91 100644 --- a/fs/proc/namespaces.c +++ b/fs/proc/namespaces.c | |||
@@ -30,14 +30,18 @@ static const struct proc_ns_operations *ns_entries[] = { | |||
30 | &mntns_operations, | 30 | &mntns_operations, |
31 | }; | 31 | }; |
32 | 32 | ||
33 | static const char *proc_ns_follow_link(struct dentry *dentry, void **cookie) | 33 | static const char *proc_ns_get_link(struct dentry *dentry, |
34 | struct inode *inode, | ||
35 | struct delayed_call *done) | ||
34 | { | 36 | { |
35 | struct inode *inode = d_inode(dentry); | ||
36 | const struct proc_ns_operations *ns_ops = PROC_I(inode)->ns_ops; | 37 | const struct proc_ns_operations *ns_ops = PROC_I(inode)->ns_ops; |
37 | struct task_struct *task; | 38 | struct task_struct *task; |
38 | struct path ns_path; | 39 | struct path ns_path; |
39 | void *error = ERR_PTR(-EACCES); | 40 | void *error = ERR_PTR(-EACCES); |
40 | 41 | ||
42 | if (!dentry) | ||
43 | return ERR_PTR(-ECHILD); | ||
44 | |||
41 | task = get_proc_task(inode); | 45 | task = get_proc_task(inode); |
42 | if (!task) | 46 | if (!task) |
43 | return error; | 47 | return error; |
@@ -74,7 +78,7 @@ static int proc_ns_readlink(struct dentry *dentry, char __user *buffer, int bufl | |||
74 | 78 | ||
75 | static const struct inode_operations proc_ns_link_inode_operations = { | 79 | static const struct inode_operations proc_ns_link_inode_operations = { |
76 | .readlink = proc_ns_readlink, | 80 | .readlink = proc_ns_readlink, |
77 | .follow_link = proc_ns_follow_link, | 81 | .get_link = proc_ns_get_link, |
78 | .setattr = proc_setattr, | 82 | .setattr = proc_setattr, |
79 | }; | 83 | }; |
80 | 84 | ||
diff --git a/fs/proc/self.c b/fs/proc/self.c index 113b8d061fc0..67e8db442cf0 100644 --- a/fs/proc/self.c +++ b/fs/proc/self.c | |||
@@ -18,26 +18,28 @@ 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 | ||
21 | static const char *proc_self_follow_link(struct dentry *dentry, void **cookie) | 21 | static const char *proc_self_get_link(struct dentry *dentry, |
22 | struct inode *inode, | ||
23 | struct delayed_call *done) | ||
22 | { | 24 | { |
23 | struct pid_namespace *ns = dentry->d_sb->s_fs_info; | 25 | struct pid_namespace *ns = inode->i_sb->s_fs_info; |
24 | pid_t tgid = task_tgid_nr_ns(current, ns); | 26 | pid_t tgid = task_tgid_nr_ns(current, ns); |
25 | char *name; | 27 | char *name; |
26 | 28 | ||
27 | if (!tgid) | 29 | if (!tgid) |
28 | return ERR_PTR(-ENOENT); | 30 | return ERR_PTR(-ENOENT); |
29 | /* 11 for max length of signed int in decimal + NULL term */ | 31 | /* 11 for max length of signed int in decimal + NULL term */ |
30 | name = kmalloc(12, GFP_KERNEL); | 32 | name = kmalloc(12, dentry ? GFP_KERNEL : GFP_ATOMIC); |
31 | if (!name) | 33 | if (unlikely(!name)) |
32 | return ERR_PTR(-ENOMEM); | 34 | return dentry ? ERR_PTR(-ENOMEM) : ERR_PTR(-ECHILD); |
33 | sprintf(name, "%d", tgid); | 35 | sprintf(name, "%d", tgid); |
34 | return *cookie = name; | 36 | set_delayed_call(done, kfree_link, name); |
37 | return name; | ||
35 | } | 38 | } |
36 | 39 | ||
37 | static const struct inode_operations proc_self_inode_operations = { | 40 | static 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, | ||
41 | }; | 43 | }; |
42 | 44 | ||
43 | static unsigned self_inum; | 45 | static unsigned self_inum; |
diff --git a/fs/proc/thread_self.c b/fs/proc/thread_self.c index 947b0f4fd0a1..9eacd59e0360 100644 --- a/fs/proc/thread_self.c +++ b/fs/proc/thread_self.c | |||
@@ -19,26 +19,29 @@ 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 | ||
22 | static const char *proc_thread_self_follow_link(struct dentry *dentry, void **cookie) | 22 | static const char *proc_thread_self_get_link(struct dentry *dentry, |
23 | struct inode *inode, | ||
24 | struct delayed_call *done) | ||
23 | { | 25 | { |
24 | struct pid_namespace *ns = dentry->d_sb->s_fs_info; | 26 | struct pid_namespace *ns = inode->i_sb->s_fs_info; |
25 | pid_t tgid = task_tgid_nr_ns(current, ns); | 27 | pid_t tgid = task_tgid_nr_ns(current, ns); |
26 | pid_t pid = task_pid_nr_ns(current, ns); | 28 | pid_t pid = task_pid_nr_ns(current, ns); |
27 | char *name; | 29 | char *name; |
28 | 30 | ||
29 | if (!pid) | 31 | if (!pid) |
30 | return ERR_PTR(-ENOENT); | 32 | return ERR_PTR(-ENOENT); |
31 | name = kmalloc(PROC_NUMBUF + 6 + PROC_NUMBUF, GFP_KERNEL); | 33 | name = kmalloc(PROC_NUMBUF + 6 + PROC_NUMBUF, |
32 | if (!name) | 34 | dentry ? GFP_KERNEL : GFP_ATOMIC); |
33 | return ERR_PTR(-ENOMEM); | 35 | if (unlikely(!name)) |
36 | return dentry ? ERR_PTR(-ENOMEM) : ERR_PTR(-ECHILD); | ||
34 | sprintf(name, "%d/task/%d", tgid, pid); | 37 | sprintf(name, "%d/task/%d", tgid, pid); |
35 | return *cookie = name; | 38 | set_delayed_call(done, kfree_link, name); |
39 | return name; | ||
36 | } | 40 | } |
37 | 41 | ||
38 | static const struct inode_operations proc_thread_self_inode_operations = { | 42 | static const struct inode_operations proc_thread_self_inode_operations = { |
39 | .readlink = proc_thread_self_readlink, | 43 | .readlink = proc_thread_self_readlink, |
40 | .follow_link = proc_thread_self_follow_link, | 44 | .get_link = proc_thread_self_get_link, |
41 | .put_link = kfree_put_link, | ||
42 | }; | 45 | }; |
43 | 46 | ||
44 | static unsigned thread_self_inum; | 47 | static unsigned thread_self_inum; |