Skip to content

Commit

Permalink
powerpc/powernv: Check sysparam size before creation
Browse files Browse the repository at this point in the history
The size of the sysparam sysfs files is determined from the device tree
at boot. However the buffer is hard coded to 64 bytes. If we encounter a
parameter that is larger than 64, or miss-parse the device tree, the
buffer will overflow when reading or writing to the parameter.

Check it at discovery time, and if the parameter is too large, do not
create a sysfs entry for it.

Signed-off-by: Joel Stanley <joel@jms.id.au>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
  • Loading branch information
Joel Stanley authored and Benjamin Herrenschmidt committed Apr 28, 2014
1 parent 16003d2 commit 63aecfb
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions arch/powerpc/platforms/powernv/opal-sysparam.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,12 @@ void __init opal_sys_param_init(void)

/* For each of the parameters, populate the parameter attributes */
for (i = 0; i < count; i++) {
if (size[i] > MAX_PARAM_DATA_LEN) {
pr_warn("SYSPARAM: Not creating parameter %d as size "
"exceeds buffer length\n", i);
continue;
}

sysfs_attr_init(&attr[i].kobj_attr.attr);
attr[i].param_id = id[i];
attr[i].param_size = size[i];
Expand Down

0 comments on commit 63aecfb

Please sign in to comment.