提交 df11f6c5 编写于 作者: A Andy Shevchenko

platform/x86: thinkpad_acpi: Revert "Use strndup_user() in dispatch_proc_write()"

This reverts commit 35d13c7a.

This broke procfs interface due to neglecting the fact that
the strings are not coming NULL terminated.

Revert the change till we will have a better clean up.

Fixes: 35d13c7a ("platform/x86: thinkpad_acpi: Use strndup_user() in dispatch_proc_write()")
Reported-by: NHans de Goede <hdegoede@redhat.com>
Signed-off-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com>
上级 13bceda6
......@@ -885,11 +885,19 @@ static ssize_t dispatch_proc_write(struct file *file,
if (!ibm || !ibm->write)
return -EINVAL;
if (count > PAGE_SIZE - 1)
return -EINVAL;
kernbuf = kmalloc(count + 1, GFP_KERNEL);
if (!kernbuf)
return -ENOMEM;
kernbuf = strndup_user(userbuf, PAGE_SIZE);
if (IS_ERR(kernbuf))
return PTR_ERR(kernbuf);
if (copy_from_user(kernbuf, userbuf, count)) {
kfree(kernbuf);
return -EFAULT;
}
kernbuf[count] = 0;
ret = ibm->write(kernbuf);
if (ret == 0)
ret = count;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册