summaryrefslogtreecommitdiff
path: root/mm
diff options
context:
space:
mode:
authorHan Pingtian <hanpt@linux.vnet.ibm.com>2014-08-28 19:34:12 +0100
committerJiri Slaby <jslaby@suse.cz>2014-09-26 11:51:50 +0200
commit73210d0adac4c6f283eb825e85febdc12dbd3e36 (patch)
tree65e110487ea501cff2e1842e2547f69fd535f12d /mm
parent3ddc614ca27c84a91d3b51ab57e50c68fdf4889b (diff)
mm: prevent setting of a value less than 0 to min_free_kbytes
commit da8c757b080ee84f219fa2368cb5dd23ac304fc0 upstream. If echo -1 > /proc/vm/sys/min_free_kbytes, the system will hang. Changing proc_dointvec() to proc_dointvec_minmax() in the min_free_kbytes_sysctl_handler() can prevent this to happen. mhocko said: : You can still do echo $BIG_VALUE > /proc/vm/sys/min_free_kbytes and make : your machine unusable but I agree that proc_dointvec_minmax is more : suitable here as we already have: : : .proc_handler = min_free_kbytes_sysctl_handler, : .extra1 = &zero, : : It used to work properly but then 6fce56ec91b5 ("sysctl: Remove references : to ctl_name and strategy from the generic sysctl table") has removed : sysctl_intvec strategy and so extra1 is ignored. Signed-off-by: Han Pingtian <hanpt@linux.vnet.ibm.com> Acked-by: Michal Hocko <mhocko@suse.cz> Acked-by: David Rientjes <rientjes@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Mel Gorman <mgorman@suse.de> Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Diffstat (limited to 'mm')
-rw-r--r--mm/page_alloc.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index a280f772bc66..95f20173abba 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -5734,7 +5734,12 @@ module_init(init_per_zone_wmark_min)
int min_free_kbytes_sysctl_handler(ctl_table *table, int write,
void __user *buffer, size_t *length, loff_t *ppos)
{
- proc_dointvec(table, write, buffer, length, ppos);
+ int rc;
+
+ rc = proc_dointvec_minmax(table, write, buffer, length, ppos);
+ if (rc)
+ return rc;
+
if (write) {
user_min_free_kbytes = min_free_kbytes;
setup_per_zone_wmarks();