diff options
author | Han Pingtian <hanpt@linux.vnet.ibm.com> | 2014-01-23 18:53:17 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-01-23 19:36:52 -0500 |
commit | da8c757b080ee84f219fa2368cb5dd23ac304fc0 (patch) | |
tree | c6a351683151f272a488e0fc379653a1b259e64f /mm/page_alloc.c | |
parent | cc81717ed3bc6d4f3738d13a1e097437caada0e9 (diff) |
mm: prevent setting of a value less than 0 to min_free_kbytes
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>
Diffstat (limited to 'mm/page_alloc.c')
-rw-r--r-- | mm/page_alloc.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/mm/page_alloc.c b/mm/page_alloc.c index f18f016cca80..a818d568ddf3 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c | |||
@@ -5754,7 +5754,12 @@ module_init(init_per_zone_wmark_min) | |||
5754 | int min_free_kbytes_sysctl_handler(ctl_table *table, int write, | 5754 | int min_free_kbytes_sysctl_handler(ctl_table *table, int write, |
5755 | void __user *buffer, size_t *length, loff_t *ppos) | 5755 | void __user *buffer, size_t *length, loff_t *ppos) |
5756 | { | 5756 | { |
5757 | proc_dointvec(table, write, buffer, length, ppos); | 5757 | int rc; |
5758 | |||
5759 | rc = proc_dointvec_minmax(table, write, buffer, length, ppos); | ||
5760 | if (rc) | ||
5761 | return rc; | ||
5762 | |||
5758 | if (write) { | 5763 | if (write) { |
5759 | user_min_free_kbytes = min_free_kbytes; | 5764 | user_min_free_kbytes = min_free_kbytes; |
5760 | setup_per_zone_wmarks(); | 5765 | setup_per_zone_wmarks(); |