All of lore.kernel.org
 help / color / mirror / Atom feed
From: Brian Foster <bfoster@redhat.com>
To: Eric Sandeen <sandeen@redhat.com>
Cc: linux-xfs <linux-xfs@vger.kernel.org>, Stefan Ring <stefanrin@gmail.com>
Subject: Re: [PATCH] xfs_metadump: zap stale date in DIR2_LEAF1 dirs
Date: Wed, 2 Aug 2017 09:54:21 -0400	[thread overview]
Message-ID: <20170802135417.GA38674@bfoster.bfoster> (raw)
In-Reply-To: <37cd41d1-335f-a3af-d92c-c0b4b6d1356a@redhat.com>

On Tue, Aug 01, 2017 at 09:35:27PM -0500, Eric Sandeen wrote:
> xfs_metadump attempts to zero out unused regions of metadata
> blocks to prevent data leaks when sharing metadata images.
> 
> However, Stefan Ring reported a significant number of leaked
> strings when dumping his 1T filesystem.  Based on a reduced
> metadata set, I was able to identify "leaf" directories
> (with XFS_DIR2_LEAF1_MAGIC magic) as the primary culprit;
> the region between the end of the entries array and the start
> of the bests array was not getting zeroed out.  This patch
> seems to remedy that problem.
> 
> Reported-by: Stefan Ring <stefanrin@gmail.com>
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
> ---
> 
> I may have missed some handy macro to work out some of the
> math below, if so I'd be perfectly happy to hear about it ;)
> 

Looks good to me. A couple nits...

> diff --git a/db/metadump.c b/db/metadump.c
> index 96641e0..6d77d61 100644
> --- a/db/metadump.c
> +++ b/db/metadump.c
> @@ -1459,6 +1459,37 @@ process_dir_data_block(
>  	int		wantmagic;
>  	struct xfs_dir2_data_hdr *datahdr;
>  
> +	if (offset >= mp->m_dir_geo->freeblk) {
> +		/* TODO */
> +		return;

TODO what exactly? Zero from the end of the bests array to the end of
the block? We could at least add the if (!zero_stale_data) check here
too.

> +	} else if (offset >= mp->m_dir_geo->leafblk) {
> +		struct xfs_dir2_leaf		*leaf;
> +		struct xfs_dir2_leaf_tail	*ltp;
> +		struct xfs_dir3_icleaf_hdr 	leafhdr;
> +
> +		if (!zero_stale_data)
> +			return;
> +
> +		leaf = (struct xfs_dir2_leaf *)block;
> +		ltp = xfs_dir2_leaf_tail_p(mp->m_dir_geo, leaf);

ltp isn't used until the block of code below (which already has locally
scoped vars).

Brian

> +		M_DIROPS(mp)->leaf_hdr_from_disk(&leafhdr, leaf);
> +
> +		/* Zero out space from end of ents[] to bests */
> +		if (leafhdr.magic == XFS_DIR2_LEAF1_MAGIC) {
> +			struct xfs_dir2_leaf_entry	*ents;
> +			__be16				*lbp;
> +			char				*start; /* end of ents */
> +
> +			ents = M_DIROPS(mp)->leaf_ents_p(leaf);
> +			start = (char *)&ents[leafhdr.count + leafhdr.stale];
> +			lbp = xfs_dir2_leaf_bests_p(ltp);
> +			memset(start, 0, (char *)lbp - start);
> +			iocur_top->need_crc = 1;
> +		}
> +		return;
> +	}
> +
> +	/* It's a data block. */
>  	datahdr = (struct xfs_dir2_data_hdr *)block;
>  
>  	if (is_block_format) {
> @@ -1800,9 +1831,6 @@ process_single_fsb_objects(
>  		dp = iocur_top->data;
>  		switch (btype) {
>  		case TYP_DIR2:
> -			if (o >= mp->m_dir_geo->leafblk)
> -				break;
> -
>  			process_dir_data_block(dp, o,
>  					 last == mp->m_dir_geo->fsbcount);
>  			iocur_top->need_crc = 1;
> 
> --
> 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

  reply	other threads:[~2017-08-02 13:54 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-02  2:35 [PATCH] xfs_metadump: zap stale date in DIR2_LEAF1 dirs Eric Sandeen
2017-08-02 13:54 ` Brian Foster [this message]
2017-08-02 15:16   ` Eric Sandeen
2017-08-02 16:09     ` Darrick J. Wong
2017-08-10 21:30 ` [PATCH V2] " Eric Sandeen
2017-08-14 12:40   ` 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=20170802135417.GA38674@bfoster.bfoster \
    --to=bfoster@redhat.com \
    --cc=linux-xfs@vger.kernel.org \
    --cc=sandeen@redhat.com \
    --cc=stefanrin@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.