From: Jan Kara <jack@suse.cz>
To: Amir Goldstein <amir73il@gmail.com>
Cc: Su Hui <suhui@nfschina.com>,
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: Tue, 2 Jan 2024 14:47:51 +0100 [thread overview]
Message-ID: <20240102134751.2flliwe4lfvp3r5a@quack3> (raw)
In-Reply-To: <CAOQ4uxhtZSr-kq3G1vmm4=GyBO3E5RdSbGSp108moRiRBx4vvg@mail.gmail.com>
On Thu 10-08-23 20:58:16, Amir Goldstein wrote:
> 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>
I'm sorry but this has somehow fallen through the cracks.
> > 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;
Well, if passed 'fh' is NULL, we have problems later in the function
anyway. E.g. in fanotify_fh_buf() a few lines below. So I think this needs
a bit more work that just this small fixup...
Honza
> >
> > /* 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
> >
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
prev parent reply other threads:[~2024-01-02 13:47 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
2024-01-02 13:47 ` Jan Kara [this message]
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=20240102134751.2flliwe4lfvp3r5a@quack3 \
--to=jack@suse.cz \
--cc=amir73il@gmail.com \
--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).