[PATCH RESEND v2 20/23] platform/x86: thinkpad_acpi: let procfs copy in writes
From: Christian Brauner
Date: Wed Nov 04 2026 - 15:49:30 EST
Implement ->proc_write_buf() so procfs copies in what is written to
/proc/acpi/ibm/* before it pins the entry, and hand that copy to
->write(). procfs already rejects writes larger than PAGE_SIZE - 1
bytes.
Signed-off-by: Christian Brauner (Amutable) <brauner@xxxxxxxxxx>
---
drivers/platform/x86/lenovo/thinkpad_acpi.c | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)
diff --git a/drivers/platform/x86/lenovo/thinkpad_acpi.c b/drivers/platform/x86/lenovo/thinkpad_acpi.c
index 2ee208c82801..8287b36bd90d 100644
--- a/drivers/platform/x86/lenovo/thinkpad_acpi.c
+++ b/drivers/platform/x86/lenovo/thinkpad_acpi.c
@@ -882,7 +882,7 @@ static int dispatch_proc_show(struct seq_file *m, void *v)
}
static ssize_t dispatch_proc_write(struct file *file,
- const char __user *userbuf,
+ char *buf,
size_t count, loff_t *pos)
{
struct ibm_struct *ibm = pde_data(file_inode(file));
@@ -890,14 +890,8 @@ static ssize_t dispatch_proc_write(struct file *file,
if (!ibm || !ibm->write)
return -EINVAL;
- if (count > PAGE_SIZE - 1)
- return -EINVAL;
-
- char *kernbuf __free(kfree) = memdup_user_nul(userbuf, count);
- if (IS_ERR(kernbuf))
- return PTR_ERR(kernbuf);
- ret = ibm->write(kernbuf);
+ ret = ibm->write(buf);
if (ret)
return ret;
@@ -906,7 +900,7 @@ static ssize_t dispatch_proc_write(struct file *file,
static const struct proc_ops dispatch_proc_ops = {
.proc_show = dispatch_proc_show,
- .proc_write = dispatch_proc_write,
+ .proc_write_buf = dispatch_proc_write,
};
/****************************************************************************
--
2.53.0