@@ -769,21 +769,14 @@ static int __init mconsole_init(void)
__initcall(mconsole_init);
static ssize_t mconsole_proc_write(struct file *file,
- const char __user *buffer, size_t count, loff_t *pos)
+ char *buf, size_t count, loff_t *pos)
{
- char *buf;
-
- buf = memdup_user_nul(buffer, count);
- if (IS_ERR(buf))
- return PTR_ERR(buf);
-
mconsole_notify(notify_socket, MCONSOLE_USER_NOTIFY, buf, count);
- kfree(buf);
return count;
}
static const struct proc_ops mconsole_proc_ops = {
- .proc_write = mconsole_proc_write,
+ .proc_write_buf = mconsole_proc_write,
.proc_lseek = noop_llseek,
};
@@ -32,18 +32,12 @@ static int exitcode_proc_show(struct seq_file *m, void *v)
}
static ssize_t exitcode_proc_write(struct file *file,
- const char __user *buffer, size_t count, loff_t *pos)
+ char *buffer, size_t count, loff_t *pos)
{
- char *end, buf[sizeof("nnnnn\0")];
- size_t size;
+ char *end;
int tmp;
- size = min(count, sizeof(buf) - 1);
- if (copy_from_user(buf, buffer, size))
- return -EFAULT;
- buf[size] = '\0';
-
- tmp = simple_strtol(buf, &end, 0);
+ tmp = simple_strtol(buffer, &end, 0);
if ((*end != '\0') && !isspace(*end))
return -EINVAL;
@@ -53,7 +47,7 @@ static ssize_t exitcode_proc_write(struct file *file,
static const struct proc_ops exitcode_proc_ops = {
.proc_show = exitcode_proc_show,
- .proc_write = exitcode_proc_write,
+ .proc_write_buf = exitcode_proc_write,
};
static int make_proc_exitcode(void)
Implement ->proc_write_buf() for the mconsole and exitcode files so procfs copies in what is written before it pins the entry. Writes larger than PAGE_SIZE - 1 bytes fail with -EINVAL now. exitcode parses procfs' copy as is, so it no longer stops at the first six bytes of what is written. Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org> --- arch/um/drivers/mconsole_kern.c | 11 ++--------- arch/um/kernel/exitcode.c | 14 ++++---------- 2 files changed, 6 insertions(+), 19 deletions(-)