Commit 1ff007eb authored by Eric W. Biederman's avatar Eric W. Biederman Committed by Linus Torvalds

[PATCH] sysctl: allow sysctl_perm to be called from outside of sysctl.c

Signed-off-by: default avatarEric W. Biederman <ebiederm@xmission.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 805b5d5e
...@@ -925,8 +925,10 @@ enum ...@@ -925,8 +925,10 @@ enum
#include <linux/list.h> #include <linux/list.h>
/* For the /proc/sys support */ /* For the /proc/sys support */
struct ctl_table;
extern struct ctl_table_header *sysctl_head_next(struct ctl_table_header *prev); extern struct ctl_table_header *sysctl_head_next(struct ctl_table_header *prev);
extern void sysctl_head_finish(struct ctl_table_header *prev); extern void sysctl_head_finish(struct ctl_table_header *prev);
extern int sysctl_perm(struct ctl_table *table, int op);
extern void sysctl_init(void); extern void sysctl_init(void);
......
...@@ -1157,7 +1157,7 @@ asmlinkage long sys_sysctl(struct __sysctl_args __user *args) ...@@ -1157,7 +1157,7 @@ asmlinkage long sys_sysctl(struct __sysctl_args __user *args)
#endif /* CONFIG_SYSCTL_SYSCALL */ #endif /* CONFIG_SYSCTL_SYSCALL */
/* /*
* ctl_perm does NOT grant the superuser all rights automatically, because * sysctl_perm does NOT grant the superuser all rights automatically, because
* some sysctl variables are readonly even to root. * some sysctl variables are readonly even to root.
*/ */
...@@ -1172,7 +1172,7 @@ static int test_perm(int mode, int op) ...@@ -1172,7 +1172,7 @@ static int test_perm(int mode, int op)
return -EACCES; return -EACCES;
} }
static inline int ctl_perm(ctl_table *table, int op) int sysctl_perm(ctl_table *table, int op)
{ {
int error; int error;
error = security_sysctl(table, op); error = security_sysctl(table, op);
...@@ -1199,7 +1199,7 @@ static int parse_table(int __user *name, int nlen, ...@@ -1199,7 +1199,7 @@ static int parse_table(int __user *name, int nlen,
if (n == table->ctl_name) { if (n == table->ctl_name) {
int error; int error;
if (table->child) { if (table->child) {
if (ctl_perm(table, 001)) if (sysctl_perm(table, 001))
return -EPERM; return -EPERM;
name++; name++;
nlen--; nlen--;
...@@ -1228,7 +1228,7 @@ int do_sysctl_strategy (ctl_table *table, ...@@ -1228,7 +1228,7 @@ int do_sysctl_strategy (ctl_table *table,
op |= 004; op |= 004;
if (newval) if (newval)
op |= 002; op |= 002;
if (ctl_perm(table, op)) if (sysctl_perm(table, op))
return -EPERM; return -EPERM;
if (table->strategy) { if (table->strategy) {
...@@ -1498,7 +1498,7 @@ static ssize_t do_rw_proc(int write, struct file * file, char __user * buf, ...@@ -1498,7 +1498,7 @@ static ssize_t do_rw_proc(int write, struct file * file, char __user * buf,
goto out; goto out;
error = -EPERM; error = -EPERM;
op = (write ? 002 : 004); op = (write ? 002 : 004);
if (ctl_perm(table, op)) if (sysctl_perm(table, op))
goto out; goto out;
/* careful: calling conventions are nasty here */ /* careful: calling conventions are nasty here */
......
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