diff options
Diffstat (limited to 'kernel/sysctl.c')
| -rw-r--r-- | kernel/sysctl.c | 147 |
1 files changed, 69 insertions, 78 deletions
diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 362a0cc37138..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) |
| 78 | int unknown_nmi_panic; | 78 | int unknown_nmi_panic; |
| 79 | extern int proc_unknown_nmi_panic(ctl_table *, int, struct file *, | 79 | int nmi_watchdog_enabled; |
| 80 | void __user *, size_t *, loff_t *); | 80 | extern 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; | |||
| 136 | extern int max_lock_depth; | 137 | extern int max_lock_depth; |
| 137 | #endif | 138 | #endif |
| 138 | 139 | ||
| 139 | static int parse_table(int __user *, int, void __user *, size_t __user *, void __user *, size_t, | 140 | #ifdef CONFIG_SYSCTL_SYSCALL |
| 140 | ctl_table *, void **); | 141 | static int parse_table(int __user *, int, void __user *, size_t __user *, |
| 142 | void __user *, size_t, ctl_table *, void **); | ||
| 143 | #endif | ||
| 144 | |||
| 141 | static int proc_doutsstring(ctl_table *table, int write, struct file *filp, | 145 | static 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 | ||
| 169 | static ssize_t proc_readsys(struct file *, char __user *, size_t, loff_t *); | 173 | static ssize_t proc_readsys(struct file *, char __user *, size_t, loff_t *); |
| 170 | static ssize_t proc_writesys(struct file *, const char __user *, size_t, loff_t *); | 174 | static 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, |
| @@ -943,6 +963,17 @@ static ctl_table vm_table[] = { | |||
| 943 | .extra1 = &zero, | 963 | .extra1 = &zero, |
| 944 | .extra2 = &one_hundred, | 964 | .extra2 = &one_hundred, |
| 945 | }, | 965 | }, |
| 966 | { | ||
| 967 | .ctl_name = VM_MIN_SLAB, | ||
| 968 | .procname = "min_slab_ratio", | ||
| 969 | .data = &sysctl_min_slab_ratio, | ||
| 970 | .maxlen = sizeof(sysctl_min_slab_ratio), | ||
| 971 | .mode = 0644, | ||
| 972 | .proc_handler = &sysctl_min_slab_ratio_sysctl_handler, | ||
| 973 | .strategy = &sysctl_intvec, | ||
| 974 | .extra1 = &zero, | ||
| 975 | .extra2 = &one_hundred, | ||
| 976 | }, | ||
| 946 | #endif | 977 | #endif |
| 947 | #ifdef CONFIG_X86_32 | 978 | #ifdef CONFIG_X86_32 |
| 948 | { | 979 | { |
| @@ -1138,12 +1169,13 @@ static void start_unregistering(struct ctl_table_header *p) | |||
| 1138 | 1169 | ||
| 1139 | void __init sysctl_init(void) | 1170 | void __init sysctl_init(void) |
| 1140 | { | 1171 | { |
| 1141 | #ifdef CONFIG_PROC_FS | 1172 | #ifdef CONFIG_PROC_SYSCTL |
| 1142 | register_proc_table(root_table, proc_sys_root, &root_table_header); | 1173 | register_proc_table(root_table, proc_sys_root, &root_table_header); |
| 1143 | init_irq_proc(); | 1174 | init_irq_proc(); |
| 1144 | #endif | 1175 | #endif |
| 1145 | } | 1176 | } |
| 1146 | 1177 | ||
| 1178 | #ifdef CONFIG_SYSCTL_SYSCALL | ||
| 1147 | int do_sysctl(int __user *name, int nlen, void __user *oldval, size_t __user *oldlenp, | 1179 | int do_sysctl(int __user *name, int nlen, void __user *oldval, size_t __user *oldlenp, |
| 1148 | void __user *newval, size_t newlen) | 1180 | void __user *newval, size_t newlen) |
| 1149 | { | 1181 | { |
| @@ -1197,6 +1229,7 @@ asmlinkage long sys_sysctl(struct __sysctl_args __user *args) | |||
| 1197 | unlock_kernel(); | 1229 | unlock_kernel(); |
| 1198 | return error; | 1230 | return error; |
| 1199 | } | 1231 | } |
| 1232 | #endif /* CONFIG_SYSCTL_SYSCALL */ | ||
| 1200 | 1233 | ||
| 1201 | /* | 1234 | /* |
| 1202 | * ctl_perm does NOT grant the superuser all rights automatically, because | 1235 | * ctl_perm does NOT grant the superuser all rights automatically, because |
| @@ -1223,6 +1256,7 @@ static inline int ctl_perm(ctl_table *table, int op) | |||
| 1223 | return test_perm(table->mode, op); | 1256 | return test_perm(table->mode, op); |
| 1224 | } | 1257 | } |
| 1225 | 1258 | ||
| 1259 | #ifdef CONFIG_SYSCTL_SYSCALL | ||
| 1226 | static int parse_table(int __user *name, int nlen, | 1260 | static int parse_table(int __user *name, int nlen, |
| 1227 | void __user *oldval, size_t __user *oldlenp, | 1261 | void __user *oldval, size_t __user *oldlenp, |
| 1228 | void __user *newval, size_t newlen, | 1262 | void __user *newval, size_t newlen, |
| @@ -1312,6 +1346,7 @@ int do_sysctl_strategy (ctl_table *table, | |||
| 1312 | } | 1346 | } |
| 1313 | return 0; | 1347 | return 0; |
| 1314 | } | 1348 | } |
| 1349 | #endif /* CONFIG_SYSCTL_SYSCALL */ | ||
| 1315 | 1350 | ||
| 1316 | /** | 1351 | /** |
| 1317 | * register_sysctl_table - register a sysctl hierarchy | 1352 | * register_sysctl_table - register a sysctl hierarchy |
| @@ -1399,7 +1434,7 @@ struct ctl_table_header *register_sysctl_table(ctl_table * table, | |||
| 1399 | else | 1434 | else |
| 1400 | list_add_tail(&tmp->ctl_entry, &root_table_header.ctl_entry); | 1435 | list_add_tail(&tmp->ctl_entry, &root_table_header.ctl_entry); |
| 1401 | spin_unlock(&sysctl_lock); | 1436 | spin_unlock(&sysctl_lock); |
| 1402 | #ifdef CONFIG_PROC_FS | 1437 | #ifdef CONFIG_PROC_SYSCTL |
| 1403 | register_proc_table(table, proc_sys_root, tmp); | 1438 | register_proc_table(table, proc_sys_root, tmp); |
| 1404 | #endif | 1439 | #endif |
| 1405 | return tmp; | 1440 | return tmp; |
| @@ -1417,18 +1452,31 @@ void unregister_sysctl_table(struct ctl_table_header * header) | |||
| 1417 | might_sleep(); | 1452 | might_sleep(); |
| 1418 | spin_lock(&sysctl_lock); | 1453 | spin_lock(&sysctl_lock); |
| 1419 | start_unregistering(header); | 1454 | start_unregistering(header); |
| 1420 | #ifdef CONFIG_PROC_FS | 1455 | #ifdef CONFIG_PROC_SYSCTL |
| 1421 | unregister_proc_table(header->ctl_table, proc_sys_root); | 1456 | unregister_proc_table(header->ctl_table, proc_sys_root); |
| 1422 | #endif | 1457 | #endif |
| 1423 | spin_unlock(&sysctl_lock); | 1458 | spin_unlock(&sysctl_lock); |
| 1424 | kfree(header); | 1459 | kfree(header); |
| 1425 | } | 1460 | } |
| 1426 | 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 | |||
| 1427 | /* | 1475 | /* |
| 1428 | * /proc/sys support | 1476 | * /proc/sys support |
| 1429 | */ | 1477 | */ |
| 1430 | 1478 | ||
| 1431 | #ifdef CONFIG_PROC_FS | 1479 | #ifdef CONFIG_PROC_SYSCTL |
| 1432 | 1480 | ||
| 1433 | /* 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 */ |
| 1434 | static void register_proc_table(ctl_table * table, struct proc_dir_entry *root, void *set) | 1482 | static void register_proc_table(ctl_table * table, struct proc_dir_entry *root, void *set) |
| @@ -2290,6 +2338,7 @@ int proc_doulongvec_ms_jiffies_minmax(ctl_table *table, int write, | |||
| 2290 | #endif /* CONFIG_PROC_FS */ | 2338 | #endif /* CONFIG_PROC_FS */ |
| 2291 | 2339 | ||
| 2292 | 2340 | ||
| 2341 | #ifdef CONFIG_SYSCTL_SYSCALL | ||
| 2293 | /* | 2342 | /* |
| 2294 | * General sysctl support routines | 2343 | * General sysctl support routines |
| 2295 | */ | 2344 | */ |
| @@ -2432,11 +2481,19 @@ int sysctl_ms_jiffies(ctl_table *table, int __user *name, int nlen, | |||
| 2432 | return 1; | 2481 | return 1; |
| 2433 | } | 2482 | } |
| 2434 | 2483 | ||
| 2435 | #else /* CONFIG_SYSCTL */ | 2484 | #else /* CONFIG_SYSCTL_SYSCALL */ |
| 2436 | 2485 | ||
| 2437 | 2486 | ||
| 2438 | asmlinkage long sys_sysctl(struct __sysctl_args __user *args) | 2487 | asmlinkage long sys_sysctl(struct __sysctl_args __user *args) |
| 2439 | { | 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 | } | ||
| 2440 | return -ENOSYS; | 2497 | return -ENOSYS; |
| 2441 | } | 2498 | } |
| 2442 | 2499 | ||
| @@ -2468,73 +2525,7 @@ int sysctl_ms_jiffies(ctl_table *table, int __user *name, int nlen, | |||
| 2468 | return -ENOSYS; | 2525 | return -ENOSYS; |
| 2469 | } | 2526 | } |
| 2470 | 2527 | ||
| 2471 | int proc_dostring(ctl_table *table, int write, struct file *filp, | 2528 | #endif /* CONFIG_SYSCTL_SYSCALL */ |
| 2472 | void __user *buffer, size_t *lenp, loff_t *ppos) | ||
| 2473 | { | ||
| 2474 | return -ENOSYS; | ||
| 2475 | } | ||
| 2476 | |||
| 2477 | int 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 | |||
| 2483 | int 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 | |||
| 2489 | int 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 | |||
| 2495 | int 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 | |||
| 2501 | int 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 | |||
| 2507 | int 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 | |||
| 2513 | int 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 | |||
| 2519 | int 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 | |||
| 2527 | struct ctl_table_header * register_sysctl_table(ctl_table * table, | ||
| 2528 | int insert_at_head) | ||
| 2529 | { | ||
| 2530 | return NULL; | ||
| 2531 | } | ||
| 2532 | |||
| 2533 | void unregister_sysctl_table(struct ctl_table_header * table) | ||
| 2534 | { | ||
| 2535 | } | ||
| 2536 | |||
| 2537 | #endif /* CONFIG_SYSCTL */ | ||
| 2538 | 2529 | ||
| 2539 | /* | 2530 | /* |
| 2540 | * No sense putting this after each symbol definition, twice, | 2531 | * No sense putting this after each symbol definition, twice, |
