aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoel Stanley <joel@jms.id.au>2014-04-22 18:38:09 +1000
committerEli Qiao <taget@linux.vnet.ibm.com>2014-04-22 16:55:31 +0800
commitd152a119e53f2b0f95a71e4a3c74a89224be099b (patch)
tree785dafca406153a6285483bc3fe11f294b1b5eea
parenteb198b7a0ed49f7aaa73f87d9ef270302f4aaec8 (diff)
downloadpowerkvm-d152a119e53f2b0f95a71e4a3c74a89224be099b.tar.gz
powerpc/powernv: Check sysparam size before creation
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>
-rw-r--r--arch/powerpc/platforms/powernv/opal-sysparam.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/arch/powerpc/platforms/powernv/opal-sysparam.c b/arch/powerpc/platforms/powernv/opal-sysparam.c
index 7a249f166fdb3..5527e83b27966 100644
--- a/arch/powerpc/platforms/powernv/opal-sysparam.c
+++ b/arch/powerpc/platforms/powernv/opal-sysparam.c
@@ -241,6 +241,11 @@ 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;
+ }
attr[i].param_id = id[i];
attr[i].param_size = size[i];
if (of_property_read_string_index(sysparam, "param-name", i,