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>
Subject: Re: [PATCH] xfs_metadump: properly handle obfuscation of all remote attribute blocks
Date: Fri, 28 Jul 2017 08:52:02 -0400	[thread overview]
Message-ID: <20170728125201.GA12444@bfoster.bfoster> (raw)
In-Reply-To: <7862201b-e387-8037-ca99-b6ab3212f4a7@redhat.com>

On Wed, Jul 26, 2017 at 03:35:37PM -0500, Eric Sandeen wrote:
> add_remote_vals assumes that it can subtract blocksize
> from each block that it processes, but with CRCs, there
> is a header on each block, so the assumption that each
> block consumes $BLOCKSIZE of the value length is incorrect.
> 
> This causes us to stop adding remote blocks too soon, and
> the missed blocks do not get obfuscated.
> 
> Fix this by accounting for the header size as appropriate,
> depending on whether or not we have a CRC filesystem.
> 
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
> ---
> 
> diff --git a/db/metadump.c b/db/metadump.c
> index 96641e0..c8abfeb 100644
> --- a/db/metadump.c
> +++ b/db/metadump.c
> @@ -1602,14 +1602,20 @@ static struct attr_data_s {
>  
>  static inline void
>  add_remote_vals(
> +	struct xfs_mount	*mp,
>  	xfs_dablk_t 		blockidx,
>  	int			length)
>  {
> +	int			hdrsize = 0;
> +
> +	if (xfs_sb_version_hascrc(&mp->m_sb))
> +		hdrsize = sizeof(struct xfs_attr3_rmt_hdr);
> +
>  	while (length > 0 && attr_data.remote_val_count < MAX_REMOTE_VALS) {
>  		attr_data.remote_vals[attr_data.remote_val_count] = blockidx;
>  		attr_data.remote_val_count++;
>  		blockidx++;
> -		length -= mp->m_sb.sb_blocksize;
> +		length -= (mp->m_sb.sb_blocksize - hdrsize);

XFS_ATTR3_RMT_BUF_SPACE()?

Brian

>  	}
>  
>  	if (attr_data.remote_val_count >= MAX_REMOTE_VALS) {
> @@ -1716,7 +1722,8 @@ process_attr_block(
>  			if (obfuscate) {
>  				generate_obfuscated_name(0, remote->namelen,
>  							 &remote->name[0]);
> -				add_remote_vals(be32_to_cpu(remote->valueblk),
> +				add_remote_vals(mp,
> +						be32_to_cpu(remote->valueblk),
>  						be32_to_cpu(remote->valuelen));
>  			}
>  			/* zero from end of name[] to next name start */
> 
> --
> 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-07-28 12:52 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-26 20:35 [PATCH] xfs_metadump: properly handle obfuscation of all remote attribute blocks Eric Sandeen
2017-07-28 12:52 ` Brian Foster [this message]
2017-08-01 16:26   ` Eric Sandeen
2017-08-01 16:39 ` [PATCH V2] " Eric Sandeen
2017-08-01 16:53   ` 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=20170728125201.GA12444@bfoster.bfoster \
    --to=bfoster@redhat.com \
    --cc=linux-xfs@vger.kernel.org \
    --cc=sandeen@redhat.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.