Commit fc3501d411d34823fb9be248a95a0c44f945866f
Committed by
Linus Torvalds
1 parent
35887b1cf7
Exists in
master
and in
20 other branches
mm: fix dirty_bytes/dirty_background_bytes sysctls on 64bit arches
We need to pass an unsigned long as the minimum, because it gets casted to an unsigned long in the sysctl handler. If we pass an int, we'll access four more bytes on 64bit arches, resulting in a random minimum value. [rientjes@google.com: fix type of `old_bytes'] Signed-off-by: Sven Wegener <sven.wegener@stealer.net> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Dave Chinner <david@fromorbit.com> Cc: Christoph Lameter <cl@linux-foundation.org> Cc: David Rientjes <rientjes@google.com> Signed-off-by: David Rientjes <rientjes@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Showing 2 changed files with 4 additions and 3 deletions Side-by-side Diff
kernel/sysctl.c
... | ... | @@ -101,6 +101,7 @@ |
101 | 101 | |
102 | 102 | static int zero; |
103 | 103 | static int one = 1; |
104 | +static unsigned long one_ul = 1; | |
104 | 105 | static int one_hundred = 100; |
105 | 106 | |
106 | 107 | /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */ |
... | ... | @@ -974,7 +975,7 @@ |
974 | 975 | .mode = 0644, |
975 | 976 | .proc_handler = &dirty_background_bytes_handler, |
976 | 977 | .strategy = &sysctl_intvec, |
977 | - .extra1 = &one, | |
978 | + .extra1 = &one_ul, | |
978 | 979 | }, |
979 | 980 | { |
980 | 981 | .ctl_name = VM_DIRTY_RATIO, |
... | ... | @@ -995,7 +996,7 @@ |
995 | 996 | .mode = 0644, |
996 | 997 | .proc_handler = &dirty_bytes_handler, |
997 | 998 | .strategy = &sysctl_intvec, |
998 | - .extra1 = &one, | |
999 | + .extra1 = &one_ul, | |
999 | 1000 | }, |
1000 | 1001 | { |
1001 | 1002 | .procname = "dirty_writeback_centisecs", |
mm/page-writeback.c
... | ... | @@ -209,7 +209,7 @@ |
209 | 209 | struct file *filp, void __user *buffer, size_t *lenp, |
210 | 210 | loff_t *ppos) |
211 | 211 | { |
212 | - int old_bytes = vm_dirty_bytes; | |
212 | + unsigned long old_bytes = vm_dirty_bytes; | |
213 | 213 | int ret; |
214 | 214 | |
215 | 215 | ret = proc_doulongvec_minmax(table, write, filp, buffer, lenp, ppos); |