mm: prevent set a value less than 0 to min_free_kbytes
Subsystems (2)
RFC 1/1 mm: prevent set 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.
--- mm/page_alloc.c | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-)
mm/page_alloc.c +6 -1
@@ -5692,7 +5692,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 ();
Signature · 7 lines
1.7.7.6 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 3 lines · Han Pingtian
If echo -1 >
/proc/vm/sys/min_free_kbytes, the system will hang. Changingproc_dointvec()toproc_dointvec_minmax()in themin_free_kbytes_sysctl_handler()can prevent this to happen.
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.
Quoted 1 line
Signed-off-by Han Pingtian <[email protected]>
That being said I do not think this will fix any real world problem but just for sake of correctness
After changelog is updated feel free to add my
Quoted 25 lines
--- mm/page_alloc.c | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-)mm/page_alloc.c +6
-1@@ -5692,7 +5692,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 ();Signature · 1 line
1.7.7.6
Signature · 8 lines
Michal Hocko SUSE Labs -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 5 lines · Han Pingtian
If echo -1 >
/proc/vm/sys/min_free_kbytes, the system will hang. Changingproc_dointvec()toproc_dointvec_minmax()in themin_free_kbytes_sysctl_handler()can prevent this to happen.Signed-off-by Han Pingtian <[email protected]>
Nice catch!
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>