Skip to content

Commit 1ff007e

Browse files
ebiedermLinus Torvalds
authored andcommitted
[PATCH] sysctl: allow sysctl_perm to be called from outside of sysctl.c
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 805b5d5 commit 1ff007e

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

‎include/linux/sysctl.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -925,8 +925,10 @@ enum
925925
#include <linux/list.h>
926926

927927
/* For the /proc/sys support */
928+
struct ctl_table;
928929
extern struct ctl_table_header *sysctl_head_next(struct ctl_table_header *prev);
929930
extern void sysctl_head_finish(struct ctl_table_header *prev);
931+
extern int sysctl_perm(struct ctl_table *table, int op);
930932

931933
extern void sysctl_init(void);
932934

‎kernel/sysctl.c‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,7 +1157,7 @@ asmlinkage long sys_sysctl(struct __sysctl_args __user *args)
11571157
#endif /* CONFIG_SYSCTL_SYSCALL */
11581158

11591159
/*
1160-
* ctl_perm does NOT grant the superuser all rights automatically, because
1160+
* sysctl_perm does NOT grant the superuser all rights automatically, because
11611161
* some sysctl variables are readonly even to root.
11621162
*/
11631163

@@ -1172,7 +1172,7 @@ static int test_perm(int mode, int op)
11721172
return -EACCES;
11731173
}
11741174

1175-
static inline int ctl_perm(ctl_table *table, int op)
1175+
int sysctl_perm(ctl_table *table, int op)
11761176
{
11771177
int error;
11781178
error = security_sysctl(table, op);
@@ -1199,7 +1199,7 @@ static int parse_table(int __user *name, int nlen,
11991199
if (n == table->ctl_name) {
12001200
int error;
12011201
if (table->child) {
1202-
if (ctl_perm(table, 001))
1202+
if (sysctl_perm(table, 001))
12031203
return -EPERM;
12041204
name++;
12051205
nlen--;
@@ -1228,7 +1228,7 @@ int do_sysctl_strategy (ctl_table *table,
12281228
op |= 004;
12291229
if (newval)
12301230
op |= 002;
1231-
if (ctl_perm(table, op))
1231+
if (sysctl_perm(table, op))
12321232
return -EPERM;
12331233

12341234
if (table->strategy) {
@@ -1498,7 +1498,7 @@ static ssize_t do_rw_proc(int write, struct file * file, char __user * buf,
14981498
goto out;
14991499
error = -EPERM;
15001500
op = (write ? 002 : 004);
1501-
if (ctl_perm(table, op))
1501+
if (sysctl_perm(table, op))
15021502
goto out;
15031503

15041504
/* careful: calling conventions are nasty here */

0 commit comments

Comments
 (0)