aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/sysctl.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/sysctl.c')
-rw-r--r--kernel/sysctl.c218
1 files changed, 117 insertions, 101 deletions
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index eb8bd214e7d7..c57c4532e296 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -18,7 +18,6 @@
18 * Removed it and replaced it with older style, 03/23/00, Bill Wendling 18 * Removed it and replaced it with older style, 03/23/00, Bill Wendling
19 */ 19 */
20 20
21#include <linux/config.h>
22#include <linux/module.h> 21#include <linux/module.h>
23#include <linux/mm.h> 22#include <linux/mm.h>
24#include <linux/swap.h> 23#include <linux/swap.h>
@@ -53,6 +52,10 @@
53extern 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,
54 void __user *buffer, size_t *lenp, loff_t *ppos); 53 void __user *buffer, size_t *lenp, loff_t *ppos);
55 54
55#ifdef CONFIG_X86
56#include <asm/nmi.h>
57#endif
58
56#if defined(CONFIG_SYSCTL) 59#if defined(CONFIG_SYSCTL)
57 60
58/* External variables not in a header file. */ 61/* External variables not in a header file. */
@@ -73,12 +76,7 @@ extern int printk_ratelimit_burst;
73extern int pid_max_min, pid_max_max; 76extern int pid_max_min, pid_max_max;
74extern int sysctl_drop_caches; 77extern int sysctl_drop_caches;
75extern int percpu_pagelist_fraction; 78extern int percpu_pagelist_fraction;
76 79extern int compat_log;
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 80
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;
@@ -132,8 +130,15 @@ extern int acct_parm[];
132extern int no_unaligned_warning; 130extern int no_unaligned_warning;
133#endif 131#endif
134 132
135static int parse_table(int __user *, int, void __user *, size_t __user *, void __user *, size_t, 133#ifdef CONFIG_RT_MUTEXES
136 ctl_table *, void **); 134extern int max_lock_depth;
135#endif
136
137#ifdef CONFIG_SYSCTL_SYSCALL
138static int parse_table(int __user *, int, void __user *, size_t __user *,
139 void __user *, size_t, ctl_table *, void **);
140#endif
141
137static int proc_doutsstring(ctl_table *table, int write, struct file *filp, 142static int proc_doutsstring(ctl_table *table, int write, struct file *filp,
138 void __user *buffer, size_t *lenp, loff_t *ppos); 143 void __user *buffer, size_t *lenp, loff_t *ppos);
139 144
@@ -143,7 +148,6 @@ static struct ctl_table_header root_table_header =
143 148
144static ctl_table kern_table[]; 149static ctl_table kern_table[];
145static ctl_table vm_table[]; 150static ctl_table vm_table[];
146static ctl_table proc_table[];
147static ctl_table fs_table[]; 151static ctl_table fs_table[];
148static ctl_table debug_table[]; 152static ctl_table debug_table[];
149static ctl_table dev_table[]; 153static ctl_table dev_table[];
@@ -161,7 +165,7 @@ int sysctl_legacy_va_layout;
161 165
162/* /proc declarations: */ 166/* /proc declarations: */
163 167
164#ifdef CONFIG_PROC_FS 168#ifdef CONFIG_PROC_SYSCTL
165 169
166static 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 *);
167static 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 *);
@@ -203,12 +207,6 @@ static ctl_table root_table[] = {
203 }, 207 },
204#endif 208#endif
205 { 209 {
206 .ctl_name = CTL_PROC,
207 .procname = "proc",
208 .mode = 0555,
209 .child = proc_table,
210 },
211 {
212 .ctl_name = CTL_FS, 210 .ctl_name = CTL_FS,
213 .procname = "fs", 211 .procname = "fs",
214 .mode = 0555, 212 .mode = 0555,
@@ -631,11 +629,27 @@ static ctl_table kern_table[] = {
631 .data = &unknown_nmi_panic, 629 .data = &unknown_nmi_panic,
632 .maxlen = sizeof (int), 630 .maxlen = sizeof (int),
633 .mode = 0644, 631 .mode = 0644,
634 .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,
635 }, 641 },
636#endif 642#endif
637#if defined(CONFIG_X86) 643#if defined(CONFIG_X86)
638 { 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 {
639 .ctl_name = KERN_BOOTLOADER_TYPE, 653 .ctl_name = KERN_BOOTLOADER_TYPE,
640 .procname = "bootloader_type", 654 .procname = "bootloader_type",
641 .data = &bootloader_type, 655 .data = &bootloader_type,
@@ -684,6 +698,27 @@ static ctl_table kern_table[] = {
684 .proc_handler = &proc_dointvec, 698 .proc_handler = &proc_dointvec,
685 }, 699 },
686#endif 700#endif
701#ifdef CONFIG_COMPAT
702 {
703 .ctl_name = KERN_COMPAT_LOG,
704 .procname = "compat-log",
705 .data = &compat_log,
706 .maxlen = sizeof (int),
707 .mode = 0644,
708 .proc_handler = &proc_dointvec,
709 },
710#endif
711#ifdef CONFIG_RT_MUTEXES
712 {
713 .ctl_name = KERN_MAX_LOCK_DEPTH,
714 .procname = "max_lock_depth",
715 .data = &max_lock_depth,
716 .maxlen = sizeof(int),
717 .mode = 0644,
718 .proc_handler = &proc_dointvec,
719 },
720#endif
721
687 { .ctl_name = 0 } 722 { .ctl_name = 0 }
688}; 723};
689 724
@@ -915,19 +950,40 @@ static ctl_table vm_table[] = {
915 .extra1 = &zero, 950 .extra1 = &zero,
916 }, 951 },
917 { 952 {
918 .ctl_name = VM_ZONE_RECLAIM_INTERVAL, 953 .ctl_name = VM_MIN_UNMAPPED,
919 .procname = "zone_reclaim_interval", 954 .procname = "min_unmapped_ratio",
920 .data = &zone_reclaim_interval, 955 .data = &sysctl_min_unmapped_ratio,
921 .maxlen = sizeof(zone_reclaim_interval), 956 .maxlen = sizeof(sysctl_min_unmapped_ratio),
922 .mode = 0644, 957 .mode = 0644,
923 .proc_handler = &proc_dointvec_jiffies, 958 .proc_handler = &sysctl_min_unmapped_ratio_sysctl_handler,
924 .strategy = &sysctl_jiffies, 959 .strategy = &sysctl_intvec,
960 .extra1 = &zero,
961 .extra2 = &one_hundred,
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 },
974#endif
975#ifdef CONFIG_X86_32
976 {
977 .ctl_name = VM_VDSO_ENABLED,
978 .procname = "vdso_enabled",
979 .data = &vdso_enabled,
980 .maxlen = sizeof(vdso_enabled),
981 .mode = 0644,
982 .proc_handler = &proc_dointvec,
983 .strategy = &sysctl_intvec,
984 .extra1 = &zero,
925 }, 985 },
926#endif 986#endif
927 { .ctl_name = 0 }
928};
929
930static ctl_table proc_table[] = {
931 { .ctl_name = 0 } 987 { .ctl_name = 0 }
932}; 988};
933 989
@@ -1110,12 +1166,13 @@ static void start_unregistering(struct ctl_table_header *p)
1110 1166
1111void __init sysctl_init(void) 1167void __init sysctl_init(void)
1112{ 1168{
1113#ifdef CONFIG_PROC_FS 1169#ifdef CONFIG_PROC_SYSCTL
1114 register_proc_table(root_table, proc_sys_root, &root_table_header); 1170 register_proc_table(root_table, proc_sys_root, &root_table_header);
1115 init_irq_proc(); 1171 init_irq_proc();
1116#endif 1172#endif
1117} 1173}
1118 1174
1175#ifdef CONFIG_SYSCTL_SYSCALL
1119int 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,
1120 void __user *newval, size_t newlen) 1177 void __user *newval, size_t newlen)
1121{ 1178{
@@ -1169,6 +1226,7 @@ asmlinkage long sys_sysctl(struct __sysctl_args __user *args)
1169 unlock_kernel(); 1226 unlock_kernel();
1170 return error; 1227 return error;
1171} 1228}
1229#endif /* CONFIG_SYSCTL_SYSCALL */
1172 1230
1173/* 1231/*
1174 * ctl_perm does NOT grant the superuser all rights automatically, because 1232 * ctl_perm does NOT grant the superuser all rights automatically, because
@@ -1195,6 +1253,7 @@ static inline int ctl_perm(ctl_table *table, int op)
1195 return test_perm(table->mode, op); 1253 return test_perm(table->mode, op);
1196} 1254}
1197 1255
1256#ifdef CONFIG_SYSCTL_SYSCALL
1198static int parse_table(int __user *name, int nlen, 1257static int parse_table(int __user *name, int nlen,
1199 void __user *oldval, size_t __user *oldlenp, 1258 void __user *oldval, size_t __user *oldlenp,
1200 void __user *newval, size_t newlen, 1259 void __user *newval, size_t newlen,
@@ -1284,6 +1343,7 @@ int do_sysctl_strategy (ctl_table *table,
1284 } 1343 }
1285 return 0; 1344 return 0;
1286} 1345}
1346#endif /* CONFIG_SYSCTL_SYSCALL */
1287 1347
1288/** 1348/**
1289 * register_sysctl_table - register a sysctl hierarchy 1349 * register_sysctl_table - register a sysctl hierarchy
@@ -1371,7 +1431,7 @@ struct ctl_table_header *register_sysctl_table(ctl_table * table,
1371 else 1431 else
1372 list_add_tail(&tmp->ctl_entry, &root_table_header.ctl_entry); 1432 list_add_tail(&tmp->ctl_entry, &root_table_header.ctl_entry);
1373 spin_unlock(&sysctl_lock); 1433 spin_unlock(&sysctl_lock);
1374#ifdef CONFIG_PROC_FS 1434#ifdef CONFIG_PROC_SYSCTL
1375 register_proc_table(table, proc_sys_root, tmp); 1435 register_proc_table(table, proc_sys_root, tmp);
1376#endif 1436#endif
1377 return tmp; 1437 return tmp;
@@ -1389,18 +1449,31 @@ void unregister_sysctl_table(struct ctl_table_header * header)
1389 might_sleep(); 1449 might_sleep();
1390 spin_lock(&sysctl_lock); 1450 spin_lock(&sysctl_lock);
1391 start_unregistering(header); 1451 start_unregistering(header);
1392#ifdef CONFIG_PROC_FS 1452#ifdef CONFIG_PROC_SYSCTL
1393 unregister_proc_table(header->ctl_table, proc_sys_root); 1453 unregister_proc_table(header->ctl_table, proc_sys_root);
1394#endif 1454#endif
1395 spin_unlock(&sysctl_lock); 1455 spin_unlock(&sysctl_lock);
1396 kfree(header); 1456 kfree(header);
1397} 1457}
1398 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
1399/* 1472/*
1400 * /proc/sys support 1473 * /proc/sys support
1401 */ 1474 */
1402 1475
1403#ifdef CONFIG_PROC_FS 1476#ifdef CONFIG_PROC_SYSCTL
1404 1477
1405/* 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 */
1406static 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)
@@ -1839,7 +1912,7 @@ int proc_dointvec_bset(ctl_table *table, int write, struct file *filp,
1839 return -EPERM; 1912 return -EPERM;
1840 } 1913 }
1841 1914
1842 op = (current->pid == 1) ? OP_SET : OP_AND; 1915 op = is_init(current) ? OP_SET : OP_AND;
1843 return do_proc_dointvec(table,write,filp,buffer,lenp,ppos, 1916 return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
1844 do_proc_dointvec_bset_conv,&op); 1917 do_proc_dointvec_bset_conv,&op);
1845} 1918}
@@ -2262,6 +2335,7 @@ int proc_doulongvec_ms_jiffies_minmax(ctl_table *table, int write,
2262#endif /* CONFIG_PROC_FS */ 2335#endif /* CONFIG_PROC_FS */
2263 2336
2264 2337
2338#ifdef CONFIG_SYSCTL_SYSCALL
2265/* 2339/*
2266 * General sysctl support routines 2340 * General sysctl support routines
2267 */ 2341 */
@@ -2404,11 +2478,19 @@ int sysctl_ms_jiffies(ctl_table *table, int __user *name, int nlen,
2404 return 1; 2478 return 1;
2405} 2479}
2406 2480
2407#else /* CONFIG_SYSCTL */ 2481#else /* CONFIG_SYSCTL_SYSCALL */
2408 2482
2409 2483
2410asmlinkage long sys_sysctl(struct __sysctl_args __user *args) 2484asmlinkage long sys_sysctl(struct __sysctl_args __user *args)
2411{ 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 }
2412 return -ENOSYS; 2494 return -ENOSYS;
2413} 2495}
2414 2496
@@ -2440,73 +2522,7 @@ int sysctl_ms_jiffies(ctl_table *table, int __user *name, int nlen,
2440 return -ENOSYS; 2522 return -ENOSYS;
2441} 2523}
2442 2524
2443int proc_dostring(ctl_table *table, int write, struct file *filp, 2525#endif /* CONFIG_SYSCTL_SYSCALL */
2444 void __user *buffer, size_t *lenp, loff_t *ppos)
2445{
2446 return -ENOSYS;
2447}
2448
2449int proc_dointvec(ctl_table *table, int write, struct file *filp,
2450 void __user *buffer, size_t *lenp, loff_t *ppos)
2451{
2452 return -ENOSYS;
2453}
2454
2455int proc_dointvec_bset(ctl_table *table, int write, struct file *filp,
2456 void __user *buffer, size_t *lenp, loff_t *ppos)
2457{
2458 return -ENOSYS;
2459}
2460
2461int proc_dointvec_minmax(ctl_table *table, int write, struct file *filp,
2462 void __user *buffer, size_t *lenp, loff_t *ppos)
2463{
2464 return -ENOSYS;
2465}
2466
2467int proc_dointvec_jiffies(ctl_table *table, int write, struct file *filp,
2468 void __user *buffer, size_t *lenp, loff_t *ppos)
2469{
2470 return -ENOSYS;
2471}
2472
2473int proc_dointvec_userhz_jiffies(ctl_table *table, int write, struct file *filp,
2474 void __user *buffer, size_t *lenp, loff_t *ppos)
2475{
2476 return -ENOSYS;
2477}
2478
2479int proc_dointvec_ms_jiffies(ctl_table *table, int write, struct file *filp,
2480 void __user *buffer, size_t *lenp, loff_t *ppos)
2481{
2482 return -ENOSYS;
2483}
2484
2485int proc_doulongvec_minmax(ctl_table *table, int write, struct file *filp,
2486 void __user *buffer, size_t *lenp, loff_t *ppos)
2487{
2488 return -ENOSYS;
2489}
2490
2491int proc_doulongvec_ms_jiffies_minmax(ctl_table *table, int write,
2492 struct file *filp,
2493 void __user *buffer,
2494 size_t *lenp, loff_t *ppos)
2495{
2496 return -ENOSYS;
2497}
2498
2499struct ctl_table_header * register_sysctl_table(ctl_table * table,
2500 int insert_at_head)
2501{
2502 return NULL;
2503}
2504
2505void unregister_sysctl_table(struct ctl_table_header * table)
2506{
2507}
2508
2509#endif /* CONFIG_SYSCTL */
2510 2526
2511/* 2527/*
2512 * No sense putting this after each symbol definition, twice, 2528 * No sense putting this after each symbol definition, twice,