Re: [PATCH] debugfs: Fix debugfs_read_file_str()

From: Steven Rostedt
Date: Fri May 28 2021 - 21:51:35 EST


On Thu, 27 May 2021 11:11:05 +0200
Dietmar Eggemann <dietmar.eggemann@xxxxxxx> wrote:

> +++ b/fs/debugfs/file.c
> @@ -893,7 +893,7 @@ ssize_t debugfs_read_file_str(struct file *file, char __user *user_buf,
>
> copy[copy_len] = '\n';
>
> - ret = simple_read_from_buffer(user_buf, count, ppos, copy, copy_len);
> + ret = simple_read_from_buffer(user_buf, count, ppos, copy, len);
> kfree(copy);

As we have:

len = strlen(str) + 1;
[..]
copy_len = strscpy(copy, str, len);

I can't think of any situation that len is not equal to copy_len + 1. :-/

Anyway, either "len" or "copy_len + 1" would work.

Reviewed-by: Steven Rostedt (VMware) <rostedt@xxxxxxxxxxx>

-- Steve