aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/sysctl.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/sysctl.c')
-rw-r--r--kernel/sysctl.c77
1 files changed, 56 insertions, 21 deletions
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 9990e10192e8..cb99a42f8b37 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -25,12 +25,14 @@
25#include <linux/slab.h> 25#include <linux/slab.h>
26#include <linux/sysctl.h> 26#include <linux/sysctl.h>
27#include <linux/proc_fs.h> 27#include <linux/proc_fs.h>
28#include <linux/capability.h>
28#include <linux/ctype.h> 29#include <linux/ctype.h>
29#include <linux/utsname.h> 30#include <linux/utsname.h>
30#include <linux/capability.h> 31#include <linux/capability.h>
31#include <linux/smp_lock.h> 32#include <linux/smp_lock.h>
32#include <linux/init.h> 33#include <linux/init.h>
33#include <linux/kernel.h> 34#include <linux/kernel.h>
35#include <linux/kobject.h>
34#include <linux/net.h> 36#include <linux/net.h>
35#include <linux/sysrq.h> 37#include <linux/sysrq.h>
36#include <linux/highuid.h> 38#include <linux/highuid.h>
@@ -67,6 +69,8 @@ extern int min_free_kbytes;
67extern int printk_ratelimit_jiffies; 69extern int printk_ratelimit_jiffies;
68extern int printk_ratelimit_burst; 70extern int printk_ratelimit_burst;
69extern int pid_max_min, pid_max_max; 71extern int pid_max_min, pid_max_max;
72extern int sysctl_drop_caches;
73extern int percpu_pagelist_fraction;
70 74
71#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86) 75#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
72int unknown_nmi_panic; 76int unknown_nmi_panic;
@@ -77,15 +81,13 @@ extern int proc_unknown_nmi_panic(ctl_table *, int, struct file *,
77/* 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 */
78static int maxolduid = 65535; 82static int maxolduid = 65535;
79static int minolduid; 83static int minolduid;
84static int min_percpu_pagelist_fract = 8;
80 85
81static int ngroups_max = NGROUPS_MAX; 86static int ngroups_max = NGROUPS_MAX;
82 87
83#ifdef CONFIG_KMOD 88#ifdef CONFIG_KMOD
84extern char modprobe_path[]; 89extern char modprobe_path[];
85#endif 90#endif
86#ifdef CONFIG_HOTPLUG
87extern char hotplug_path[];
88#endif
89#ifdef CONFIG_CHR_DEV_SG 91#ifdef CONFIG_CHR_DEV_SG
90extern int sg_big_buff; 92extern int sg_big_buff;
91#endif 93#endif
@@ -110,7 +112,7 @@ extern int pwrsw_enabled;
110extern int unaligned_enabled; 112extern int unaligned_enabled;
111#endif 113#endif
112 114
113#ifdef CONFIG_ARCH_S390 115#ifdef CONFIG_S390
114#ifdef CONFIG_MATHEMU 116#ifdef CONFIG_MATHEMU
115extern int sysctl_ieee_emulation_warnings; 117extern int sysctl_ieee_emulation_warnings;
116#endif 118#endif
@@ -397,8 +399,8 @@ static ctl_table kern_table[] = {
397 { 399 {
398 .ctl_name = KERN_HOTPLUG, 400 .ctl_name = KERN_HOTPLUG,
399 .procname = "hotplug", 401 .procname = "hotplug",
400 .data = &hotplug_path, 402 .data = &uevent_helper,
401 .maxlen = HOTPLUG_PATH_LEN, 403 .maxlen = UEVENT_HELPER_PATH_LEN,
402 .mode = 0644, 404 .mode = 0644,
403 .proc_handler = &proc_dostring, 405 .proc_handler = &proc_dostring,
404 .strategy = &sysctl_string, 406 .strategy = &sysctl_string,
@@ -544,7 +546,7 @@ static ctl_table kern_table[] = {
544 .extra1 = &minolduid, 546 .extra1 = &minolduid,
545 .extra2 = &maxolduid, 547 .extra2 = &maxolduid,
546 }, 548 },
547#ifdef CONFIG_ARCH_S390 549#ifdef CONFIG_S390
548#ifdef CONFIG_MATHEMU 550#ifdef CONFIG_MATHEMU
549 { 551 {
550 .ctl_name = KERN_IEEE_EMULATION_WARNINGS, 552 .ctl_name = KERN_IEEE_EMULATION_WARNINGS,
@@ -646,7 +648,7 @@ static ctl_table kern_table[] = {
646 .mode = 0644, 648 .mode = 0644,
647 .proc_handler = &proc_dointvec, 649 .proc_handler = &proc_dointvec,
648 }, 650 },
649#if defined(CONFIG_ARCH_S390) 651#if defined(CONFIG_S390) && defined(CONFIG_SMP)
650 { 652 {
651 .ctl_name = KERN_SPIN_RETRY, 653 .ctl_name = KERN_SPIN_RETRY,
652 .procname = "spin_retry", 654 .procname = "spin_retry",
@@ -777,6 +779,15 @@ static ctl_table vm_table[] = {
777 .strategy = &sysctl_intvec, 779 .strategy = &sysctl_intvec,
778 }, 780 },
779 { 781 {
782 .ctl_name = VM_DROP_PAGECACHE,
783 .procname = "drop_caches",
784 .data = &sysctl_drop_caches,
785 .maxlen = sizeof(int),
786 .mode = 0644,
787 .proc_handler = drop_caches_sysctl_handler,
788 .strategy = &sysctl_intvec,
789 },
790 {
780 .ctl_name = VM_MIN_FREE_KBYTES, 791 .ctl_name = VM_MIN_FREE_KBYTES,
781 .procname = "min_free_kbytes", 792 .procname = "min_free_kbytes",
782 .data = &min_free_kbytes, 793 .data = &min_free_kbytes,
@@ -786,6 +797,16 @@ static ctl_table vm_table[] = {
786 .strategy = &sysctl_intvec, 797 .strategy = &sysctl_intvec,
787 .extra1 = &zero, 798 .extra1 = &zero,
788 }, 799 },
800 {
801 .ctl_name = VM_PERCPU_PAGELIST_FRACTION,
802 .procname = "percpu_pagelist_fraction",
803 .data = &percpu_pagelist_fraction,
804 .maxlen = sizeof(percpu_pagelist_fraction),
805 .mode = 0644,
806 .proc_handler = &percpu_pagelist_fraction_sysctl_handler,
807 .strategy = &sysctl_intvec,
808 .extra1 = &min_percpu_pagelist_fract,
809 },
789#ifdef CONFIG_MMU 810#ifdef CONFIG_MMU
790 { 811 {
791 .ctl_name = VM_MAX_MAP_COUNT, 812 .ctl_name = VM_MAX_MAP_COUNT,
@@ -849,6 +870,17 @@ static ctl_table vm_table[] = {
849 .strategy = &sysctl_jiffies, 870 .strategy = &sysctl_jiffies,
850 }, 871 },
851#endif 872#endif
873#ifdef CONFIG_NUMA
874 {
875 .ctl_name = VM_ZONE_RECLAIM_MODE,
876 .procname = "zone_reclaim_mode",
877 .data = &zone_reclaim_mode,
878 .maxlen = sizeof(zone_reclaim_mode),
879 .mode = 0644,
880 .proc_handler = &proc_dointvec,
881 .strategy = &zero,
882 },
883#endif
852 { .ctl_name = 0 } 884 { .ctl_name = 0 }
853}; 885};
854 886
@@ -2192,29 +2224,32 @@ int sysctl_string(ctl_table *table, int __user *name, int nlen,
2192 void __user *oldval, size_t __user *oldlenp, 2224 void __user *oldval, size_t __user *oldlenp,
2193 void __user *newval, size_t newlen, void **context) 2225 void __user *newval, size_t newlen, void **context)
2194{ 2226{
2195 size_t l, len;
2196
2197 if (!table->data || !table->maxlen) 2227 if (!table->data || !table->maxlen)
2198 return -ENOTDIR; 2228 return -ENOTDIR;
2199 2229
2200 if (oldval && oldlenp) { 2230 if (oldval && oldlenp) {
2201 if (get_user(len, oldlenp)) 2231 size_t bufsize;
2232 if (get_user(bufsize, oldlenp))
2202 return -EFAULT; 2233 return -EFAULT;
2203 if (len) { 2234 if (bufsize) {
2204 l = strlen(table->data); 2235 size_t len = strlen(table->data), copied;
2205 if (len > l) len = l; 2236
2206 if (len >= table->maxlen) 2237 /* This shouldn't trigger for a well-formed sysctl */
2238 if (len > table->maxlen)
2207 len = table->maxlen; 2239 len = table->maxlen;
2208 if(copy_to_user(oldval, table->data, len)) 2240
2209 return -EFAULT; 2241 /* Copy up to a max of bufsize-1 bytes of the string */
2210 if(put_user(0, ((char __user *) oldval) + len)) 2242 copied = (len >= bufsize) ? bufsize - 1 : len;
2243
2244 if (copy_to_user(oldval, table->data, copied) ||
2245 put_user(0, (char __user *)(oldval + copied)))
2211 return -EFAULT; 2246 return -EFAULT;
2212 if(put_user(len, oldlenp)) 2247 if (put_user(len, oldlenp))
2213 return -EFAULT; 2248 return -EFAULT;
2214 } 2249 }
2215 } 2250 }
2216 if (newval && newlen) { 2251 if (newval && newlen) {
2217 len = newlen; 2252 size_t len = newlen;
2218 if (len > table->maxlen) 2253 if (len > table->maxlen)
2219 len = table->maxlen; 2254 len = table->maxlen;
2220 if(copy_from_user(table->data, newval, len)) 2255 if(copy_from_user(table->data, newval, len))
@@ -2223,7 +2258,7 @@ int sysctl_string(ctl_table *table, int __user *name, int nlen,
2223 len--; 2258 len--;
2224 ((char *) table->data)[len] = 0; 2259 ((char *) table->data)[len] = 0;
2225 } 2260 }
2226 return 0; 2261 return 1;
2227} 2262}
2228 2263
2229/* 2264/*