Commit b89a81712f486e4f7a606987413e387605fdeaf4

Authored by Eric W. Biederman
Committed by Linus Torvalds
1 parent 571817849c

[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>

Showing 9 changed files with 81 additions and 96 deletions Side-by-side Diff

arch/ia64/ia32/sys_ia32.c
... ... @@ -1942,7 +1942,7 @@
1942 1942 unsigned int __unused[4];
1943 1943 };
1944 1944  
1945   -#ifdef CONFIG_SYSCTL
  1945 +#ifdef CONFIG_SYSCTL_SYSCALL
1946 1946 asmlinkage long
1947 1947 sys32_sysctl (struct sysctl32 __user *args)
1948 1948 {
arch/mips/kernel/linux32.c
... ... @@ -991,7 +991,7 @@
991 991 unsigned int __unused[4];
992 992 };
993 993  
994   -#ifdef CONFIG_SYSCTL
  994 +#ifdef CONFIG_SYSCTL_SYSCALL
995 995  
996 996 asmlinkage long sys32_sysctl(struct sysctl_args32 __user *args)
997 997 {
... ... @@ -1032,7 +1032,7 @@
1032 1032 return error;
1033 1033 }
1034 1034  
1035   -#endif /* CONFIG_SYSCTL */
  1035 +#endif /* CONFIG_SYSCTL_SYSCALL */
1036 1036  
1037 1037 asmlinkage long sys32_newuname(struct new_utsname __user * name)
1038 1038 {
arch/powerpc/kernel/sys_ppc32.c
... ... @@ -740,7 +740,7 @@
740 740 return sys_umask((int)mask);
741 741 }
742 742  
743   -#ifdef CONFIG_SYSCTL
  743 +#ifdef CONFIG_SYSCTL_SYSCALL
744 744 struct __sysctl_args32 {
745 745 u32 name;
746 746 int nlen;
arch/s390/kernel/compat_linux.c
... ... @@ -708,7 +708,7 @@
708 708 return ret;
709 709 }
710 710  
711   -#ifdef CONFIG_SYSCTL
  711 +#ifdef CONFIG_SYSCTL_SYSCALL
712 712 struct __sysctl_args32 {
713 713 u32 name;
714 714 int nlen;
arch/sparc64/kernel/sys_sparc32.c
... ... @@ -1016,7 +1016,7 @@
1016 1016  
1017 1017 asmlinkage long sys32_sysctl(struct __sysctl_args32 __user *args)
1018 1018 {
1019   -#ifndef CONFIG_SYSCTL
  1019 +#ifndef CONFIG_SYSCTL_SYSCALL
1020 1020 return -ENOSYS;
1021 1021 #else
1022 1022 struct __sysctl_args32 tmp;
arch/x86_64/ia32/sys_ia32.c
... ... @@ -648,7 +648,7 @@
648 648 }
649 649  
650 650  
651   -#ifdef CONFIG_SYSCTL
  651 +#ifdef CONFIG_SYSCTL_SYSCALL
652 652 struct sysctl_ia32 {
653 653 unsigned int name;
654 654 int nlen;
... ... @@ -826,6 +826,25 @@
826 826 help
827 827 Exports the dump image of crashed kernel in ELF format.
828 828  
  829 +config PROC_SYSCTL
  830 + bool "Sysctl support (/proc/sys)" if EMBEDDED
  831 + depends on PROC_FS
  832 + select SYSCTL
  833 + default y
  834 + ---help---
  835 + The sysctl interface provides a means of dynamically changing
  836 + certain kernel parameters and variables on the fly without requiring
  837 + a recompile of the kernel or reboot of the system. The primary
  838 + interface is through /proc/sys. If you say Y here a tree of
  839 + modifiable sysctl entries will be generated beneath the
  840 + /proc/sys directory. They are explained in the files
  841 + in <file:Documentation/sysctl/>. Note that enabling this
  842 + option will enlarge the kernel by at least 8 KB.
  843 +
  844 + As it is generally a good thing, you should say Y here unless
  845 + building a kernel for install/rescue disks or your system is very
  846 + limited in memory.
  847 +
829 848 config SYSFS
830 849 bool "sysfs file system support" if EMBEDDED
831 850 default y
... ... @@ -273,21 +273,24 @@
273 273 This enables the legacy 16-bit UID syscall wrappers.
274 274  
275 275 config SYSCTL
276   - bool "Sysctl support" if EMBEDDED
277   - default y
  276 + bool
  277 +
  278 +config SYSCTL_SYSCALL
  279 + bool "Sysctl syscall support"
  280 + default n
  281 + select SYSCTL
278 282 ---help---
279   - The sysctl interface provides a means of dynamically changing
280   - certain kernel parameters and variables on the fly without requiring
281   - a recompile of the kernel or reboot of the system. The primary
282   - interface consists of a system call, but if you say Y to "/proc
283   - file system support", a tree of modifiable sysctl entries will be
284   - generated beneath the /proc/sys directory. They are explained in the
285   - files in <file:Documentation/sysctl/>. Note that enabling this
286   - option will enlarge the kernel by at least 8 KB.
  283 + Enable the deprecated sysctl system call. sys_sysctl uses
  284 + binary paths that have been found to be a major pain to maintain
  285 + and use. The interface in /proc/sys is now the primary and what
  286 + everyone uses.
287 287  
288   - As it is generally a good thing, you should say Y here unless
289   - building a kernel for install/rescue disks or your system is very
290   - limited in memory.
  288 + Nothing has been using the binary sysctl interface for some time
  289 + time now so nothing should break if you disable sysctl syscall
  290 + support, and you kernel will get marginally smaller.
  291 +
  292 + Unless you have an application that uses the sys_syscall interface
  293 + you should probably say N here.
291 294  
292 295 config KALLSYMS
293 296 bool "Load all symbols for debugging/kksymoops" if EMBEDDED
... ... @@ -137,8 +137,11 @@
137 137 extern int max_lock_depth;
138 138 #endif
139 139  
140   -static int parse_table(int __user *, int, void __user *, size_t __user *, void __user *, size_t,
141   - ctl_table *, void **);
  140 +#ifdef CONFIG_SYSCTL_SYSCALL
  141 +static int parse_table(int __user *, int, void __user *, size_t __user *,
  142 + void __user *, size_t, ctl_table *, void **);
  143 +#endif
  144 +
142 145 static int proc_doutsstring(ctl_table *table, int write, struct file *filp,
143 146 void __user *buffer, size_t *lenp, loff_t *ppos);
144 147  
... ... @@ -165,7 +168,7 @@
165 168  
166 169 /* /proc declarations: */
167 170  
168   -#ifdef CONFIG_PROC_FS
  171 +#ifdef CONFIG_PROC_SYSCTL
169 172  
170 173 static ssize_t proc_readsys(struct file *, char __user *, size_t, loff_t *);
171 174 static ssize_t proc_writesys(struct file *, const char __user *, size_t, loff_t *);
172 175  
... ... @@ -1166,12 +1169,13 @@
1166 1169  
1167 1170 void __init sysctl_init(void)
1168 1171 {
1169   -#ifdef CONFIG_PROC_FS
  1172 +#ifdef CONFIG_PROC_SYSCTL
1170 1173 register_proc_table(root_table, proc_sys_root, &root_table_header);
1171 1174 init_irq_proc();
1172 1175 #endif
1173 1176 }
1174 1177  
  1178 +#ifdef CONFIG_SYSCTL_SYSCALL
1175 1179 int do_sysctl(int __user *name, int nlen, void __user *oldval, size_t __user *oldlenp,
1176 1180 void __user *newval, size_t newlen)
1177 1181 {
... ... @@ -1225,6 +1229,7 @@
1225 1229 unlock_kernel();
1226 1230 return error;
1227 1231 }
  1232 +#endif /* CONFIG_SYSCTL_SYSCALL */
1228 1233  
1229 1234 /*
1230 1235 * ctl_perm does NOT grant the superuser all rights automatically, because
... ... @@ -1251,6 +1256,7 @@
1251 1256 return test_perm(table->mode, op);
1252 1257 }
1253 1258  
  1259 +#ifdef CONFIG_SYSCTL_SYSCALL
1254 1260 static int parse_table(int __user *name, int nlen,
1255 1261 void __user *oldval, size_t __user *oldlenp,
1256 1262 void __user *newval, size_t newlen,
... ... @@ -1340,6 +1346,7 @@
1340 1346 }
1341 1347 return 0;
1342 1348 }
  1349 +#endif /* CONFIG_SYSCTL_SYSCALL */
1343 1350  
1344 1351 /**
1345 1352 * register_sysctl_table - register a sysctl hierarchy
... ... @@ -1427,7 +1434,7 @@
1427 1434 else
1428 1435 list_add_tail(&tmp->ctl_entry, &root_table_header.ctl_entry);
1429 1436 spin_unlock(&sysctl_lock);
1430   -#ifdef CONFIG_PROC_FS
  1437 +#ifdef CONFIG_PROC_SYSCTL
1431 1438 register_proc_table(table, proc_sys_root, tmp);
1432 1439 #endif
1433 1440 return tmp;
1434 1441  
1435 1442  
... ... @@ -1445,18 +1452,31 @@
1445 1452 might_sleep();
1446 1453 spin_lock(&sysctl_lock);
1447 1454 start_unregistering(header);
1448   -#ifdef CONFIG_PROC_FS
  1455 +#ifdef CONFIG_PROC_SYSCTL
1449 1456 unregister_proc_table(header->ctl_table, proc_sys_root);
1450 1457 #endif
1451 1458 spin_unlock(&sysctl_lock);
1452 1459 kfree(header);
1453 1460 }
1454 1461  
  1462 +#else /* !CONFIG_SYSCTL */
  1463 +struct ctl_table_header * register_sysctl_table(ctl_table * table,
  1464 + int insert_at_head)
  1465 +{
  1466 + return NULL;
  1467 +}
  1468 +
  1469 +void unregister_sysctl_table(struct ctl_table_header * table)
  1470 +{
  1471 +}
  1472 +
  1473 +#endif /* CONFIG_SYSCTL */
  1474 +
1455 1475 /*
1456 1476 * /proc/sys support
1457 1477 */
1458 1478  
1459   -#ifdef CONFIG_PROC_FS
  1479 +#ifdef CONFIG_PROC_SYSCTL
1460 1480  
1461 1481 /* Scan the sysctl entries in table and add them all into /proc */
1462 1482 static void register_proc_table(ctl_table * table, struct proc_dir_entry *root, void *set)
... ... @@ -2318,6 +2338,7 @@
2318 2338 #endif /* CONFIG_PROC_FS */
2319 2339  
2320 2340  
  2341 +#ifdef CONFIG_SYSCTL_SYSCALL
2321 2342 /*
2322 2343 * General sysctl support routines
2323 2344 */
2324 2345  
... ... @@ -2460,11 +2481,19 @@
2460 2481 return 1;
2461 2482 }
2462 2483  
2463   -#else /* CONFIG_SYSCTL */
  2484 +#else /* CONFIG_SYSCTL_SYSCALL */
2464 2485  
2465 2486  
2466 2487 asmlinkage 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 2497 return -ENOSYS;
2469 2498 }
2470 2499  
... ... @@ -2496,73 +2525,7 @@
2496 2525 return -ENOSYS;
2497 2526 }
2498 2527  
2499   -int proc_dostring(ctl_table *table, int write, struct file *filp,
2500   - void __user *buffer, size_t *lenp, loff_t *ppos)
2501   -{
2502   - return -ENOSYS;
2503   -}
2504   -
2505   -int 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   -
2511   -int 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   -
2517   -int 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   -
2523   -int 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   -
2529   -int 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   -
2535   -int 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   -
2541   -int 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   -
2547   -int 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   -
2555   -struct ctl_table_header * register_sysctl_table(ctl_table * table,
2556   - int insert_at_head)
2557   -{
2558   - return NULL;
2559   -}
2560   -
2561   -void unregister_sysctl_table(struct ctl_table_header * table)
2562   -{
2563   -}
2564   -
2565   -#endif /* CONFIG_SYSCTL */
  2528 +#endif /* CONFIG_SYSCTL_SYSCALL */
2566 2529  
2567 2530 /*
2568 2531 * No sense putting this after each symbol definition, twice,