[PATCH RFC 21/22] PNP: pnpbios: let procfs copy in writes
From: Christian Brauner
Date: Mon Nov 02 2026 - 12:42:18 EST
Implement ->proc_write_buf() so procfs copies in what is written to
/proc/bus/pnp/<node> before it pins the entry, and take the node data
from that copy. A node with more than PAGE_SIZE - 1 bytes of data can't
be written anymore. I don't think there are any.
Signed-off-by: Christian Brauner (Amutable) <brauner@xxxxxxxxxx>
---
drivers/pnp/pnpbios/proc.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/drivers/pnp/pnpbios/proc.c b/drivers/pnp/pnpbios/proc.c
index 14632a8d0da0..00163aedd738 100644
--- a/drivers/pnp/pnpbios/proc.c
+++ b/drivers/pnp/pnpbios/proc.c
@@ -171,7 +171,7 @@ static int pnpbios_proc_show(struct seq_file *m, void *v)
return 0;
}
-static ssize_t pnpbios_proc_write(struct file *file, const char __user *buf,
+static ssize_t pnpbios_proc_write(struct file *file, char *buf,
size_t count, loff_t *pos)
{
void *data = pde_data(file_inode(file));
@@ -191,10 +191,7 @@ static ssize_t pnpbios_proc_write(struct file *file, const char __user *buf,
ret = -EINVAL;
goto out;
}
- if (copy_from_user(node->data, buf, count)) {
- ret = -EFAULT;
- goto out;
- }
+ memcpy(node->data, buf, count);
if (pnp_bios_set_dev_node(node->handle, boot, node) != 0) {
ret = -EINVAL;
goto out;
@@ -207,7 +204,7 @@ out:
static const struct proc_ops pnpbios_proc_ops = {
.proc_show = pnpbios_proc_show,
- .proc_write = pnpbios_proc_write,
+ .proc_write_buf = pnpbios_proc_write,
};
int pnpbios_interface_attach_device(struct pnp_bios_node *node)
--
2.53.0