[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2023051659-sinless-lemon-e3b1@gregkh>
Date: Tue, 16 May 2023 18:33:08 +0200
From: Greg KH <gregkh@...uxfoundation.org>
To: Richard Fitzgerald <rf@...nsource.cirrus.com>
Cc: rafael@...nel.org, linux-kernel@...r.kernel.org,
patches@...nsource.cirrus.com
Subject: Re: [PATCH 1/5] debugfs: Prevent NULL dereference reading from
string property
On Tue, May 16, 2023 at 05:07:49PM +0100, Richard Fitzgerald wrote:
> Check in debugfs_read_file_str() if the string pointer is NULL.
>
> It is perfectly reasonable that a driver may wish to export a string
> to debugfs that can have the value NULL to indicate empty/unused/ignore.
Does any in-kernel driver do this today?
If not, why not fix up the driver instead?
>
> Signed-off-by: Richard Fitzgerald <rf@...nsource.cirrus.com>
> ---
> fs/debugfs/file.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/fs/debugfs/file.c b/fs/debugfs/file.c
> index 1f971c880dde..2c085ab4e800 100644
> --- a/fs/debugfs/file.c
> +++ b/fs/debugfs/file.c
> @@ -878,6 +878,9 @@ ssize_t debugfs_read_file_str(struct file *file, char __user *user_buf,
> return ret;
>
> str = *(char **)file->private_data;
> + if (!str)
> + return simple_read_from_buffer(user_buf, count, ppos, "\n", 1);
Why not print "(NULL)"?
thanks,
greg k-h
Powered by blists - more mailing lists