aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc
diff options
context:
space:
mode:
authorJoel Stanley <joel@jms.id.au>2014-04-24 16:55:37 +0930
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2014-04-28 13:08:49 +1000
commit63aecfb20a6629f1ca91d7a052f87988ceb6dd53 (patch)
tree1f4985bfd80fe769b9916b179ddbfb12ba919393 /arch/powerpc
parentpowerpc/powernv: Fix typos in sysparam code (diff)
downloadlinux-dev-63aecfb20a6629f1ca91d7a052f87988ceb6dd53.tar.xz
linux-dev-63aecfb20a6629f1ca91d7a052f87988ceb6dd53.zip
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>
Diffstat (limited to 'arch/powerpc')
-rw-r--r--arch/powerpc/platforms/powernv/opal-sysparam.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/arch/powerpc/platforms/powernv/opal-sysparam.c b/arch/powerpc/platforms/powernv/opal-sysparam.c
index c59e77a84721..d202f9bc3683 100644
--- a/arch/powerpc/platforms/powernv/opal-sysparam.c
+++ b/arch/powerpc/platforms/powernv/opal-sysparam.c
@@ -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];