Skip to content

Commit

Permalink
platform/x86: thinkpad_acpi: Revert "Use strndup_user() in dispatch_p…
Browse files Browse the repository at this point in the history
…roc_write()"

This reverts commit 35d13c7.

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: 35d13c7 ("platform/x86: thinkpad_acpi: Use strndup_user() in dispatch_proc_write()")
Reported-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
  • Loading branch information
Andy Shevchenko committed Jul 15, 2020
1 parent 13bceda commit df11f6c
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions drivers/platform/x86/thinkpad_acpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit df11f6c

Please sign in to comment.