aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetr Holasek <pholasek@redhat.com>2011-03-23 19:43:09 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-03-23 22:46:51 -0400
commitcb16e95fa2996743a6e80a665ed2ed0590bd38cf (patch)
tree7128a7d03a94a68dd9550f33ac66876bf6854ad0
parent256c53a65128cbc8a766b1503f3f25a52a8d07cb (diff)
sysctl: add some missing input constraint checks
Add boundaries of allowed input ranges for: dirty_expire_centisecs, drop_caches, overcommit_memory, page-cluster and panic_on_oom. Signed-off-by: Petr Holasek <pholasek@redhat.com> Acked-by: Dave Young <hidave.darkstar@gmail.com> Cc: David Rientjes <rientjes@google.com> Cc: Wu Fengguang <fengguang.wu@intel.com> Cc: Alexey Dobriyan <adobriyan@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--fs/drop_caches.c6
-rw-r--r--kernel/sysctl.c17
2 files changed, 18 insertions, 5 deletions
diff --git a/fs/drop_caches.c b/fs/drop_caches.c
index 2195c213ab2f..816f88e6b9ce 100644
--- a/fs/drop_caches.c
+++ b/fs/drop_caches.c
@@ -45,7 +45,11 @@ static void drop_slab(void)
45int drop_caches_sysctl_handler(ctl_table *table, int write, 45int drop_caches_sysctl_handler(ctl_table *table, int write,
46 void __user *buffer, size_t *length, loff_t *ppos) 46 void __user *buffer, size_t *length, loff_t *ppos)
47{ 47{
48 proc_dointvec_minmax(table, write, buffer, length, ppos); 48 int ret;
49
50 ret = proc_dointvec_minmax(table, write, buffer, length, ppos);
51 if (ret)
52 return ret;
49 if (write) { 53 if (write) {
50 if (sysctl_drop_caches & 1) 54 if (sysctl_drop_caches & 1)
51 iterate_supers(drop_pagecache_sb, NULL); 55 iterate_supers(drop_pagecache_sb, NULL);
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 40245d697602..97ab1690f5ed 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -117,6 +117,7 @@ static int neg_one = -1;
117static int zero; 117static int zero;
118static int __maybe_unused one = 1; 118static int __maybe_unused one = 1;
119static int __maybe_unused two = 2; 119static int __maybe_unused two = 2;
120static int __maybe_unused three = 3;
120static unsigned long one_ul = 1; 121static unsigned long one_ul = 1;
121static int one_hundred = 100; 122static int one_hundred = 100;
122#ifdef CONFIG_PRINTK 123#ifdef CONFIG_PRINTK
@@ -971,14 +972,18 @@ static struct ctl_table vm_table[] = {
971 .data = &sysctl_overcommit_memory, 972 .data = &sysctl_overcommit_memory,
972 .maxlen = sizeof(sysctl_overcommit_memory), 973 .maxlen = sizeof(sysctl_overcommit_memory),
973 .mode = 0644, 974 .mode = 0644,
974 .proc_handler = proc_dointvec, 975 .proc_handler = proc_dointvec_minmax,
976 .extra1 = &zero,
977 .extra2 = &two,
975 }, 978 },
976 { 979 {
977 .procname = "panic_on_oom", 980 .procname = "panic_on_oom",
978 .data = &sysctl_panic_on_oom, 981 .data = &sysctl_panic_on_oom,
979 .maxlen = sizeof(sysctl_panic_on_oom), 982 .maxlen = sizeof(sysctl_panic_on_oom),
980 .mode = 0644, 983 .mode = 0644,
981 .proc_handler = proc_dointvec, 984 .proc_handler = proc_dointvec_minmax,
985 .extra1 = &zero,
986 .extra2 = &two,
982 }, 987 },
983 { 988 {
984 .procname = "oom_kill_allocating_task", 989 .procname = "oom_kill_allocating_task",
@@ -1006,7 +1011,8 @@ static struct ctl_table vm_table[] = {
1006 .data = &page_cluster, 1011 .data = &page_cluster,
1007 .maxlen = sizeof(int), 1012 .maxlen = sizeof(int),
1008 .mode = 0644, 1013 .mode = 0644,
1009 .proc_handler = proc_dointvec, 1014 .proc_handler = proc_dointvec_minmax,
1015 .extra1 = &zero,
1010 }, 1016 },
1011 { 1017 {
1012 .procname = "dirty_background_ratio", 1018 .procname = "dirty_background_ratio",
@@ -1054,7 +1060,8 @@ static struct ctl_table vm_table[] = {
1054 .data = &dirty_expire_interval, 1060 .data = &dirty_expire_interval,
1055 .maxlen = sizeof(dirty_expire_interval), 1061 .maxlen = sizeof(dirty_expire_interval),
1056 .mode = 0644, 1062 .mode = 0644,
1057 .proc_handler = proc_dointvec, 1063 .proc_handler = proc_dointvec_minmax,
1064 .extra1 = &zero,
1058 }, 1065 },
1059 { 1066 {
1060 .procname = "nr_pdflush_threads", 1067 .procname = "nr_pdflush_threads",
@@ -1130,6 +1137,8 @@ static struct ctl_table vm_table[] = {
1130 .maxlen = sizeof(int), 1137 .maxlen = sizeof(int),
1131 .mode = 0644, 1138 .mode = 0644,
1132 .proc_handler = drop_caches_sysctl_handler, 1139 .proc_handler = drop_caches_sysctl_handler,
1140 .extra1 = &one,
1141 .extra2 = &three,
1133 }, 1142 },
1134#ifdef CONFIG_COMPACTION 1143#ifdef CONFIG_COMPACTION
1135 { 1144 {