Skip to content

Commit

Permalink
mm: fix dirty_bytes/dirty_background_bytes sysctls on 64bit arches
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Sven Wegener authored and Linus Torvalds committed Feb 11, 2009
1 parent 35887b1 commit fc3501d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions kernel/sysctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ static int two = 2;

static int zero;
static int one = 1;
static unsigned long one_ul = 1;
static int one_hundred = 100;

/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
Expand Down Expand Up @@ -974,7 +975,7 @@ static struct ctl_table vm_table[] = {
.mode = 0644,
.proc_handler = &dirty_background_bytes_handler,
.strategy = &sysctl_intvec,
.extra1 = &one,
.extra1 = &one_ul,
},
{
.ctl_name = VM_DIRTY_RATIO,
Expand All @@ -995,7 +996,7 @@ static struct ctl_table vm_table[] = {
.mode = 0644,
.proc_handler = &dirty_bytes_handler,
.strategy = &sysctl_intvec,
.extra1 = &one,
.extra1 = &one_ul,
},
{
.procname = "dirty_writeback_centisecs",
Expand Down
2 changes: 1 addition & 1 deletion mm/page-writeback.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ int dirty_bytes_handler(struct ctl_table *table, int write,
struct file *filp, void __user *buffer, size_t *lenp,
loff_t *ppos)
{
int old_bytes = vm_dirty_bytes;
unsigned long old_bytes = vm_dirty_bytes;
int ret;

ret = proc_doulongvec_minmax(table, write, filp, buffer, lenp, ppos);
Expand Down

0 comments on commit fc3501d

Please sign in to comment.