linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Brian Foster <bfoster@redhat.com>
To: "Darrick J. Wong" <djwong@maple.djwong.org>
Cc: darrick.wong@oracle.com, linux-xfs@vger.kernel.org
Subject: Re: [PATCH 1/8] xfs: check leaf attribute block freemap in verifier
Date: Thu, 19 Jul 2018 08:24:21 -0400	[thread overview]
Message-ID: <20180719122421.GC25672@bfoster> (raw)
In-Reply-To: <153192903434.31685.282625226695514597.stgit@magnolia>

On Wed, Jul 18, 2018 at 08:50:34AM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Check the leaf attribute freemap when we we're verifying the block.
> 

s/we//

> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
>  fs/xfs/libxfs/xfs_attr_leaf.c |   18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)
> 
> 
> diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c
> index 76e90046731c..b3c19339e1b5 100644
> --- a/fs/xfs/libxfs/xfs_attr_leaf.c
> +++ b/fs/xfs/libxfs/xfs_attr_leaf.c
> @@ -244,6 +244,8 @@ xfs_attr3_leaf_verify(
>  	struct xfs_attr_leafblock	*leaf = bp->b_addr;
>  	struct xfs_perag		*pag = bp->b_pag;
>  	struct xfs_attr_leaf_entry	*entries;
> +	uint16_t			end;
> +	int				i;
>  
>  	xfs_attr3_leaf_hdr_from_disk(mp->m_attr_geo, &ichdr, leaf);
>  
> @@ -289,6 +291,22 @@ xfs_attr3_leaf_verify(
>  	/* XXX: need to range check rest of attr header values */
>  	/* XXX: hash order check? */
>  
> +	for (i = 0; i < XFS_ATTR_LEAF_MAPSIZE; i++) {
> +		if (ichdr.freemap[i].base > mp->m_attr_geo->blksize)
> +			return __this_address;
> +		if (ichdr.freemap[i].base & 0x3)
> +			return __this_address;

Same question as Carlos.. can you elaborate on the 0x3 magic number? (A
one-liner comment might be useful).

Brian

> +		if (ichdr.freemap[i].size > mp->m_attr_geo->blksize)
> +			return __this_address;
> +		if (ichdr.freemap[i].size & 0x3)
> +			return __this_address;
> +		end = ichdr.freemap[i].base + ichdr.freemap[i].size;
> +		if (end < ichdr.freemap[i].base)
> +			return __this_address;
> +		if (end > mp->m_attr_geo->blksize)
> +			return __this_address;
> +	}
> +
>  	return 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

  parent reply	other threads:[~2018-07-19 13:07 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-18 15:50 [PATCH 0/8] xfs-4.19: fixes & cleanups Darrick J. Wong
2018-07-18 15:50 ` [PATCH 1/8] xfs: check leaf attribute block freemap in verifier Darrick J. Wong
2018-07-19 12:19   ` Carlos Maiolino
2018-07-19 12:24   ` Brian Foster [this message]
2018-07-19 15:20     ` Darrick J. Wong
2018-07-19 15:25   ` [PATCH v2 " Darrick J. Wong
2018-07-19 15:30     ` Brian Foster
2018-07-19 15:46     ` Carlos Maiolino
2018-07-19 16:40     ` Christoph Hellwig
2018-07-18 15:50 ` [PATCH 2/8] xfs: return from _defer_finish with a clean transaction Darrick J. Wong
2018-07-19 12:24   ` Brian Foster
2018-07-19 16:41   ` Christoph Hellwig
2018-07-18 15:50 ` [PATCH 3/8] xfs: trivial xfs_btree_del_cursor cleanups Darrick J. Wong
2018-07-19 12:24   ` Brian Foster
2018-07-19 12:25   ` Carlos Maiolino
2018-07-19 16:43   ` Christoph Hellwig
2018-07-19 19:22     ` Darrick J. Wong
2018-07-20 16:04       ` Christoph Hellwig
2018-07-18 15:50 ` [PATCH 4/8] xfs: clean up xfs_btree_del_cursor callers Darrick J. Wong
2018-07-19 12:24   ` Brian Foster
2018-07-19 12:28   ` Carlos Maiolino
2018-07-19 16:46   ` Christoph Hellwig
2018-07-18 15:51 ` [PATCH 5/8] xfs: shorten xfs_scrub_ prefix Darrick J. Wong
2018-07-19 12:59   ` Brian Foster
2018-07-18 15:51 ` [PATCH 6/8] xfs: shorten xfs_repair_ prefix to xrep_ Darrick J. Wong
2018-07-19 12:59   ` Brian Foster
2018-07-18 15:52 ` [PATCH 7/8] xfs: shorten struct xfs_scrub_context to struct xfs_scrub Darrick J. Wong
2018-07-19 12:59   ` Brian Foster
2018-07-18 15:52 ` [PATCH 8/8] xfs: fix indentation and other whitespace problems in scrub/repair Darrick J. Wong
2018-07-19 12:59   ` 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=20180719122421.GC25672@bfoster \
    --to=bfoster@redhat.com \
    --cc=darrick.wong@oracle.com \
    --cc=djwong@maple.djwong.org \
    --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;
as well as URLs for NNTP newsgroup(s).