Implement ->proc_write_buf() so procfs copies in what is written before it pins the entry, and take the level from that copy. Writes larger than PAGE_SIZE - 1 bytes fail with -EINVAL now and so do empty writes, which looked at a byte that wasn't written before.
Signed-off-by: Christian Brauner (Amutable) <[email protected]> --- fs/jfs/jfs_debug.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/fs/jfs/jfs_debug.c b/fs/jfs/jfs_debug.c index 5eb35b0d420f..e1c0211a6a32 100644 --- a/fs/jfs/jfs_debug.c +++ b/fs/jfs/jfs_debug.c @@ -23,13 +23,10 @@ static int jfs_loglevel_proc_show(struct seq_file *m, void *v) return 0; } -static ssize_t jfs_loglevel_proc_write(struct file *file, - const char __user *buffer, size_t count, loff_t *ppos) +static ssize_t jfs_loglevel_proc_write(struct file *file, char *buffer, + size_t count, loff_t *ppos) { - char c; - - if (get_user(c, buffer)) - return -EFAULT; + char c = buffer[0]; /* yes, I know this is an ASCIIism. --hch */ if (c < '0' || c > '9') @@ -40,7 +37,7 @@ static ssize_t jfs_loglevel_proc_write(struct file *file, static const struct proc_ops jfs_loglevel_proc_ops = { .proc_show = jfs_loglevel_proc_show, - .proc_write = jfs_loglevel_proc_write, + .proc_write_buf = jfs_loglevel_proc_write, }; #endif -- 2.53.0
