aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/sysctl.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/sysctl.c')
-rw-r--r--kernel/sysctl.c136
1 files changed, 58 insertions, 78 deletions
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index fd43c3e6786b..8bfa7d117c54 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -76,8 +76,9 @@ extern int compat_log;
76 76
77#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86) 77#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
78int unknown_nmi_panic; 78int unknown_nmi_panic;
79extern int proc_unknown_nmi_panic(ctl_table *, int, struct file *, 79int nmi_watchdog_enabled;
80 void __user *, size_t *, loff_t *); 80extern int proc_nmi_enabled(struct ctl_table *, int , struct file *,
81 void __user *, size_t *, loff_t *);
81#endif 82#endif
82 83
83/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */ 84/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
@@ -136,8 +137,11 @@ extern int no_unaligned_warning;
136extern int max_lock_depth; 137extern int max_lock_depth;
137#endif 138#endif
138 139
139static int parse_table(int __user *, int, void __user *, size_t __user *, void __user *, size_t, 140#ifdef CONFIG_SYSCTL_SYSCALL
140 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
141static int proc_doutsstring(ctl_table *table, int write, struct file *filp, 145static int proc_doutsstring(ctl_table *table, int write, struct file *filp,
142 void __user *buffer, size_t *lenp, loff_t *ppos); 146 void __user *buffer, size_t *lenp, loff_t *ppos);
143 147
@@ -164,7 +168,7 @@ int sysctl_legacy_va_layout;
164 168
165/* /proc declarations: */ 169/* /proc declarations: */
166 170
167#ifdef CONFIG_PROC_FS 171#ifdef CONFIG_PROC_SYSCTL
168 172
169static 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 *);
170static 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 *);
@@ -628,11 +632,27 @@ static ctl_table kern_table[] = {
628 .data = &unknown_nmi_panic, 632 .data = &unknown_nmi_panic,
629 .maxlen = sizeof (int), 633 .maxlen = sizeof (int),
630 .mode = 0644, 634 .mode = 0644,
631 .proc_handler = &proc_unknown_nmi_panic, 635 .proc_handler = &proc_dointvec,
636 },
637 {
638 .ctl_name = KERN_NMI_WATCHDOG,
639 .procname = "nmi_watchdog",
640 .data = &nmi_watchdog_enabled,
641 .maxlen = sizeof (int),
642 .mode = 0644,
643 .proc_handler = &proc_nmi_enabled,
632 }, 644 },
633#endif 645#endif
634#if defined(CONFIG_X86) 646#if defined(CONFIG_X86)
635 { 647 {
648 .ctl_name = KERN_PANIC_ON_NMI,
649 .procname = "panic_on_unrecovered_nmi",
650 .data = &panic_on_unrecovered_nmi,
651 .maxlen = sizeof(int),
652 .mode = 0644,
653 .proc_handler = &proc_dointvec,
654 },
655 {
636 .ctl_name = KERN_BOOTLOADER_TYPE, 656 .ctl_name = KERN_BOOTLOADER_TYPE,
637 .procname = "bootloader_type", 657 .procname = "bootloader_type",
638 .data = &bootloader_type, 658 .data = &bootloader_type,
@@ -1149,12 +1169,13 @@ static void start_unregistering(struct ctl_table_header *p)
1149 1169
1150void __init sysctl_init(void) 1170void __init sysctl_init(void)
1151{ 1171{
1152#ifdef CONFIG_PROC_FS 1172#ifdef CONFIG_PROC_SYSCTL
1153 register_proc_table(root_table, proc_sys_root, &root_table_header); 1173 register_proc_table(root_table, proc_sys_root, &root_table_header);
1154 init_irq_proc(); 1174 init_irq_proc();
1155#endif 1175#endif
1156} 1176}
1157 1177
1178#ifdef CONFIG_SYSCTL_SYSCALL
1158int 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,
1159 void __user *newval, size_t newlen) 1180 void __user *newval, size_t newlen)
1160{ 1181{
@@ -1208,6 +1229,7 @@ asmlinkage long sys_sysctl(struct __sysctl_args __user *args)
1208 unlock_kernel(); 1229 unlock_kernel();
1209 return error; 1230 return error;
1210} 1231}
1232#endif /* CONFIG_SYSCTL_SYSCALL */
1211 1233
1212/* 1234/*
1213 * ctl_perm does NOT grant the superuser all rights automatically, because 1235 * ctl_perm does NOT grant the superuser all rights automatically, because
@@ -1234,6 +1256,7 @@ static inline int ctl_perm(ctl_table *table, int op)
1234 return test_perm(table->mode, op); 1256 return test_perm(table->mode, op);
1235} 1257}
1236 1258
1259#ifdef CONFIG_SYSCTL_SYSCALL
1237static int parse_table(int __user *name, int nlen, 1260static int parse_table(int __user *name, int nlen,
1238 void __user *oldval, size_t __user *oldlenp, 1261 void __user *oldval, size_t __user *oldlenp,
1239 void __user *newval, size_t newlen, 1262 void __user *newval, size_t newlen,
@@ -1323,6 +1346,7 @@ int do_sysctl_strategy (ctl_table *table,
1323 } 1346 }
1324 return 0; 1347 return 0;
1325} 1348}
1349#endif /* CONFIG_SYSCTL_SYSCALL */
1326 1350
1327/** 1351/**
1328 * register_sysctl_table - register a sysctl hierarchy 1352 * register_sysctl_table - register a sysctl hierarchy
@@ -1410,7 +1434,7 @@ struct ctl_table_header *register_sysctl_table(ctl_table * table,
1410 else 1434 else
1411 list_add_tail(&tmp->ctl_entry, &root_table_header.ctl_entry); 1435 list_add_tail(&tmp->ctl_entry, &root_table_header.ctl_entry);
1412 spin_unlock(&sysctl_lock); 1436 spin_unlock(&sysctl_lock);
1413#ifdef CONFIG_PROC_FS 1437#ifdef CONFIG_PROC_SYSCTL
1414 register_proc_table(table, proc_sys_root, tmp); 1438 register_proc_table(table, proc_sys_root, tmp);
1415#endif 1439#endif
1416 return tmp; 1440 return tmp;
@@ -1428,18 +1452,31 @@ void unregister_sysctl_table(struct ctl_table_header * header)
1428 might_sleep(); 1452 might_sleep();
1429 spin_lock(&sysctl_lock); 1453 spin_lock(&sysctl_lock);
1430 start_unregistering(header); 1454 start_unregistering(header);
1431#ifdef CONFIG_PROC_FS 1455#ifdef CONFIG_PROC_SYSCTL
1432 unregister_proc_table(header->ctl_table, proc_sys_root); 1456 unregister_proc_table(header->ctl_table, proc_sys_root);
1433#endif 1457#endif
1434 spin_unlock(&sysctl_lock); 1458 spin_unlock(&sysctl_lock);
1435 kfree(header); 1459 kfree(header);
1436} 1460}
1437 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
1438/* 1475/*
1439 * /proc/sys support 1476 * /proc/sys support
1440 */ 1477 */
1441 1478
1442#ifdef CONFIG_PROC_FS 1479#ifdef CONFIG_PROC_SYSCTL
1443 1480
1444/* 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 */
1445static 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)
@@ -2301,6 +2338,7 @@ int proc_doulongvec_ms_jiffies_minmax(ctl_table *table, int write,
2301#endif /* CONFIG_PROC_FS */ 2338#endif /* CONFIG_PROC_FS */
2302 2339
2303 2340
2341#ifdef CONFIG_SYSCTL_SYSCALL
2304/* 2342/*
2305 * General sysctl support routines 2343 * General sysctl support routines
2306 */ 2344 */
@@ -2443,11 +2481,19 @@ int sysctl_ms_jiffies(ctl_table *table, int __user *name, int nlen,
2443 return 1; 2481 return 1;
2444} 2482}
2445 2483
2446#else /* CONFIG_SYSCTL */ 2484#else /* CONFIG_SYSCTL_SYSCALL */
2447 2485
2448 2486
2449asmlinkage long sys_sysctl(struct __sysctl_args __user *args) 2487asmlinkage long sys_sysctl(struct __sysctl_args __user *args)
2450{ 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 }
2451 return -ENOSYS; 2497 return -ENOSYS;
2452} 2498}
2453 2499
@@ -2479,73 +2525,7 @@ int sysctl_ms_jiffies(ctl_table *table, int __user *name, int nlen,
2479 return -ENOSYS; 2525 return -ENOSYS;
2480} 2526}
2481 2527
2482int proc_dostring(ctl_table *table, int write, struct file *filp, 2528#endif /* CONFIG_SYSCTL_SYSCALL */
2483 void __user *buffer, size_t *lenp, loff_t *ppos)
2484{
2485 return -ENOSYS;
2486}
2487
2488int proc_dointvec(ctl_table *table, int write, struct file *filp,
2489 void __user *buffer, size_t *lenp, loff_t *ppos)
2490{
2491 return -ENOSYS;
2492}
2493
2494int proc_dointvec_bset(ctl_table *table, int write, struct file *filp,
2495 void __user *buffer, size_t *lenp, loff_t *ppos)
2496{
2497 return -ENOSYS;
2498}
2499
2500int proc_dointvec_minmax(ctl_table *table, int write, struct file *filp,
2501 void __user *buffer, size_t *lenp, loff_t *ppos)
2502{
2503 return -ENOSYS;
2504}
2505
2506int proc_dointvec_jiffies(ctl_table *table, int write, struct file *filp,
2507 void __user *buffer, size_t *lenp, loff_t *ppos)
2508{
2509 return -ENOSYS;
2510}
2511
2512int proc_dointvec_userhz_jiffies(ctl_table *table, int write, struct file *filp,
2513 void __user *buffer, size_t *lenp, loff_t *ppos)
2514{
2515 return -ENOSYS;
2516}
2517
2518int proc_dointvec_ms_jiffies(ctl_table *table, int write, struct file *filp,
2519 void __user *buffer, size_t *lenp, loff_t *ppos)
2520{
2521 return -ENOSYS;
2522}
2523
2524int proc_doulongvec_minmax(ctl_table *table, int write, struct file *filp,
2525 void __user *buffer, size_t *lenp, loff_t *ppos)
2526{
2527 return -ENOSYS;
2528}
2529
2530int proc_doulongvec_ms_jiffies_minmax(ctl_table *table, int write,
2531 struct file *filp,
2532 void __user *buffer,
2533 size_t *lenp, loff_t *ppos)
2534{
2535 return -ENOSYS;
2536}
2537
2538struct ctl_table_header * register_sysctl_table(ctl_table * table,
2539 int insert_at_head)
2540{
2541 return NULL;
2542}
2543
2544void unregister_sysctl_table(struct ctl_table_header * table)
2545{
2546}
2547
2548#endif /* CONFIG_SYSCTL */
2549 2529
2550/* 2530/*
2551 * No sense putting this after each symbol definition, twice, 2531 * No sense putting this after each symbol definition, twice,