From: Dave Chinner <david@fromorbit.com>
To: "Darrick J. Wong" <darrick.wong@oracle.com>
Cc: xfs <linux-xfs@vger.kernel.org>
Subject: Re: [PATCH] xfs: check that br_blockcount doesn't overflow
Date: Wed, 17 Jan 2018 11:33:04 +1100 [thread overview]
Message-ID: <20180117003304.GB6304@dastard> (raw)
In-Reply-To: <20180116233415.GH5602@magnolia>
On Tue, Jan 16, 2018 at 03:34:15PM -0800, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
>
> xfs_bmbt_irec.br_blockcount is declared as xfs_filblks_t, which is an
> unsigned 64-bit integer. Though the bmbt helpers will never set a value
> larger than 2^21 (since the underlying on-disk extent record has a
> length field that is only 21 bits wide), we should be a little defensive
> about checking that a bmbt record doesn't exceed what we're expecting or
> overflow into the next AG.
>
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
> fs/xfs/scrub/bmap.c | 13 +++++++++----
> 1 file changed, 9 insertions(+), 4 deletions(-)
>
> diff --git a/fs/xfs/scrub/bmap.c b/fs/xfs/scrub/bmap.c
> index 3a815db..fa64bd4 100644
> --- a/fs/xfs/scrub/bmap.c
> +++ b/fs/xfs/scrub/bmap.c
> @@ -348,6 +348,7 @@ xfs_scrub_bmap_extent(
> {
> struct xfs_mount *mp = info->sc->mp;
> struct xfs_buf *bp = NULL;
> + xfs_filblks_t end;
> int error = 0;
>
> if (cur)
> @@ -375,19 +376,23 @@ xfs_scrub_bmap_extent(
> irec->br_startoff);
>
> /* Make sure the extent points to a valid place. */
> + if (irec->br_blockcount > MAXEXTLEN)
> + xfs_scrub_fblock_set_corrupt(info->sc, info->whichfork,
> + irec->br_startoff);
> if (irec->br_startblock + irec->br_blockcount <= irec->br_startblock)
> xfs_scrub_fblock_set_corrupt(info->sc, info->whichfork,
> irec->br_startoff);
> + end = irec->br_startblock + irec->br_blockcount - 1;
> if (info->is_rt &&
> (!xfs_verify_rtbno(mp, irec->br_startblock) ||
> - !xfs_verify_rtbno(mp, irec->br_startblock +
> - irec->br_blockcount - 1)))
> + !xfs_verify_rtbno(mp, end)))
> xfs_scrub_fblock_set_corrupt(info->sc, info->whichfork,
> irec->br_startoff);
> if (!info->is_rt &&
> (!xfs_verify_fsbno(mp, irec->br_startblock) ||
> - !xfs_verify_fsbno(mp, irec->br_startblock +
> - irec->br_blockcount - 1)))
> + !xfs_verify_fsbno(mp, end) ||
> + XFS_FSB_TO_AGNO(mp, irec->br_startblock) !=
> + XFS_FSB_TO_AGNO(mp, end)))
Indent that last part of the check so it's clear the two lines are a
single logic statement:
XFS_FSB_TO_AGNO(mp, irec->br_startblock) !=
XFS_FSB_TO_AGNO(mp, end)))
Otherwise it looks good.
Reviewed-by: Dave Chinner <dchinner@redhat.com>
--
Dave Chinner
david@fromorbit.com
prev parent reply other threads:[~2018-01-17 0:33 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-16 23:34 [PATCH] xfs: check that br_blockcount doesn't overflow Darrick J. Wong
2018-01-17 0:33 ` Dave Chinner [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=20180117003304.GB6304@dastard \
--to=david@fromorbit.com \
--cc=darrick.wong@oracle.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