Implement ->proc_write_buf() so procfs copies in what is written to the
alignment files before it pins the entry, and take the mode from that
copy. Writes larger than PAGE_SIZE - 1 bytes fail with -EINVAL now.

Signed-off-by: Christian Brauner (Amutable) <[email protected]>
---
 arch/sh/mm/alignment.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/arch/sh/mm/alignment.c b/arch/sh/mm/alignment.c
index 2198c6f2ea63..d832249a8e18 100644
--- a/arch/sh/mm/alignment.c
+++ b/arch/sh/mm/alignment.c
@@ -133,14 +133,13 @@ static int alignment_proc_show(struct seq_file *m, void 
*v)
 }
 
 static ssize_t alignment_proc_write(struct file *file,
-               const char __user *buffer, size_t count, loff_t *pos)
+               char *buffer, size_t count, loff_t *pos)
 {
        int *data = pde_data(file_inode(file));
        char mode;
 
        if (count > 0) {
-               if (get_user(mode, buffer))
-                       return -EFAULT;
+               mode = buffer[0];
                if (mode >= '0' && mode <= '5')
                        *data = mode - '0';
        }
@@ -149,7 +148,7 @@ static ssize_t alignment_proc_write(struct file *file,
 
 static const struct proc_ops alignment_proc_ops = {
        .proc_show      = alignment_proc_show,
-       .proc_write     = alignment_proc_write,
+       .proc_write_buf = alignment_proc_write,
 };
 
 /*

-- 
2.53.0

Reply via email to