From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Brian Foster <bfoster@redhat.com>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH 3/3] xfs: check _alloc_read_agf buffer pointer before using
Date: Wed, 19 Jul 2017 08:48:41 -0700 [thread overview]
Message-ID: <20170719154841.GN4224@magnolia> (raw)
In-Reply-To: <20170719132032.GC54534@bfoster.bfoster>
On Wed, Jul 19, 2017 at 09:20:32AM -0400, Brian Foster wrote:
> On Tue, Jul 18, 2017 at 11:24:28AM -0700, Darrick J. Wong wrote:
> > From: Darrick J. Wong <darrick.wong@oracle.com>
> >
> > In some circumstances, _alloc_read_agf can return an error code of zero
> > but also a null AGF buffer pointer. Check for this and jump out.
> >
>
> It looks like this is only possible in trylock cases. Otherwise (and
> unless I'm missing something), it should always return a buffer or
> error.
>
> This is circuitous regardless and so seems fine if it shuts up a
> coverity warning:
<shrug> I argue it's also defensive, in case we ever /do/ change the
semantics to allow more "zero return and no bp" cases, then these parts
won't suddenly start blowing up.
I think the Coverity analysis is just plain wrong (it claims that we can
somehow corrupt return values to end up with a zero return having
started with -EIO) but I did spot the trylock case and figured we could
be defensive about that.
--D
> Reviewed-by: Brian Foster <bfoster@redhat.com>
>
> > Fixes-coverity-id: 1415250
> > Fixes-coverity-id: 1415320
> > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> > ---
> > fs/xfs/libxfs/xfs_refcount.c | 4 ++++
> > fs/xfs/xfs_reflink.c | 2 ++
> > 2 files changed, 6 insertions(+)
> >
> >
> > diff --git a/fs/xfs/libxfs/xfs_refcount.c b/fs/xfs/libxfs/xfs_refcount.c
> > index 900ea23..45b1c3b 100644
> > --- a/fs/xfs/libxfs/xfs_refcount.c
> > +++ b/fs/xfs/libxfs/xfs_refcount.c
> > @@ -1638,6 +1638,10 @@ xfs_refcount_recover_cow_leftovers(
> > error = xfs_alloc_read_agf(mp, tp, agno, 0, &agbp);
> > if (error)
> > goto out_trans;
> > + if (!agbp) {
> > + error = -ENOMEM;
> > + goto out_trans;
> > + }
> > cur = xfs_refcountbt_init_cursor(mp, tp, agbp, agno, NULL);
> >
> > /* Find all the leftover CoW staging extents. */
> > diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c
> > index d9b3d57..f45fbf0 100644
> > --- a/fs/xfs/xfs_reflink.c
> > +++ b/fs/xfs/xfs_reflink.c
> > @@ -170,6 +170,8 @@ xfs_reflink_find_shared(
> > error = xfs_alloc_read_agf(mp, tp, agno, 0, &agbp);
> > if (error)
> > return error;
> > + if (!agbp)
> > + return -ENOMEM;
> >
> > cur = xfs_refcountbt_init_cursor(mp, tp, agbp, agno, NULL);
> >
> >
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at http://vger.kernel.org/majordomo-info.html
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2017-07-19 15:48 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-18 18:24 [PATCH 1/3] xfs: check _btree_check_block value Darrick J. Wong
2017-07-18 18:24 ` [PATCH 2/3] xfs: set firstfsb to NULLFSBLOCK before feeding it to _bmapi_write Darrick J. Wong
2017-07-19 13:20 ` Brian Foster
2017-07-19 15:39 ` Darrick J. Wong
2017-07-19 16:10 ` Brian Foster
2017-07-18 18:24 ` [PATCH 3/3] xfs: check _alloc_read_agf buffer pointer before using Darrick J. Wong
2017-07-19 13:20 ` Brian Foster
2017-07-19 15:48 ` Darrick J. Wong [this message]
2017-07-19 13:20 ` [PATCH 1/3] xfs: check _btree_check_block value Brian Foster
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=20170719154841.GN4224@magnolia \
--to=darrick.wong@oracle.com \
--cc=bfoster@redhat.com \
--cc=linux-xfs@vger.kernel.org \
/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