Commit b431aa18 authored by Rusty Russell's avatar Rusty Russell Committed by Linus Torvalds

[PATCH] fix sysfs node cpumap for large NR_CPUS

As pointed out by Paul Jackson <pj@sgi.com>, sometimes 99 chars is not enough.
We currently get a page from sysfs: that code should check we haven't overrun
it.
Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
Signed-off-by: default avatarPaul Jackson <pj@sgi.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent d4a006b9
......@@ -21,9 +21,10 @@ static ssize_t node_read_cpumap(struct sys_device * dev, char * buf)
cpumask_t mask = node_dev->cpumap;
int len;
/* FIXME - someone should pass us a buffer size (count) or
* use seq_file or something to avoid buffer overrun risk. */
len = cpumask_scnprintf(buf, 99 /* XXX FIXME */, mask);
/* 2004/06/03: buf currently PAGE_SIZE, need > 1 char per 4 bits. */
BUILD_BUG_ON(NR_CPUS/4 > PAGE_SIZE/2);
len = cpumask_scnprintf(buf, PAGE_SIZE-1, mask);
len += sprintf(buf + len, "\n");
return len;
}
......
......@@ -89,6 +89,7 @@ static int fill_read_buffer(struct file * file, struct sysfs_buffer * buffer)
return -ENOMEM;
count = ops->show(kobj,attr,buffer->page);
BUG_ON(count > PAGE_SIZE);
if (count >= 0)
buffer->count = count;
else
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment