Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 85390378 authored by Joel Stanley's avatar Joel Stanley Committed by Benjamin Herrenschmidt
Browse files

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: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
parent b8569d23
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -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,