aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/sysctl.c
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2006-09-27 04:51:04 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-09-27 11:26:19 -0400
commitb89a81712f486e4f7a606987413e387605fdeaf4 (patch)
tree98702b89a50e927c38f2e31cf824c10d2585722f /kernel/sysctl.c
parent571817849c76aabf34d534c905b5e604f2e824c5 (diff)
[PATCH] sysctl: Allow /proc/sys without sys_sysctl
Since sys_sysctl is deprecated start allow it to be compiled out. This should catch any remaining user space code that cares, and paves the way for further sysctl cleanups. [akpm@osdl.org: If sys_sysctl() is not compiled-in, emit a warning] Signed-off-by: Eric W. Biederman <ebiederm@xmission.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'kernel/sysctl.c')
-rw-r--r--kernel/sysctl.c113
1 files changed, 38 insertions, 75 deletions
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index bcb3a181dbb2..8bfa7d117c54 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -137,8 +137,11 @@ extern int no_unaligned_warning;
137extern int max_lock_depth; 137extern int max_lock_depth;
138#endif 138#endif
139 139
140static int parse_table(int __user *, int, void __user *, size_t __user *, void __user *, size_t, 140#ifdef CONFIG_SYSCTL_SYSCALL
141 ctl_table *, void **); 141static int parse_table(int __user *, int, void __user *, size_t __user *,
142 void __user *, size_t, ctl_table *, void **);
143#endif
144
142static int proc_doutsstring(ctl_table *table, int write, struct file *filp, 145static int proc_doutsstring(ctl_table *table, int write, struct file *filp,
143 void __user *buffer, size_t *lenp, loff_t *ppos); 146 void __user *buffer, size_t *lenp, loff_t *ppos);
144 147
@@ -165,7 +168,7 @@ int sysctl_legacy_va_layout;
165 168
166/* /proc declarations: */ 169/* /proc declarations: */
167 170
168#ifdef CONFIG_PROC_FS 171#ifdef CONFIG_PROC_SYSCTL
169 172
170static ssize_t proc_readsys(struct file *, char __user *, size_t, loff_t *); 173static ssize_t proc_readsys(struct file *, char __user *, size_t, loff_t *);
171static ssize_t proc_writesys(struct file *, const char __user *, size_t, loff_t *); 174static ssize_t proc_writesys(struct file *, const char __user *, size_t, loff_t *);
@@ -1166,12 +1169,13 @@ static void start_unregistering(struct ctl_table_header *p)
1166 1169
1167void __init sysctl_init(void) 1170void __init sysctl_init(void)
1168{ 1171{
1169#ifdef CONFIG_PROC_FS 1172#ifdef CONFIG_PROC_SYSCTL
1170 register_proc_table(root_table, proc_sys_root, &root_table_header); 1173 register_proc_table(root_table, proc_sys_root, &root_table_header);
1171 init_irq_proc(); 1174 init_irq_proc();
1172#endif 1175#endif
1173} 1176}
1174 1177
1178#ifdef CONFIG_SYSCTL_SYSCALL
1175int do_sysctl(int __user *name, int nlen, void __user *oldval, size_t __user *oldlenp, 1179int do_sysctl(int __user *name, int nlen, void __user *oldval, size_t __user *oldlenp,
1176 void __user *newval, size_t newlen) 1180 void __user *newval, size_t newlen)
1177{ 1181{
@@ -1225,6 +1229,7 @@ asmlinkage long sys_sysctl(struct __sysctl_args __user *args)
1225 unlock_kernel(); 1229 unlock_kernel();
1226 return error; 1230 return error;
1227} 1231}
1232#endif /* CONFIG_SYSCTL_SYSCALL */
1228 1233
1229/* 1234/*
1230 * ctl_perm does NOT grant the superuser all rights automatically, because 1235 * ctl_perm does NOT grant the superuser all rights automatically, because
@@ -1251,6 +1256,7 @@ static inline int ctl_perm(ctl_table *table, int op)
1251 return test_perm(table->mode, op); 1256 return test_perm(table->mode, op);
1252} 1257}
1253 1258
1259#ifdef CONFIG_SYSCTL_SYSCALL
1254static int parse_table(int __user *name, int nlen, 1260static int parse_table(int __user *name, int nlen,
1255 void __user *oldval, size_t __user *oldlenp, 1261 void __user *oldval, size_t __user *oldlenp,
1256 void __user *newval, size_t newlen, 1262 void __user *newval, size_t newlen,
@@ -1340,6 +1346,7 @@ int do_sysctl_strategy (ctl_table *table,
1340 } 1346 }
1341 return 0; 1347 return 0;
1342} 1348}
1349#endif /* CONFIG_SYSCTL_SYSCALL */
1343 1350
1344/** 1351/**
1345 * register_sysctl_table - register a sysctl hierarchy 1352 * register_sysctl_table - register a sysctl hierarchy
@@ -1427,7 +1434,7 @@ struct ctl_table_header *register_sysctl_table(ctl_table * table,
1427 else 1434 else
1428 list_add_tail(&tmp->ctl_entry, &root_table_header.ctl_entry); 1435 list_add_tail(&tmp->ctl_entry, &root_table_header.ctl_entry);
1429 spin_unlock(&sysctl_lock); 1436 spin_unlock(&sysctl_lock);
1430#ifdef CONFIG_PROC_FS 1437#ifdef CONFIG_PROC_SYSCTL
1431 register_proc_table(table, proc_sys_root, tmp); 1438 register_proc_table(table, proc_sys_root, tmp);
1432#endif 1439#endif
1433 return tmp; 1440 return tmp;
@@ -1445,18 +1452,31 @@ void unregister_sysctl_table(struct ctl_table_header * header)
1445 might_sleep(); 1452 might_sleep();
1446 spin_lock(&sysctl_lock); 1453 spin_lock(&sysctl_lock);
1447 start_unregistering(header); 1454 start_unregistering(header);
1448#ifdef CONFIG_PROC_FS 1455#ifdef CONFIG_PROC_SYSCTL
1449 unregister_proc_table(header->ctl_table, proc_sys_root); 1456 unregister_proc_table(header->ctl_table, proc_sys_root);
1450#endif 1457#endif
1451 spin_unlock(&sysctl_lock); 1458 spin_unlock(&sysctl_lock);
1452 kfree(header); 1459 kfree(header);
1453} 1460}
1454 1461
1462#else /* !CONFIG_SYSCTL */
1463struct ctl_table_header * register_sysctl_table(ctl_table * table,
1464 int insert_at_head)
1465{
1466 return NULL;
1467}
1468
1469void unregister_sysctl_table(struct ctl_table_header * table)
1470{
1471}
1472
1473#endif /* CONFIG_SYSCTL */
1474
1455/* 1475/*
1456 * /proc/sys support 1476 * /proc/sys support
1457 */ 1477 */
1458 1478
1459#ifdef CONFIG_PROC_FS 1479#ifdef CONFIG_PROC_SYSCTL
1460 1480
1461/* Scan the sysctl entries in table and add them all into /proc */ 1481/* Scan the sysctl entries in table and add them all into /proc */
1462static void register_proc_table(ctl_table * table, struct proc_dir_entry *root, void *set) 1482static void register_proc_table(ctl_table * table, struct proc_dir_entry *root, void *set)
@@ -2318,6 +2338,7 @@ int proc_doulongvec_ms_jiffies_minmax(ctl_table *table, int write,
2318#endif /* CONFIG_PROC_FS */ 2338#endif /* CONFIG_PROC_FS */
2319 2339
2320 2340
2341#ifdef CONFIG_SYSCTL_SYSCALL
2321/* 2342/*
2322 * General sysctl support routines 2343 * General sysctl support routines
2323 */ 2344 */
@@ -2460,11 +2481,19 @@ int sysctl_ms_jiffies(ctl_table *table, int __user *name, int nlen,
2460 return 1; 2481 return 1;
2461} 2482}
2462 2483
2463#else /* CONFIG_SYSCTL */ 2484#else /* CONFIG_SYSCTL_SYSCALL */
2464 2485
2465 2486
2466asmlinkage long sys_sysctl(struct __sysctl_args __user *args) 2487asmlinkage long sys_sysctl(struct __sysctl_args __user *args)
2467{ 2488{
2489 static int msg_count;
2490
2491 if (msg_count < 5) {
2492 msg_count++;
2493 printk(KERN_INFO
2494 "warning: process `%s' used the removed sysctl "
2495 "system call\n", current->comm);
2496 }
2468 return -ENOSYS; 2497 return -ENOSYS;
2469} 2498}
2470 2499
@@ -2496,73 +2525,7 @@ int sysctl_ms_jiffies(ctl_table *table, int __user *name, int nlen,
2496 return -ENOSYS; 2525 return -ENOSYS;
2497} 2526}
2498 2527
2499int proc_dostring(ctl_table *table, int write, struct file *filp, 2528#endif /* CONFIG_SYSCTL_SYSCALL */
2500 void __user *buffer, size_t *lenp, loff_t *ppos)
2501{
2502 return -ENOSYS;
2503}
2504
2505int proc_dointvec(ctl_table *table, int write, struct file *filp,
2506 void __user *buffer, size_t *lenp, loff_t *ppos)
2507{
2508 return -ENOSYS;
2509}
2510
2511int proc_dointvec_bset(ctl_table *table, int write, struct file *filp,
2512 void __user *buffer, size_t *lenp, loff_t *ppos)
2513{
2514 return -ENOSYS;
2515}
2516
2517int proc_dointvec_minmax(ctl_table *table, int write, struct file *filp,
2518 void __user *buffer, size_t *lenp, loff_t *ppos)
2519{
2520 return -ENOSYS;
2521}
2522
2523int proc_dointvec_jiffies(ctl_table *table, int write, struct file *filp,
2524 void __user *buffer, size_t *lenp, loff_t *ppos)
2525{
2526 return -ENOSYS;
2527}
2528
2529int proc_dointvec_userhz_jiffies(ctl_table *table, int write, struct file *filp,
2530 void __user *buffer, size_t *lenp, loff_t *ppos)
2531{
2532 return -ENOSYS;
2533}
2534
2535int proc_dointvec_ms_jiffies(ctl_table *table, int write, struct file *filp,
2536 void __user *buffer, size_t *lenp, loff_t *ppos)
2537{
2538 return -ENOSYS;
2539}
2540
2541int proc_doulongvec_minmax(ctl_table *table, int write, struct file *filp,
2542 void __user *buffer, size_t *lenp, loff_t *ppos)
2543{
2544 return -ENOSYS;
2545}
2546
2547int proc_doulongvec_ms_jiffies_minmax(ctl_table *table, int write,
2548 struct file *filp,
2549 void __user *buffer,
2550 size_t *lenp, loff_t *ppos)
2551{
2552 return -ENOSYS;
2553}
2554
2555struct ctl_table_header * register_sysctl_table(ctl_table * table,
2556 int insert_at_head)
2557{
2558 return NULL;
2559}
2560
2561void unregister_sysctl_table(struct ctl_table_header * table)
2562{
2563}
2564
2565#endif /* CONFIG_SYSCTL */
2566 2529
2567/* 2530/*
2568 * No sense putting this after each symbol definition, twice, 2531 * No sense putting this after each symbol definition, twice,