summaryrefslogtreecommitdiff
path: root/arch
diff options
context:
space:
mode:
authorJoel Stanley <joel@jms.id.au>2014-04-24 07:25:35 (GMT)
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2014-04-28 03:08:48 (GMT)
commit85390378f0a6abf3bdb10c3d504d77862a2d0ec9 (patch)
treef4b8f3bec96478f6a5ce0dae9ea0b9ce8ce9b504 /arch
parentb8569d230416c490065098684adf13c1751cb830 (diff)
downloadlinux-85390378f0a6abf3bdb10c3d504d77862a2d0ec9.tar.xz
powerpc/powernv: Check sysfs size before copying
The sysparam code currently uses the userspace supplied number of bytes when memcpy()ing in to a local 64-byte buffer. Limit the maximum number of bytes by the size of the buffer. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'arch')
-rw-r--r--arch/powerpc/platforms/powernv/opal-sysparam.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/arch/powerpc/platforms/powernv/opal-sysparam.c b/arch/powerpc/platforms/powernv/opal-sysparam.c
index 0675e1a..83f5f2a 100644
--- a/arch/powerpc/platforms/powernv/opal-sysparam.c
+++ b/arch/powerpc/platforms/powernv/opal-sysparam.c
@@ -135,6 +135,10 @@ static ssize_t sys_param_store(struct kobject *kobj,
kobj_attr);
ssize_t ret;
+ /* MAX_PARAM_DATA_LEN is sizeof(param_data_buf) */
+ if (count > MAX_PARAM_DATA_LEN)
+ count = MAX_PARAM_DATA_LEN;
+
mutex_lock(&opal_sysparam_mutex);
memcpy(param_data_buf, buf, count);
ret = opal_set_sys_param(attr->param_id, attr->param_size,