* [PATCH] xfs_metadump: properly handle obfuscation of all remote attribute blocks
@ 2017-07-26 20:35 Eric Sandeen
2017-07-28 12:52 ` Brian Foster
2017-08-01 16:39 ` [PATCH V2] " Eric Sandeen
0 siblings, 2 replies; 5+ messages in thread
From: Eric Sandeen @ 2017-07-26 20:35 UTC (permalink / raw)
To: linux-xfs
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);
}
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 */
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH] xfs_metadump: properly handle obfuscation of all remote attribute blocks
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
2017-08-01 16:26 ` Eric Sandeen
2017-08-01 16:39 ` [PATCH V2] " Eric Sandeen
1 sibling, 1 reply; 5+ messages in thread
From: Brian Foster @ 2017-07-28 12:52 UTC (permalink / raw)
To: Eric Sandeen; +Cc: linux-xfs
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
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] xfs_metadump: properly handle obfuscation of all remote attribute blocks
2017-07-28 12:52 ` Brian Foster
@ 2017-08-01 16:26 ` Eric Sandeen
0 siblings, 0 replies; 5+ messages in thread
From: Eric Sandeen @ 2017-08-01 16:26 UTC (permalink / raw)
To: Brian Foster, Eric Sandeen; +Cc: linux-xfs
On 7/28/17 7:52 AM, Brian Foster wrote:
> 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()?
Oh, yeah, why didn't I use that!
Thanks,
-Eric
> Brian
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH V2] xfs_metadump: properly handle obfuscation of all remote attribute blocks
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
@ 2017-08-01 16:39 ` Eric Sandeen
2017-08-01 16:53 ` Brian Foster
1 sibling, 1 reply; 5+ messages in thread
From: Eric Sandeen @ 2017-08-01 16:39 UTC (permalink / raw)
To: Eric Sandeen, linux-xfs
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>
---
V2: Use helper macro, don't send mp as arg (it's a global (!))
diff --git a/db/metadump.c b/db/metadump.c
index 96641e0..f60bd32 100644
--- a/db/metadump.c
+++ b/db/metadump.c
@@ -1609,7 +1609,7 @@ add_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 -= XFS_ATTR3_RMT_BUF_SPACE(mp, mp->m_sb.sb_blocksize);
}
if (attr_data.remote_val_count >= MAX_REMOTE_VALS) {
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH V2] xfs_metadump: properly handle obfuscation of all remote attribute blocks
2017-08-01 16:39 ` [PATCH V2] " Eric Sandeen
@ 2017-08-01 16:53 ` Brian Foster
0 siblings, 0 replies; 5+ messages in thread
From: Brian Foster @ 2017-08-01 16:53 UTC (permalink / raw)
To: Eric Sandeen; +Cc: Eric Sandeen, linux-xfs
On Tue, Aug 01, 2017 at 11:39:19AM -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>
> ---
>
Reviewed-by: Brian Foster <bfoster@redhat.com>
> V2: Use helper macro, don't send mp as arg (it's a global (!))
>
> diff --git a/db/metadump.c b/db/metadump.c
> index 96641e0..f60bd32 100644
> --- a/db/metadump.c
> +++ b/db/metadump.c
> @@ -1609,7 +1609,7 @@ add_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 -= XFS_ATTR3_RMT_BUF_SPACE(mp, mp->m_sb.sb_blocksize);
> }
>
> if (attr_data.remote_val_count >= MAX_REMOTE_VALS) {
>
> --
> 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
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-08-01 16:53 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2017-08-01 16:26 ` Eric Sandeen
2017-08-01 16:39 ` [PATCH V2] " Eric Sandeen
2017-08-01 16:53 ` Brian Foster
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox