linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Amir Goldstein <amir73il@gmail.com>
To: Su Hui <suhui@nfschina.com>
Cc: jack@suse.cz, repnop@google.com, linux-fsdevel@vger.kernel.org,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] fanotify: avoid possible NULL dereference
Date: Thu, 10 Aug 2023 20:58:16 +0300	[thread overview]
Message-ID: <CAOQ4uxhtZSr-kq3G1vmm4=GyBO3E5RdSbGSp108moRiRBx4vvg@mail.gmail.com> (raw)
In-Reply-To: <20230808091849.505809-1-suhui@nfschina.com>

On Tue, Aug 8, 2023 at 12:19 PM Su Hui <suhui@nfschina.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@nfschina.com>'

Reviewed-by: Amir Goldstein <amir73il@gmail.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
>

  reply	other threads:[~2023-08-10 17:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-08  9:18 [PATCH] fanotify: avoid possible NULL dereference Su Hui
2023-08-10 17:58 ` Amir Goldstein [this message]
2024-01-02 13:47   ` Jan Kara

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAOQ4uxhtZSr-kq3G1vmm4=GyBO3E5RdSbGSp108moRiRBx4vvg@mail.gmail.com' \
    --to=amir73il@gmail.com \
    --cc=jack@suse.cz \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=repnop@google.com \
    --cc=suhui@nfschina.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).