aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/sysctl.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/sysctl.c')
-rw-r--r--kernel/sysctl.c155
1 files changed, 82 insertions, 73 deletions
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 50ec0886fa3d..3d56fe7570da 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -80,7 +80,6 @@ extern int pid_max_min, pid_max_max;
80extern int sysctl_drop_caches; 80extern int sysctl_drop_caches;
81extern int percpu_pagelist_fraction; 81extern int percpu_pagelist_fraction;
82extern int compat_log; 82extern int compat_log;
83extern int maps_protect;
84extern int latencytop_enabled; 83extern int latencytop_enabled;
85extern int sysctl_nr_open_min, sysctl_nr_open_max; 84extern int sysctl_nr_open_min, sysctl_nr_open_max;
86#ifdef CONFIG_RCU_TORTURE_TEST 85#ifdef CONFIG_RCU_TORTURE_TEST
@@ -97,7 +96,7 @@ static int sixty = 60;
97static int neg_one = -1; 96static int neg_one = -1;
98#endif 97#endif
99 98
100#ifdef CONFIG_MMU 99#if defined(CONFIG_MMU) && defined(CONFIG_FILE_LOCKING)
101static int two = 2; 100static int two = 2;
102#endif 101#endif
103 102
@@ -118,10 +117,8 @@ extern char modprobe_path[];
118extern int sg_big_buff; 117extern int sg_big_buff;
119#endif 118#endif
120 119
121#ifdef __sparc__ 120#ifdef CONFIG_SPARC
122extern char reboot_command []; 121#include <asm/system.h>
123extern int stop_a_enabled;
124extern int scons_pwroff;
125#endif 122#endif
126 123
127#ifdef __hppa__ 124#ifdef __hppa__
@@ -152,7 +149,7 @@ extern int max_lock_depth;
152#ifdef CONFIG_PROC_SYSCTL 149#ifdef CONFIG_PROC_SYSCTL
153static int proc_do_cad_pid(struct ctl_table *table, int write, struct file *filp, 150static int proc_do_cad_pid(struct ctl_table *table, int write, struct file *filp,
154 void __user *buffer, size_t *lenp, loff_t *ppos); 151 void __user *buffer, size_t *lenp, loff_t *ppos);
155static int proc_dointvec_taint(struct ctl_table *table, int write, struct file *filp, 152static int proc_taint(struct ctl_table *table, int write, struct file *filp,
156 void __user *buffer, size_t *lenp, loff_t *ppos); 153 void __user *buffer, size_t *lenp, loff_t *ppos);
157#endif 154#endif
158 155
@@ -179,6 +176,9 @@ extern struct ctl_table random_table[];
179#ifdef CONFIG_INOTIFY_USER 176#ifdef CONFIG_INOTIFY_USER
180extern struct ctl_table inotify_table[]; 177extern struct ctl_table inotify_table[];
181#endif 178#endif
179#ifdef CONFIG_EPOLL
180extern struct ctl_table epoll_table[];
181#endif
182 182
183#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT 183#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
184int sysctl_legacy_va_layout; 184int sysctl_legacy_va_layout;
@@ -279,6 +279,16 @@ static struct ctl_table kern_table[] = {
279 }, 279 },
280 { 280 {
281 .ctl_name = CTL_UNNUMBERED, 281 .ctl_name = CTL_UNNUMBERED,
282 .procname = "sched_shares_thresh",
283 .data = &sysctl_sched_shares_thresh,
284 .maxlen = sizeof(unsigned int),
285 .mode = 0644,
286 .proc_handler = &proc_dointvec_minmax,
287 .strategy = &sysctl_intvec,
288 .extra1 = &zero,
289 },
290 {
291 .ctl_name = CTL_UNNUMBERED,
282 .procname = "sched_child_runs_first", 292 .procname = "sched_child_runs_first",
283 .data = &sysctl_sched_child_runs_first, 293 .data = &sysctl_sched_child_runs_first,
284 .maxlen = sizeof(unsigned int), 294 .maxlen = sizeof(unsigned int),
@@ -382,10 +392,9 @@ static struct ctl_table kern_table[] = {
382#ifdef CONFIG_PROC_SYSCTL 392#ifdef CONFIG_PROC_SYSCTL
383 { 393 {
384 .procname = "tainted", 394 .procname = "tainted",
385 .data = &tainted, 395 .maxlen = sizeof(long),
386 .maxlen = sizeof(int),
387 .mode = 0644, 396 .mode = 0644,
388 .proc_handler = &proc_dointvec_taint, 397 .proc_handler = &proc_taint,
389 }, 398 },
390#endif 399#endif
391#ifdef CONFIG_LATENCYTOP 400#ifdef CONFIG_LATENCYTOP
@@ -415,7 +424,7 @@ static struct ctl_table kern_table[] = {
415 .mode = 0644, 424 .mode = 0644,
416 .proc_handler = &proc_dointvec, 425 .proc_handler = &proc_dointvec,
417 }, 426 },
418#ifdef __sparc__ 427#ifdef CONFIG_SPARC
419 { 428 {
420 .ctl_name = KERN_SPARC_REBOOT, 429 .ctl_name = KERN_SPARC_REBOOT,
421 .procname = "reboot-cmd", 430 .procname = "reboot-cmd",
@@ -468,7 +477,7 @@ static struct ctl_table kern_table[] = {
468 .mode = 0644, 477 .mode = 0644,
469 .proc_handler = &proc_dointvec, 478 .proc_handler = &proc_dointvec,
470 }, 479 },
471#ifdef CONFIG_FTRACE 480#ifdef CONFIG_FUNCTION_TRACER
472 { 481 {
473 .ctl_name = CTL_UNNUMBERED, 482 .ctl_name = CTL_UNNUMBERED,
474 .procname = "ftrace_enabled", 483 .procname = "ftrace_enabled",
@@ -810,16 +819,6 @@ static struct ctl_table kern_table[] = {
810 .proc_handler = &proc_dointvec, 819 .proc_handler = &proc_dointvec,
811 }, 820 },
812#endif 821#endif
813#ifdef CONFIG_PROC_FS
814 {
815 .ctl_name = CTL_UNNUMBERED,
816 .procname = "maps_protect",
817 .data = &maps_protect,
818 .maxlen = sizeof(int),
819 .mode = 0644,
820 .proc_handler = &proc_dointvec,
821 },
822#endif
823 { 822 {
824 .ctl_name = CTL_UNNUMBERED, 823 .ctl_name = CTL_UNNUMBERED,
825 .procname = "poweroff_cmd", 824 .procname = "poweroff_cmd",
@@ -847,6 +846,16 @@ static struct ctl_table kern_table[] = {
847 .proc_handler = &proc_dointvec, 846 .proc_handler = &proc_dointvec,
848 }, 847 },
849#endif 848#endif
849#ifdef CONFIG_UNEVICTABLE_LRU
850 {
851 .ctl_name = CTL_UNNUMBERED,
852 .procname = "scan_unevictable_pages",
853 .data = &scan_unevictable_pages,
854 .maxlen = sizeof(scan_unevictable_pages),
855 .mode = 0644,
856 .proc_handler = &scan_unevictable_handler,
857 },
858#endif
850/* 859/*
851 * NOTE: do not add new entries to this table unless you have read 860 * NOTE: do not add new entries to this table unless you have read
852 * Documentation/sysctl/ctl_unnumbered.txt 861 * Documentation/sysctl/ctl_unnumbered.txt
@@ -1261,6 +1270,7 @@ static struct ctl_table fs_table[] = {
1261 .extra1 = &minolduid, 1270 .extra1 = &minolduid,
1262 .extra2 = &maxolduid, 1271 .extra2 = &maxolduid,
1263 }, 1272 },
1273#ifdef CONFIG_FILE_LOCKING
1264 { 1274 {
1265 .ctl_name = FS_LEASES, 1275 .ctl_name = FS_LEASES,
1266 .procname = "leases-enable", 1276 .procname = "leases-enable",
@@ -1269,6 +1279,7 @@ static struct ctl_table fs_table[] = {
1269 .mode = 0644, 1279 .mode = 0644,
1270 .proc_handler = &proc_dointvec, 1280 .proc_handler = &proc_dointvec,
1271 }, 1281 },
1282#endif
1272#ifdef CONFIG_DNOTIFY 1283#ifdef CONFIG_DNOTIFY
1273 { 1284 {
1274 .ctl_name = FS_DIR_NOTIFY, 1285 .ctl_name = FS_DIR_NOTIFY,
@@ -1280,6 +1291,7 @@ static struct ctl_table fs_table[] = {
1280 }, 1291 },
1281#endif 1292#endif
1282#ifdef CONFIG_MMU 1293#ifdef CONFIG_MMU
1294#ifdef CONFIG_FILE_LOCKING
1283 { 1295 {
1284 .ctl_name = FS_LEASE_TIME, 1296 .ctl_name = FS_LEASE_TIME,
1285 .procname = "lease-break-time", 1297 .procname = "lease-break-time",
@@ -1291,6 +1303,8 @@ static struct ctl_table fs_table[] = {
1291 .extra1 = &zero, 1303 .extra1 = &zero,
1292 .extra2 = &two, 1304 .extra2 = &two,
1293 }, 1305 },
1306#endif
1307#ifdef CONFIG_AIO
1294 { 1308 {
1295 .procname = "aio-nr", 1309 .procname = "aio-nr",
1296 .data = &aio_nr, 1310 .data = &aio_nr,
@@ -1305,6 +1319,7 @@ static struct ctl_table fs_table[] = {
1305 .mode = 0644, 1319 .mode = 0644,
1306 .proc_handler = &proc_doulongvec_minmax, 1320 .proc_handler = &proc_doulongvec_minmax,
1307 }, 1321 },
1322#endif /* CONFIG_AIO */
1308#ifdef CONFIG_INOTIFY_USER 1323#ifdef CONFIG_INOTIFY_USER
1309 { 1324 {
1310 .ctl_name = FS_INOTIFY, 1325 .ctl_name = FS_INOTIFY,
@@ -1313,6 +1328,13 @@ static struct ctl_table fs_table[] = {
1313 .child = inotify_table, 1328 .child = inotify_table,
1314 }, 1329 },
1315#endif 1330#endif
1331#ifdef CONFIG_EPOLL
1332 {
1333 .procname = "epoll",
1334 .mode = 0555,
1335 .child = epoll_table,
1336 },
1337#endif
1316#endif 1338#endif
1317 { 1339 {
1318 .ctl_name = KERN_SETUID_DUMPABLE, 1340 .ctl_name = KERN_SETUID_DUMPABLE,
@@ -1510,7 +1532,6 @@ void register_sysctl_root(struct ctl_table_root *root)
1510/* Perform the actual read/write of a sysctl table entry. */ 1532/* Perform the actual read/write of a sysctl table entry. */
1511static int do_sysctl_strategy(struct ctl_table_root *root, 1533static int do_sysctl_strategy(struct ctl_table_root *root,
1512 struct ctl_table *table, 1534 struct ctl_table *table,
1513 int __user *name, int nlen,
1514 void __user *oldval, size_t __user *oldlenp, 1535 void __user *oldval, size_t __user *oldlenp,
1515 void __user *newval, size_t newlen) 1536 void __user *newval, size_t newlen)
1516{ 1537{
@@ -1524,8 +1545,7 @@ static int do_sysctl_strategy(struct ctl_table_root *root,
1524 return -EPERM; 1545 return -EPERM;
1525 1546
1526 if (table->strategy) { 1547 if (table->strategy) {
1527 rc = table->strategy(table, name, nlen, oldval, oldlenp, 1548 rc = table->strategy(table, oldval, oldlenp, newval, newlen);
1528 newval, newlen);
1529 if (rc < 0) 1549 if (rc < 0)
1530 return rc; 1550 return rc;
1531 if (rc > 0) 1551 if (rc > 0)
@@ -1535,8 +1555,7 @@ static int do_sysctl_strategy(struct ctl_table_root *root,
1535 /* If there is no strategy routine, or if the strategy returns 1555 /* If there is no strategy routine, or if the strategy returns
1536 * zero, proceed with automatic r/w */ 1556 * zero, proceed with automatic r/w */
1537 if (table->data && table->maxlen) { 1557 if (table->data && table->maxlen) {
1538 rc = sysctl_data(table, name, nlen, oldval, oldlenp, 1558 rc = sysctl_data(table, oldval, oldlenp, newval, newlen);
1539 newval, newlen);
1540 if (rc < 0) 1559 if (rc < 0)
1541 return rc; 1560 return rc;
1542 } 1561 }
@@ -1568,7 +1587,7 @@ repeat:
1568 table = table->child; 1587 table = table->child;
1569 goto repeat; 1588 goto repeat;
1570 } 1589 }
1571 error = do_sysctl_strategy(root, table, name, nlen, 1590 error = do_sysctl_strategy(root, table,
1572 oldval, oldlenp, 1591 oldval, oldlenp,
1573 newval, newlen); 1592 newval, newlen);
1574 return error; 1593 return error;
@@ -2237,49 +2256,39 @@ int proc_dointvec(struct ctl_table *table, int write, struct file *filp,
2237 NULL,NULL); 2256 NULL,NULL);
2238} 2257}
2239 2258
2240#define OP_SET 0
2241#define OP_AND 1
2242#define OP_OR 2
2243
2244static int do_proc_dointvec_bset_conv(int *negp, unsigned long *lvalp,
2245 int *valp,
2246 int write, void *data)
2247{
2248 int op = *(int *)data;
2249 if (write) {
2250 int val = *negp ? -*lvalp : *lvalp;
2251 switch(op) {
2252 case OP_SET: *valp = val; break;
2253 case OP_AND: *valp &= val; break;
2254 case OP_OR: *valp |= val; break;
2255 }
2256 } else {
2257 int val = *valp;
2258 if (val < 0) {
2259 *negp = -1;
2260 *lvalp = (unsigned long)-val;
2261 } else {
2262 *negp = 0;
2263 *lvalp = (unsigned long)val;
2264 }
2265 }
2266 return 0;
2267}
2268
2269/* 2259/*
2270 * Taint values can only be increased 2260 * Taint values can only be increased
2261 * This means we can safely use a temporary.
2271 */ 2262 */
2272static int proc_dointvec_taint(struct ctl_table *table, int write, struct file *filp, 2263static int proc_taint(struct ctl_table *table, int write, struct file *filp,
2273 void __user *buffer, size_t *lenp, loff_t *ppos) 2264 void __user *buffer, size_t *lenp, loff_t *ppos)
2274{ 2265{
2275 int op; 2266 struct ctl_table t;
2267 unsigned long tmptaint = get_taint();
2268 int err;
2276 2269
2277 if (write && !capable(CAP_SYS_ADMIN)) 2270 if (write && !capable(CAP_SYS_ADMIN))
2278 return -EPERM; 2271 return -EPERM;
2279 2272
2280 op = OP_OR; 2273 t = *table;
2281 return do_proc_dointvec(table,write,filp,buffer,lenp,ppos, 2274 t.data = &tmptaint;
2282 do_proc_dointvec_bset_conv,&op); 2275 err = proc_doulongvec_minmax(&t, write, filp, buffer, lenp, ppos);
2276 if (err < 0)
2277 return err;
2278
2279 if (write) {
2280 /*
2281 * Poor man's atomic or. Not worth adding a primitive
2282 * to everyone's atomic.h for this
2283 */
2284 int i;
2285 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
2286 if ((tmptaint >> i) & 1)
2287 add_taint(i);
2288 }
2289 }
2290
2291 return err;
2283} 2292}
2284 2293
2285struct do_proc_dointvec_minmax_conv_param { 2294struct do_proc_dointvec_minmax_conv_param {
@@ -2727,7 +2736,7 @@ int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
2727 */ 2736 */
2728 2737
2729/* The generic sysctl data routine (used if no strategy routine supplied) */ 2738/* The generic sysctl data routine (used if no strategy routine supplied) */
2730int sysctl_data(struct ctl_table *table, int __user *name, int nlen, 2739int sysctl_data(struct ctl_table *table,
2731 void __user *oldval, size_t __user *oldlenp, 2740 void __user *oldval, size_t __user *oldlenp,
2732 void __user *newval, size_t newlen) 2741 void __user *newval, size_t newlen)
2733{ 2742{
@@ -2761,7 +2770,7 @@ int sysctl_data(struct ctl_table *table, int __user *name, int nlen,
2761} 2770}
2762 2771
2763/* The generic string strategy routine: */ 2772/* The generic string strategy routine: */
2764int sysctl_string(struct ctl_table *table, int __user *name, int nlen, 2773int sysctl_string(struct ctl_table *table,
2765 void __user *oldval, size_t __user *oldlenp, 2774 void __user *oldval, size_t __user *oldlenp,
2766 void __user *newval, size_t newlen) 2775 void __user *newval, size_t newlen)
2767{ 2776{
@@ -2807,7 +2816,7 @@ int sysctl_string(struct ctl_table *table, int __user *name, int nlen,
2807 * are between the minimum and maximum values given in the arrays 2816 * are between the minimum and maximum values given in the arrays
2808 * table->extra1 and table->extra2, respectively. 2817 * table->extra1 and table->extra2, respectively.
2809 */ 2818 */
2810int sysctl_intvec(struct ctl_table *table, int __user *name, int nlen, 2819int sysctl_intvec(struct ctl_table *table,
2811 void __user *oldval, size_t __user *oldlenp, 2820 void __user *oldval, size_t __user *oldlenp,
2812 void __user *newval, size_t newlen) 2821 void __user *newval, size_t newlen)
2813{ 2822{
@@ -2843,7 +2852,7 @@ int sysctl_intvec(struct ctl_table *table, int __user *name, int nlen,
2843} 2852}
2844 2853
2845/* Strategy function to convert jiffies to seconds */ 2854/* Strategy function to convert jiffies to seconds */
2846int sysctl_jiffies(struct ctl_table *table, int __user *name, int nlen, 2855int sysctl_jiffies(struct ctl_table *table,
2847 void __user *oldval, size_t __user *oldlenp, 2856 void __user *oldval, size_t __user *oldlenp,
2848 void __user *newval, size_t newlen) 2857 void __user *newval, size_t newlen)
2849{ 2858{
@@ -2877,7 +2886,7 @@ int sysctl_jiffies(struct ctl_table *table, int __user *name, int nlen,
2877} 2886}
2878 2887
2879/* Strategy function to convert jiffies to seconds */ 2888/* Strategy function to convert jiffies to seconds */
2880int sysctl_ms_jiffies(struct ctl_table *table, int __user *name, int nlen, 2889int sysctl_ms_jiffies(struct ctl_table *table,
2881 void __user *oldval, size_t __user *oldlenp, 2890 void __user *oldval, size_t __user *oldlenp,
2882 void __user *newval, size_t newlen) 2891 void __user *newval, size_t newlen)
2883{ 2892{
@@ -2932,35 +2941,35 @@ asmlinkage long sys_sysctl(struct __sysctl_args __user *args)
2932 return error; 2941 return error;
2933} 2942}
2934 2943
2935int sysctl_data(struct ctl_table *table, int __user *name, int nlen, 2944int sysctl_data(struct ctl_table *table,
2936 void __user *oldval, size_t __user *oldlenp, 2945 void __user *oldval, size_t __user *oldlenp,
2937 void __user *newval, size_t newlen) 2946 void __user *newval, size_t newlen)
2938{ 2947{
2939 return -ENOSYS; 2948 return -ENOSYS;
2940} 2949}
2941 2950
2942int sysctl_string(struct ctl_table *table, int __user *name, int nlen, 2951int sysctl_string(struct ctl_table *table,
2943 void __user *oldval, size_t __user *oldlenp, 2952 void __user *oldval, size_t __user *oldlenp,
2944 void __user *newval, size_t newlen) 2953 void __user *newval, size_t newlen)
2945{ 2954{
2946 return -ENOSYS; 2955 return -ENOSYS;
2947} 2956}
2948 2957
2949int sysctl_intvec(struct ctl_table *table, int __user *name, int nlen, 2958int sysctl_intvec(struct ctl_table *table,
2950 void __user *oldval, size_t __user *oldlenp, 2959 void __user *oldval, size_t __user *oldlenp,
2951 void __user *newval, size_t newlen) 2960 void __user *newval, size_t newlen)
2952{ 2961{
2953 return -ENOSYS; 2962 return -ENOSYS;
2954} 2963}
2955 2964
2956int sysctl_jiffies(struct ctl_table *table, int __user *name, int nlen, 2965int sysctl_jiffies(struct ctl_table *table,
2957 void __user *oldval, size_t __user *oldlenp, 2966 void __user *oldval, size_t __user *oldlenp,
2958 void __user *newval, size_t newlen) 2967 void __user *newval, size_t newlen)
2959{ 2968{
2960 return -ENOSYS; 2969 return -ENOSYS;
2961} 2970}
2962 2971
2963int sysctl_ms_jiffies(struct ctl_table *table, int __user *name, int nlen, 2972int sysctl_ms_jiffies(struct ctl_table *table,
2964 void __user *oldval, size_t __user *oldlenp, 2973 void __user *oldval, size_t __user *oldlenp,
2965 void __user *newval, size_t newlen) 2974 void __user *newval, size_t newlen)
2966{ 2975{