aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/sysctl.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/sysctl.c')
-rw-r--r--kernel/sysctl.c154
1 files changed, 71 insertions, 83 deletions
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 362a0cc37138..c57c4532e296 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -52,6 +52,10 @@
52extern int proc_nr_files(ctl_table *table, int write, struct file *filp, 52extern int proc_nr_files(ctl_table *table, int write, struct file *filp,
53 void __user *buffer, size_t *lenp, loff_t *ppos); 53 void __user *buffer, size_t *lenp, loff_t *ppos);
54 54
55#ifdef CONFIG_X86
56#include <asm/nmi.h>
57#endif
58
55#if defined(CONFIG_SYSCTL) 59#if defined(CONFIG_SYSCTL)
56 60
57/* External variables not in a header file. */ 61/* External variables not in a header file. */
@@ -74,12 +78,6 @@ extern int sysctl_drop_caches;
74extern int percpu_pagelist_fraction; 78extern int percpu_pagelist_fraction;
75extern int compat_log; 79extern int compat_log;
76 80
77#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
78int unknown_nmi_panic;
79extern int proc_unknown_nmi_panic(ctl_table *, int, struct file *,
80 void __user *, size_t *, loff_t *);
81#endif
82
83/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */ 81/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
84static int maxolduid = 65535; 82static int maxolduid = 65535;
85static int minolduid; 83static int minolduid;
@@ -136,8 +134,11 @@ extern int no_unaligned_warning;
136extern int max_lock_depth; 134extern int max_lock_depth;
137#endif 135#endif
138 136
139static int parse_table(int __user *, int, void __user *, size_t __user *, void __user *, size_t, 137#ifdef CONFIG_SYSCTL_SYSCALL
140 ctl_table *, void **); 138static int parse_table(int __user *, int, void __user *, size_t __user *,
139 void __user *, size_t, ctl_table *, void **);
140#endif
141
141static int proc_doutsstring(ctl_table *table, int write, struct file *filp, 142static int proc_doutsstring(ctl_table *table, int write, struct file *filp,
142 void __user *buffer, size_t *lenp, loff_t *ppos); 143 void __user *buffer, size_t *lenp, loff_t *ppos);
143 144
@@ -164,7 +165,7 @@ int sysctl_legacy_va_layout;
164 165
165/* /proc declarations: */ 166/* /proc declarations: */
166 167
167#ifdef CONFIG_PROC_FS 168#ifdef CONFIG_PROC_SYSCTL
168 169
169static ssize_t proc_readsys(struct file *, char __user *, size_t, loff_t *); 170static ssize_t proc_readsys(struct file *, char __user *, size_t, loff_t *);
170static ssize_t proc_writesys(struct file *, const char __user *, size_t, loff_t *); 171static ssize_t proc_writesys(struct file *, const char __user *, size_t, loff_t *);
@@ -628,11 +629,27 @@ static ctl_table kern_table[] = {
628 .data = &unknown_nmi_panic, 629 .data = &unknown_nmi_panic,
629 .maxlen = sizeof (int), 630 .maxlen = sizeof (int),
630 .mode = 0644, 631 .mode = 0644,
631 .proc_handler = &proc_unknown_nmi_panic, 632 .proc_handler = &proc_dointvec,
633 },
634 {
635 .ctl_name = KERN_NMI_WATCHDOG,
636 .procname = "nmi_watchdog",
637 .data = &nmi_watchdog_enabled,
638 .maxlen = sizeof (int),
639 .mode = 0644,
640 .proc_handler = &proc_nmi_enabled,
632 }, 641 },
633#endif 642#endif
634#if defined(CONFIG_X86) 643#if defined(CONFIG_X86)
635 { 644 {
645 .ctl_name = KERN_PANIC_ON_NMI,
646 .procname = "panic_on_unrecovered_nmi",
647 .data = &panic_on_unrecovered_nmi,
648 .maxlen = sizeof(int),
649 .mode = 0644,
650 .proc_handler = &proc_dointvec,
651 },
652 {
636 .ctl_name = KERN_BOOTLOADER_TYPE, 653 .ctl_name = KERN_BOOTLOADER_TYPE,
637 .procname = "bootloader_type", 654 .procname = "bootloader_type",
638 .data = &bootloader_type, 655 .data = &bootloader_type,
@@ -943,6 +960,17 @@ static ctl_table vm_table[] = {
943 .extra1 = &zero, 960 .extra1 = &zero,
944 .extra2 = &one_hundred, 961 .extra2 = &one_hundred,
945 }, 962 },
963 {
964 .ctl_name = VM_MIN_SLAB,
965 .procname = "min_slab_ratio",
966 .data = &sysctl_min_slab_ratio,
967 .maxlen = sizeof(sysctl_min_slab_ratio),
968 .mode = 0644,
969 .proc_handler = &sysctl_min_slab_ratio_sysctl_handler,
970 .strategy = &sysctl_intvec,
971 .extra1 = &zero,
972 .extra2 = &one_hundred,
973 },
946#endif 974#endif
947#ifdef CONFIG_X86_32 975#ifdef CONFIG_X86_32
948 { 976 {
@@ -1138,12 +1166,13 @@ static void start_unregistering(struct ctl_table_header *p)
1138 1166
1139void __init sysctl_init(void) 1167void __init sysctl_init(void)
1140{ 1168{
1141#ifdef CONFIG_PROC_FS 1169#ifdef CONFIG_PROC_SYSCTL
1142 register_proc_table(root_table, proc_sys_root, &root_table_header); 1170 register_proc_table(root_table, proc_sys_root, &root_table_header);
1143 init_irq_proc(); 1171 init_irq_proc();
1144#endif 1172#endif
1145} 1173}
1146 1174
1175#ifdef CONFIG_SYSCTL_SYSCALL
1147int do_sysctl(int __user *name, int nlen, void __user *oldval, size_t __user *oldlenp, 1176int do_sysctl(int __user *name, int nlen, void __user *oldval, size_t __user *oldlenp,
1148 void __user *newval, size_t newlen) 1177 void __user *newval, size_t newlen)
1149{ 1178{
@@ -1197,6 +1226,7 @@ asmlinkage long sys_sysctl(struct __sysctl_args __user *args)
1197 unlock_kernel(); 1226 unlock_kernel();
1198 return error; 1227 return error;
1199} 1228}
1229#endif /* CONFIG_SYSCTL_SYSCALL */
1200 1230
1201/* 1231/*
1202 * ctl_perm does NOT grant the superuser all rights automatically, because 1232 * ctl_perm does NOT grant the superuser all rights automatically, because
@@ -1223,6 +1253,7 @@ static inline int ctl_perm(ctl_table *table, int op)
1223 return test_perm(table->mode, op); 1253 return test_perm(table->mode, op);
1224} 1254}
1225 1255
1256#ifdef CONFIG_SYSCTL_SYSCALL
1226static int parse_table(int __user *name, int nlen, 1257static int parse_table(int __user *name, int nlen,
1227 void __user *oldval, size_t __user *oldlenp, 1258 void __user *oldval, size_t __user *oldlenp,
1228 void __user *newval, size_t newlen, 1259 void __user *newval, size_t newlen,
@@ -1312,6 +1343,7 @@ int do_sysctl_strategy (ctl_table *table,
1312 } 1343 }
1313 return 0; 1344 return 0;
1314} 1345}
1346#endif /* CONFIG_SYSCTL_SYSCALL */
1315 1347
1316/** 1348/**
1317 * register_sysctl_table - register a sysctl hierarchy 1349 * register_sysctl_table - register a sysctl hierarchy
@@ -1399,7 +1431,7 @@ struct ctl_table_header *register_sysctl_table(ctl_table * table,
1399 else 1431 else
1400 list_add_tail(&tmp->ctl_entry, &root_table_header.ctl_entry); 1432 list_add_tail(&tmp->ctl_entry, &root_table_header.ctl_entry);
1401 spin_unlock(&sysctl_lock); 1433 spin_unlock(&sysctl_lock);
1402#ifdef CONFIG_PROC_FS 1434#ifdef CONFIG_PROC_SYSCTL
1403 register_proc_table(table, proc_sys_root, tmp); 1435 register_proc_table(table, proc_sys_root, tmp);
1404#endif 1436#endif
1405 return tmp; 1437 return tmp;
@@ -1417,18 +1449,31 @@ void unregister_sysctl_table(struct ctl_table_header * header)
1417 might_sleep(); 1449 might_sleep();
1418 spin_lock(&sysctl_lock); 1450 spin_lock(&sysctl_lock);
1419 start_unregistering(header); 1451 start_unregistering(header);
1420#ifdef CONFIG_PROC_FS 1452#ifdef CONFIG_PROC_SYSCTL
1421 unregister_proc_table(header->ctl_table, proc_sys_root); 1453 unregister_proc_table(header->ctl_table, proc_sys_root);
1422#endif 1454#endif
1423 spin_unlock(&sysctl_lock); 1455 spin_unlock(&sysctl_lock);
1424 kfree(header); 1456 kfree(header);
1425} 1457}
1426 1458
1459#else /* !CONFIG_SYSCTL */
1460struct ctl_table_header * register_sysctl_table(ctl_table * table,
1461 int insert_at_head)
1462{
1463 return NULL;
1464}
1465
1466void unregister_sysctl_table(struct ctl_table_header * table)
1467{
1468}
1469
1470#endif /* CONFIG_SYSCTL */
1471
1427/* 1472/*
1428 * /proc/sys support 1473 * /proc/sys support
1429 */ 1474 */
1430 1475
1431#ifdef CONFIG_PROC_FS 1476#ifdef CONFIG_PROC_SYSCTL
1432 1477
1433/* Scan the sysctl entries in table and add them all into /proc */ 1478/* Scan the sysctl entries in table and add them all into /proc */
1434static void register_proc_table(ctl_table * table, struct proc_dir_entry *root, void *set) 1479static void register_proc_table(ctl_table * table, struct proc_dir_entry *root, void *set)
@@ -1867,7 +1912,7 @@ int proc_dointvec_bset(ctl_table *table, int write, struct file *filp,
1867 return -EPERM; 1912 return -EPERM;
1868 } 1913 }
1869 1914
1870 op = (current->pid == 1) ? OP_SET : OP_AND; 1915 op = is_init(current) ? OP_SET : OP_AND;
1871 return do_proc_dointvec(table,write,filp,buffer,lenp,ppos, 1916 return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
1872 do_proc_dointvec_bset_conv,&op); 1917 do_proc_dointvec_bset_conv,&op);
1873} 1918}
@@ -2290,6 +2335,7 @@ int proc_doulongvec_ms_jiffies_minmax(ctl_table *table, int write,
2290#endif /* CONFIG_PROC_FS */ 2335#endif /* CONFIG_PROC_FS */
2291 2336
2292 2337
2338#ifdef CONFIG_SYSCTL_SYSCALL
2293/* 2339/*
2294 * General sysctl support routines 2340 * General sysctl support routines
2295 */ 2341 */
@@ -2432,11 +2478,19 @@ int sysctl_ms_jiffies(ctl_table *table, int __user *name, int nlen,
2432 return 1; 2478 return 1;
2433} 2479}
2434 2480
2435#else /* CONFIG_SYSCTL */ 2481#else /* CONFIG_SYSCTL_SYSCALL */
2436 2482
2437 2483
2438asmlinkage long sys_sysctl(struct __sysctl_args __user *args) 2484asmlinkage long sys_sysctl(struct __sysctl_args __user *args)
2439{ 2485{
2486 static int msg_count;
2487
2488 if (msg_count < 5) {
2489 msg_count++;
2490 printk(KERN_INFO
2491 "warning: process `%s' used the removed sysctl "
2492 "system call\n", current->comm);
2493 }
2440 return -ENOSYS; 2494 return -ENOSYS;
2441} 2495}
2442 2496
@@ -2468,73 +2522,7 @@ int sysctl_ms_jiffies(ctl_table *table, int __user *name, int nlen,
2468 return -ENOSYS; 2522 return -ENOSYS;
2469} 2523}
2470 2524
2471int proc_dostring(ctl_table *table, int write, struct file *filp, 2525#endif /* CONFIG_SYSCTL_SYSCALL */
2472 void __user *buffer, size_t *lenp, loff_t *ppos)
2473{
2474 return -ENOSYS;
2475}
2476
2477int proc_dointvec(ctl_table *table, int write, struct file *filp,
2478 void __user *buffer, size_t *lenp, loff_t *ppos)
2479{
2480 return -ENOSYS;
2481}
2482
2483int proc_dointvec_bset(ctl_table *table, int write, struct file *filp,
2484 void __user *buffer, size_t *lenp, loff_t *ppos)
2485{
2486 return -ENOSYS;
2487}
2488
2489int proc_dointvec_minmax(ctl_table *table, int write, struct file *filp,
2490 void __user *buffer, size_t *lenp, loff_t *ppos)
2491{
2492 return -ENOSYS;
2493}
2494
2495int proc_dointvec_jiffies(ctl_table *table, int write, struct file *filp,
2496 void __user *buffer, size_t *lenp, loff_t *ppos)
2497{
2498 return -ENOSYS;
2499}
2500
2501int proc_dointvec_userhz_jiffies(ctl_table *table, int write, struct file *filp,
2502 void __user *buffer, size_t *lenp, loff_t *ppos)
2503{
2504 return -ENOSYS;
2505}
2506
2507int proc_dointvec_ms_jiffies(ctl_table *table, int write, struct file *filp,
2508 void __user *buffer, size_t *lenp, loff_t *ppos)
2509{
2510 return -ENOSYS;
2511}
2512
2513int proc_doulongvec_minmax(ctl_table *table, int write, struct file *filp,
2514 void __user *buffer, size_t *lenp, loff_t *ppos)
2515{
2516 return -ENOSYS;
2517}
2518
2519int proc_doulongvec_ms_jiffies_minmax(ctl_table *table, int write,
2520 struct file *filp,
2521 void __user *buffer,
2522 size_t *lenp, loff_t *ppos)
2523{
2524 return -ENOSYS;
2525}
2526
2527struct ctl_table_header * register_sysctl_table(ctl_table * table,
2528 int insert_at_head)
2529{
2530 return NULL;
2531}
2532
2533void unregister_sysctl_table(struct ctl_table_header * table)
2534{
2535}
2536
2537#endif /* CONFIG_SYSCTL */
2538 2526
2539/* 2527/*
2540 * No sense putting this after each symbol definition, twice, 2528 * No sense putting this after each symbol definition, twice,