diff options
Diffstat (limited to 'kernel/sysctl.c')
-rw-r--r-- | kernel/sysctl.c | 145 |
1 files changed, 72 insertions, 73 deletions
diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 50ec0886fa3d..9d048fa2d902 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c | |||
@@ -80,7 +80,6 @@ extern int pid_max_min, pid_max_max; | |||
80 | extern int sysctl_drop_caches; | 80 | extern int sysctl_drop_caches; |
81 | extern int percpu_pagelist_fraction; | 81 | extern int percpu_pagelist_fraction; |
82 | extern int compat_log; | 82 | extern int compat_log; |
83 | extern int maps_protect; | ||
84 | extern int latencytop_enabled; | 83 | extern int latencytop_enabled; |
85 | extern int sysctl_nr_open_min, sysctl_nr_open_max; | 84 | extern 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; | |||
97 | static int neg_one = -1; | 96 | static int neg_one = -1; |
98 | #endif | 97 | #endif |
99 | 98 | ||
100 | #ifdef CONFIG_MMU | 99 | #if defined(CONFIG_MMU) && defined(CONFIG_FILE_LOCKING) |
101 | static int two = 2; | 100 | static int two = 2; |
102 | #endif | 101 | #endif |
103 | 102 | ||
@@ -118,10 +117,8 @@ extern char modprobe_path[]; | |||
118 | extern int sg_big_buff; | 117 | extern int sg_big_buff; |
119 | #endif | 118 | #endif |
120 | 119 | ||
121 | #ifdef __sparc__ | 120 | #ifdef CONFIG_SPARC |
122 | extern char reboot_command []; | 121 | #include <asm/system.h> |
123 | extern int stop_a_enabled; | ||
124 | extern 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 |
153 | static int proc_do_cad_pid(struct ctl_table *table, int write, struct file *filp, | 150 | static 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); |
155 | static int proc_dointvec_taint(struct ctl_table *table, int write, struct file *filp, | 152 | static 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 | ||
@@ -279,6 +276,16 @@ static struct ctl_table kern_table[] = { | |||
279 | }, | 276 | }, |
280 | { | 277 | { |
281 | .ctl_name = CTL_UNNUMBERED, | 278 | .ctl_name = CTL_UNNUMBERED, |
279 | .procname = "sched_shares_thresh", | ||
280 | .data = &sysctl_sched_shares_thresh, | ||
281 | .maxlen = sizeof(unsigned int), | ||
282 | .mode = 0644, | ||
283 | .proc_handler = &proc_dointvec_minmax, | ||
284 | .strategy = &sysctl_intvec, | ||
285 | .extra1 = &zero, | ||
286 | }, | ||
287 | { | ||
288 | .ctl_name = CTL_UNNUMBERED, | ||
282 | .procname = "sched_child_runs_first", | 289 | .procname = "sched_child_runs_first", |
283 | .data = &sysctl_sched_child_runs_first, | 290 | .data = &sysctl_sched_child_runs_first, |
284 | .maxlen = sizeof(unsigned int), | 291 | .maxlen = sizeof(unsigned int), |
@@ -382,10 +389,9 @@ static struct ctl_table kern_table[] = { | |||
382 | #ifdef CONFIG_PROC_SYSCTL | 389 | #ifdef CONFIG_PROC_SYSCTL |
383 | { | 390 | { |
384 | .procname = "tainted", | 391 | .procname = "tainted", |
385 | .data = &tainted, | 392 | .maxlen = sizeof(long), |
386 | .maxlen = sizeof(int), | ||
387 | .mode = 0644, | 393 | .mode = 0644, |
388 | .proc_handler = &proc_dointvec_taint, | 394 | .proc_handler = &proc_taint, |
389 | }, | 395 | }, |
390 | #endif | 396 | #endif |
391 | #ifdef CONFIG_LATENCYTOP | 397 | #ifdef CONFIG_LATENCYTOP |
@@ -415,7 +421,7 @@ static struct ctl_table kern_table[] = { | |||
415 | .mode = 0644, | 421 | .mode = 0644, |
416 | .proc_handler = &proc_dointvec, | 422 | .proc_handler = &proc_dointvec, |
417 | }, | 423 | }, |
418 | #ifdef __sparc__ | 424 | #ifdef CONFIG_SPARC |
419 | { | 425 | { |
420 | .ctl_name = KERN_SPARC_REBOOT, | 426 | .ctl_name = KERN_SPARC_REBOOT, |
421 | .procname = "reboot-cmd", | 427 | .procname = "reboot-cmd", |
@@ -468,7 +474,7 @@ static struct ctl_table kern_table[] = { | |||
468 | .mode = 0644, | 474 | .mode = 0644, |
469 | .proc_handler = &proc_dointvec, | 475 | .proc_handler = &proc_dointvec, |
470 | }, | 476 | }, |
471 | #ifdef CONFIG_FTRACE | 477 | #ifdef CONFIG_FUNCTION_TRACER |
472 | { | 478 | { |
473 | .ctl_name = CTL_UNNUMBERED, | 479 | .ctl_name = CTL_UNNUMBERED, |
474 | .procname = "ftrace_enabled", | 480 | .procname = "ftrace_enabled", |
@@ -810,16 +816,6 @@ static struct ctl_table kern_table[] = { | |||
810 | .proc_handler = &proc_dointvec, | 816 | .proc_handler = &proc_dointvec, |
811 | }, | 817 | }, |
812 | #endif | 818 | #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 | { | 819 | { |
824 | .ctl_name = CTL_UNNUMBERED, | 820 | .ctl_name = CTL_UNNUMBERED, |
825 | .procname = "poweroff_cmd", | 821 | .procname = "poweroff_cmd", |
@@ -847,6 +843,16 @@ static struct ctl_table kern_table[] = { | |||
847 | .proc_handler = &proc_dointvec, | 843 | .proc_handler = &proc_dointvec, |
848 | }, | 844 | }, |
849 | #endif | 845 | #endif |
846 | #ifdef CONFIG_UNEVICTABLE_LRU | ||
847 | { | ||
848 | .ctl_name = CTL_UNNUMBERED, | ||
849 | .procname = "scan_unevictable_pages", | ||
850 | .data = &scan_unevictable_pages, | ||
851 | .maxlen = sizeof(scan_unevictable_pages), | ||
852 | .mode = 0644, | ||
853 | .proc_handler = &scan_unevictable_handler, | ||
854 | }, | ||
855 | #endif | ||
850 | /* | 856 | /* |
851 | * NOTE: do not add new entries to this table unless you have read | 857 | * NOTE: do not add new entries to this table unless you have read |
852 | * Documentation/sysctl/ctl_unnumbered.txt | 858 | * Documentation/sysctl/ctl_unnumbered.txt |
@@ -1261,6 +1267,7 @@ static struct ctl_table fs_table[] = { | |||
1261 | .extra1 = &minolduid, | 1267 | .extra1 = &minolduid, |
1262 | .extra2 = &maxolduid, | 1268 | .extra2 = &maxolduid, |
1263 | }, | 1269 | }, |
1270 | #ifdef CONFIG_FILE_LOCKING | ||
1264 | { | 1271 | { |
1265 | .ctl_name = FS_LEASES, | 1272 | .ctl_name = FS_LEASES, |
1266 | .procname = "leases-enable", | 1273 | .procname = "leases-enable", |
@@ -1269,6 +1276,7 @@ static struct ctl_table fs_table[] = { | |||
1269 | .mode = 0644, | 1276 | .mode = 0644, |
1270 | .proc_handler = &proc_dointvec, | 1277 | .proc_handler = &proc_dointvec, |
1271 | }, | 1278 | }, |
1279 | #endif | ||
1272 | #ifdef CONFIG_DNOTIFY | 1280 | #ifdef CONFIG_DNOTIFY |
1273 | { | 1281 | { |
1274 | .ctl_name = FS_DIR_NOTIFY, | 1282 | .ctl_name = FS_DIR_NOTIFY, |
@@ -1280,6 +1288,7 @@ static struct ctl_table fs_table[] = { | |||
1280 | }, | 1288 | }, |
1281 | #endif | 1289 | #endif |
1282 | #ifdef CONFIG_MMU | 1290 | #ifdef CONFIG_MMU |
1291 | #ifdef CONFIG_FILE_LOCKING | ||
1283 | { | 1292 | { |
1284 | .ctl_name = FS_LEASE_TIME, | 1293 | .ctl_name = FS_LEASE_TIME, |
1285 | .procname = "lease-break-time", | 1294 | .procname = "lease-break-time", |
@@ -1291,6 +1300,8 @@ static struct ctl_table fs_table[] = { | |||
1291 | .extra1 = &zero, | 1300 | .extra1 = &zero, |
1292 | .extra2 = &two, | 1301 | .extra2 = &two, |
1293 | }, | 1302 | }, |
1303 | #endif | ||
1304 | #ifdef CONFIG_AIO | ||
1294 | { | 1305 | { |
1295 | .procname = "aio-nr", | 1306 | .procname = "aio-nr", |
1296 | .data = &aio_nr, | 1307 | .data = &aio_nr, |
@@ -1305,6 +1316,7 @@ static struct ctl_table fs_table[] = { | |||
1305 | .mode = 0644, | 1316 | .mode = 0644, |
1306 | .proc_handler = &proc_doulongvec_minmax, | 1317 | .proc_handler = &proc_doulongvec_minmax, |
1307 | }, | 1318 | }, |
1319 | #endif /* CONFIG_AIO */ | ||
1308 | #ifdef CONFIG_INOTIFY_USER | 1320 | #ifdef CONFIG_INOTIFY_USER |
1309 | { | 1321 | { |
1310 | .ctl_name = FS_INOTIFY, | 1322 | .ctl_name = FS_INOTIFY, |
@@ -1510,7 +1522,6 @@ void register_sysctl_root(struct ctl_table_root *root) | |||
1510 | /* Perform the actual read/write of a sysctl table entry. */ | 1522 | /* Perform the actual read/write of a sysctl table entry. */ |
1511 | static int do_sysctl_strategy(struct ctl_table_root *root, | 1523 | static int do_sysctl_strategy(struct ctl_table_root *root, |
1512 | struct ctl_table *table, | 1524 | struct ctl_table *table, |
1513 | int __user *name, int nlen, | ||
1514 | void __user *oldval, size_t __user *oldlenp, | 1525 | void __user *oldval, size_t __user *oldlenp, |
1515 | void __user *newval, size_t newlen) | 1526 | void __user *newval, size_t newlen) |
1516 | { | 1527 | { |
@@ -1524,8 +1535,7 @@ static int do_sysctl_strategy(struct ctl_table_root *root, | |||
1524 | return -EPERM; | 1535 | return -EPERM; |
1525 | 1536 | ||
1526 | if (table->strategy) { | 1537 | if (table->strategy) { |
1527 | rc = table->strategy(table, name, nlen, oldval, oldlenp, | 1538 | rc = table->strategy(table, oldval, oldlenp, newval, newlen); |
1528 | newval, newlen); | ||
1529 | if (rc < 0) | 1539 | if (rc < 0) |
1530 | return rc; | 1540 | return rc; |
1531 | if (rc > 0) | 1541 | if (rc > 0) |
@@ -1535,8 +1545,7 @@ static int do_sysctl_strategy(struct ctl_table_root *root, | |||
1535 | /* If there is no strategy routine, or if the strategy returns | 1545 | /* If there is no strategy routine, or if the strategy returns |
1536 | * zero, proceed with automatic r/w */ | 1546 | * zero, proceed with automatic r/w */ |
1537 | if (table->data && table->maxlen) { | 1547 | if (table->data && table->maxlen) { |
1538 | rc = sysctl_data(table, name, nlen, oldval, oldlenp, | 1548 | rc = sysctl_data(table, oldval, oldlenp, newval, newlen); |
1539 | newval, newlen); | ||
1540 | if (rc < 0) | 1549 | if (rc < 0) |
1541 | return rc; | 1550 | return rc; |
1542 | } | 1551 | } |
@@ -1568,7 +1577,7 @@ repeat: | |||
1568 | table = table->child; | 1577 | table = table->child; |
1569 | goto repeat; | 1578 | goto repeat; |
1570 | } | 1579 | } |
1571 | error = do_sysctl_strategy(root, table, name, nlen, | 1580 | error = do_sysctl_strategy(root, table, |
1572 | oldval, oldlenp, | 1581 | oldval, oldlenp, |
1573 | newval, newlen); | 1582 | newval, newlen); |
1574 | return error; | 1583 | return error; |
@@ -2237,49 +2246,39 @@ int proc_dointvec(struct ctl_table *table, int write, struct file *filp, | |||
2237 | NULL,NULL); | 2246 | NULL,NULL); |
2238 | } | 2247 | } |
2239 | 2248 | ||
2240 | #define OP_SET 0 | ||
2241 | #define OP_AND 1 | ||
2242 | #define OP_OR 2 | ||
2243 | |||
2244 | static 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 | /* | 2249 | /* |
2270 | * Taint values can only be increased | 2250 | * Taint values can only be increased |
2251 | * This means we can safely use a temporary. | ||
2271 | */ | 2252 | */ |
2272 | static int proc_dointvec_taint(struct ctl_table *table, int write, struct file *filp, | 2253 | static int proc_taint(struct ctl_table *table, int write, struct file *filp, |
2273 | void __user *buffer, size_t *lenp, loff_t *ppos) | 2254 | void __user *buffer, size_t *lenp, loff_t *ppos) |
2274 | { | 2255 | { |
2275 | int op; | 2256 | struct ctl_table t; |
2257 | unsigned long tmptaint = get_taint(); | ||
2258 | int err; | ||
2276 | 2259 | ||
2277 | if (write && !capable(CAP_SYS_ADMIN)) | 2260 | if (write && !capable(CAP_SYS_ADMIN)) |
2278 | return -EPERM; | 2261 | return -EPERM; |
2279 | 2262 | ||
2280 | op = OP_OR; | 2263 | t = *table; |
2281 | return do_proc_dointvec(table,write,filp,buffer,lenp,ppos, | 2264 | t.data = &tmptaint; |
2282 | do_proc_dointvec_bset_conv,&op); | 2265 | err = proc_doulongvec_minmax(&t, write, filp, buffer, lenp, ppos); |
2266 | if (err < 0) | ||
2267 | return err; | ||
2268 | |||
2269 | if (write) { | ||
2270 | /* | ||
2271 | * Poor man's atomic or. Not worth adding a primitive | ||
2272 | * to everyone's atomic.h for this | ||
2273 | */ | ||
2274 | int i; | ||
2275 | for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) { | ||
2276 | if ((tmptaint >> i) & 1) | ||
2277 | add_taint(i); | ||
2278 | } | ||
2279 | } | ||
2280 | |||
2281 | return err; | ||
2283 | } | 2282 | } |
2284 | 2283 | ||
2285 | struct do_proc_dointvec_minmax_conv_param { | 2284 | struct do_proc_dointvec_minmax_conv_param { |
@@ -2727,7 +2726,7 @@ int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write, | |||
2727 | */ | 2726 | */ |
2728 | 2727 | ||
2729 | /* The generic sysctl data routine (used if no strategy routine supplied) */ | 2728 | /* The generic sysctl data routine (used if no strategy routine supplied) */ |
2730 | int sysctl_data(struct ctl_table *table, int __user *name, int nlen, | 2729 | int sysctl_data(struct ctl_table *table, |
2731 | void __user *oldval, size_t __user *oldlenp, | 2730 | void __user *oldval, size_t __user *oldlenp, |
2732 | void __user *newval, size_t newlen) | 2731 | void __user *newval, size_t newlen) |
2733 | { | 2732 | { |
@@ -2761,7 +2760,7 @@ int sysctl_data(struct ctl_table *table, int __user *name, int nlen, | |||
2761 | } | 2760 | } |
2762 | 2761 | ||
2763 | /* The generic string strategy routine: */ | 2762 | /* The generic string strategy routine: */ |
2764 | int sysctl_string(struct ctl_table *table, int __user *name, int nlen, | 2763 | int sysctl_string(struct ctl_table *table, |
2765 | void __user *oldval, size_t __user *oldlenp, | 2764 | void __user *oldval, size_t __user *oldlenp, |
2766 | void __user *newval, size_t newlen) | 2765 | void __user *newval, size_t newlen) |
2767 | { | 2766 | { |
@@ -2807,7 +2806,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 | 2806 | * are between the minimum and maximum values given in the arrays |
2808 | * table->extra1 and table->extra2, respectively. | 2807 | * table->extra1 and table->extra2, respectively. |
2809 | */ | 2808 | */ |
2810 | int sysctl_intvec(struct ctl_table *table, int __user *name, int nlen, | 2809 | int sysctl_intvec(struct ctl_table *table, |
2811 | void __user *oldval, size_t __user *oldlenp, | 2810 | void __user *oldval, size_t __user *oldlenp, |
2812 | void __user *newval, size_t newlen) | 2811 | void __user *newval, size_t newlen) |
2813 | { | 2812 | { |
@@ -2843,7 +2842,7 @@ int sysctl_intvec(struct ctl_table *table, int __user *name, int nlen, | |||
2843 | } | 2842 | } |
2844 | 2843 | ||
2845 | /* Strategy function to convert jiffies to seconds */ | 2844 | /* Strategy function to convert jiffies to seconds */ |
2846 | int sysctl_jiffies(struct ctl_table *table, int __user *name, int nlen, | 2845 | int sysctl_jiffies(struct ctl_table *table, |
2847 | void __user *oldval, size_t __user *oldlenp, | 2846 | void __user *oldval, size_t __user *oldlenp, |
2848 | void __user *newval, size_t newlen) | 2847 | void __user *newval, size_t newlen) |
2849 | { | 2848 | { |
@@ -2877,7 +2876,7 @@ int sysctl_jiffies(struct ctl_table *table, int __user *name, int nlen, | |||
2877 | } | 2876 | } |
2878 | 2877 | ||
2879 | /* Strategy function to convert jiffies to seconds */ | 2878 | /* Strategy function to convert jiffies to seconds */ |
2880 | int sysctl_ms_jiffies(struct ctl_table *table, int __user *name, int nlen, | 2879 | int sysctl_ms_jiffies(struct ctl_table *table, |
2881 | void __user *oldval, size_t __user *oldlenp, | 2880 | void __user *oldval, size_t __user *oldlenp, |
2882 | void __user *newval, size_t newlen) | 2881 | void __user *newval, size_t newlen) |
2883 | { | 2882 | { |
@@ -2932,35 +2931,35 @@ asmlinkage long sys_sysctl(struct __sysctl_args __user *args) | |||
2932 | return error; | 2931 | return error; |
2933 | } | 2932 | } |
2934 | 2933 | ||
2935 | int sysctl_data(struct ctl_table *table, int __user *name, int nlen, | 2934 | int sysctl_data(struct ctl_table *table, |
2936 | void __user *oldval, size_t __user *oldlenp, | 2935 | void __user *oldval, size_t __user *oldlenp, |
2937 | void __user *newval, size_t newlen) | 2936 | void __user *newval, size_t newlen) |
2938 | { | 2937 | { |
2939 | return -ENOSYS; | 2938 | return -ENOSYS; |
2940 | } | 2939 | } |
2941 | 2940 | ||
2942 | int sysctl_string(struct ctl_table *table, int __user *name, int nlen, | 2941 | int sysctl_string(struct ctl_table *table, |
2943 | void __user *oldval, size_t __user *oldlenp, | 2942 | void __user *oldval, size_t __user *oldlenp, |
2944 | void __user *newval, size_t newlen) | 2943 | void __user *newval, size_t newlen) |
2945 | { | 2944 | { |
2946 | return -ENOSYS; | 2945 | return -ENOSYS; |
2947 | } | 2946 | } |
2948 | 2947 | ||
2949 | int sysctl_intvec(struct ctl_table *table, int __user *name, int nlen, | 2948 | int sysctl_intvec(struct ctl_table *table, |
2950 | void __user *oldval, size_t __user *oldlenp, | 2949 | void __user *oldval, size_t __user *oldlenp, |
2951 | void __user *newval, size_t newlen) | 2950 | void __user *newval, size_t newlen) |
2952 | { | 2951 | { |
2953 | return -ENOSYS; | 2952 | return -ENOSYS; |
2954 | } | 2953 | } |
2955 | 2954 | ||
2956 | int sysctl_jiffies(struct ctl_table *table, int __user *name, int nlen, | 2955 | int sysctl_jiffies(struct ctl_table *table, |
2957 | void __user *oldval, size_t __user *oldlenp, | 2956 | void __user *oldval, size_t __user *oldlenp, |
2958 | void __user *newval, size_t newlen) | 2957 | void __user *newval, size_t newlen) |
2959 | { | 2958 | { |
2960 | return -ENOSYS; | 2959 | return -ENOSYS; |
2961 | } | 2960 | } |
2962 | 2961 | ||
2963 | int sysctl_ms_jiffies(struct ctl_table *table, int __user *name, int nlen, | 2962 | int sysctl_ms_jiffies(struct ctl_table *table, |
2964 | void __user *oldval, size_t __user *oldlenp, | 2963 | void __user *oldval, size_t __user *oldlenp, |
2965 | void __user *newval, size_t newlen) | 2964 | void __user *newval, size_t newlen) |
2966 | { | 2965 | { |