Commit 4e757320 authored by Eric W. Biederman's avatar Eric W. Biederman

sysctl: Don't call sysctl_follow_link unless we are a link.

There are no functional changes.  Just code motion to make it
clear that we don't follow a link between sysctl roots unless the
directory entry actually is a link.
Suggested-by: default avatarLucian Adrian Grijincu <lucian.grijincu@gmail.com>
Signed-off-by: default avatarEric W. Biederman <ebiederm@xmission.com>
parent 60f126d9
...@@ -451,10 +451,12 @@ static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry, ...@@ -451,10 +451,12 @@ static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry,
if (!p) if (!p)
goto out; goto out;
if (S_ISLNK(p->mode)) {
ret = sysctl_follow_link(&h, &p, current->nsproxy); ret = sysctl_follow_link(&h, &p, current->nsproxy);
err = ERR_PTR(ret); err = ERR_PTR(ret);
if (ret) if (ret)
goto out; goto out;
}
err = ERR_PTR(-ENOMEM); err = ERR_PTR(-ENOMEM);
inode = proc_sys_make_inode(dir->i_sb, h ? h : head, p); inode = proc_sys_make_inode(dir->i_sb, h ? h : head, p);
...@@ -601,10 +603,12 @@ static int proc_sys_link_fill_cache(struct file *filp, void *dirent, ...@@ -601,10 +603,12 @@ static int proc_sys_link_fill_cache(struct file *filp, void *dirent,
int err, ret = 0; int err, ret = 0;
head = sysctl_head_grab(head); head = sysctl_head_grab(head);
if (S_ISLNK(table->mode)) {
/* It is not an error if we can not follow the link ignore it */ /* It is not an error if we can not follow the link ignore it */
err = sysctl_follow_link(&head, &table, current->nsproxy); err = sysctl_follow_link(&head, &table, current->nsproxy);
if (err) if (err)
goto out; goto out;
}
ret = proc_sys_fill_cache(filp, dirent, filldir, head, table); ret = proc_sys_fill_cache(filp, dirent, filldir, head, table);
out: out:
...@@ -950,10 +954,6 @@ static int sysctl_follow_link(struct ctl_table_header **phead, ...@@ -950,10 +954,6 @@ static int sysctl_follow_link(struct ctl_table_header **phead,
struct ctl_dir *dir; struct ctl_dir *dir;
int ret; int ret;
/* Get out quickly if not a link */
if (!S_ISLNK((*pentry)->mode))
return 0;
ret = 0; ret = 0;
spin_lock(&sysctl_lock); spin_lock(&sysctl_lock);
root = (*pentry)->data; root = (*pentry)->data;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment