Implement ->proc_write_buf() so procfs copies in what is written before it pins the entry, and take the multiplier from that copy. Writes larger than PAGE_SIZE - 1 bytes fail with -EINVAL now. Signed-off-by: Christian Brauner (Amutable) --- kernel/profile.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/kernel/profile.c b/kernel/profile.c index 820d5ec909d4..dc2db66a77d2 100644 --- a/kernel/profile.c +++ b/kernel/profile.c @@ -189,16 +189,14 @@ int __weak setup_profiling_timer(unsigned mult) * Writing a 'profiling multiplier' value into it also re-sets the profiling * interrupt frequency, on architectures that support this. */ -static ssize_t write_profile(struct file *file, const char __user *buf, - size_t count, loff_t *ppos) +static ssize_t write_profile(struct file *file, char *buf, size_t count, + loff_t *ppos) { #ifdef CONFIG_SMP if (count == sizeof(int)) { unsigned int multiplier; - if (copy_from_user(&multiplier, buf, sizeof(int))) - return -EFAULT; - + memcpy(&multiplier, buf, sizeof(int)); if (setup_profiling_timer(multiplier)) return -EINVAL; } @@ -209,7 +207,7 @@ static ssize_t write_profile(struct file *file, const char __user *buf, static const struct proc_ops profile_proc_ops = { .proc_read = read_profile, - .proc_write = write_profile, + .proc_write_buf = write_profile, .proc_lseek = default_llseek, }; -- 2.53.0