[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAOQ4uxhtZSr-kq3G1vmm4=GyBO3E5RdSbGSp108moRiRBx4vvg@mail.gmail.com>
Date: Thu, 10 Aug 2023 20:58:16 +0300
From: Amir Goldstein <amir73il@...il.com>
To: Su Hui <suhui@...china.com>
Cc: jack@...e.cz, repnop@...gle.com, linux-fsdevel@...r.kernel.org,
linux-kernel@...r.kernel.org, kernel-janitors@...r.kernel.org
Subject: Re: [PATCH] fanotify: avoid possible NULL dereference
On Tue, Aug 8, 2023 at 12:19 PM Su Hui <suhui@...china.com> wrote:
>
> smatch error:
> fs/notify/fanotify/fanotify_user.c:462 copy_fid_info_to_user():
> we previously assumed 'fh' could be null (see line 421)
>
> Fixes: afc894c784c8 ("fanotify: Store fanotify handles differently")
> Signed-off-by: Su Hui <suhui@...china.com>'
Reviewed-by: Amir Goldstein <amir73il@...il.com>
> ---
> fs/notify/fanotify/fanotify_user.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
> index f69c451018e3..5a5487ae2460 100644
> --- a/fs/notify/fanotify/fanotify_user.c
> +++ b/fs/notify/fanotify/fanotify_user.c
> @@ -459,12 +459,13 @@ static int copy_fid_info_to_user(__kernel_fsid_t *fsid, struct fanotify_fh *fh,
> if (WARN_ON_ONCE(len < sizeof(handle)))
> return -EFAULT;
>
> - handle.handle_type = fh->type;
> handle.handle_bytes = fh_len;
>
> /* Mangle handle_type for bad file_handle */
> if (!fh_len)
> handle.handle_type = FILEID_INVALID;
> + else
> + handle.handle_type = fh->type;
>
> if (copy_to_user(buf, &handle, sizeof(handle)))
> return -EFAULT;
> --
> 2.30.2
>
Powered by blists - more mailing lists