linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Josef Bacik <jbacik@fusionio.com>
To: <linux-btrfs@vger.kernel.org>
Subject: [PATCH] Btrfs-progs: sanitize xattrs when we specify sanitization
Date: Wed, 31 Jul 2013 10:23:58 -0400	[thread overview]
Message-ID: <1375280638-1961-1-git-send-email-jbacik@fusionio.com> (raw)

Alexandre pointed out that his xattrs have sensitive information in them as
well, so fix btrfs-image to zero out the data part of xattrs that we find.
Thanks,

Signed-off-by: Josef Bacik <jbacik@fusionio.com>
---
 btrfs-image.c |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/btrfs-image.c b/btrfs-image.c
index 82aa4f3..025facf 100644
--- a/btrfs-image.c
+++ b/btrfs-image.c
@@ -162,6 +162,7 @@ static int has_name(struct btrfs_key *key)
 	case BTRFS_DIR_INDEX_KEY:
 	case BTRFS_INODE_REF_KEY:
 	case BTRFS_INODE_EXTREF_KEY:
+	case BTRFS_XATTR_ITEM_KEY:
 		return 1;
 	default:
 		break;
@@ -446,6 +447,21 @@ static void sanitize_inode_ref(struct metadump_struct *md,
 	}
 }
 
+static void sanitize_xattr(struct metadump_struct *md,
+			   struct extent_buffer *eb, int slot)
+{
+	struct btrfs_dir_item *dir_item;
+	unsigned long data_ptr;
+	u32 data_len;
+
+	dir_item = btrfs_item_ptr(eb, slot, struct btrfs_dir_item);
+	data_len = btrfs_dir_data_len(eb, dir_item);
+
+	data_ptr = (unsigned long)((char *)(dir_item + 1) +
+				   btrfs_dir_name_len(eb, dir_item));
+	memset_extent_buffer(eb, 0, data_ptr, data_len);
+}
+
 static void sanitize_name(struct metadump_struct *md, u8 *dst,
 			  struct extent_buffer *src, struct btrfs_key *key,
 			  int slot)
@@ -471,6 +487,9 @@ static void sanitize_name(struct metadump_struct *md, u8 *dst,
 	case BTRFS_INODE_EXTREF_KEY:
 		sanitize_inode_ref(md, eb, slot, 1);
 		break;
+	case BTRFS_XATTR_ITEM_KEY:
+		sanitize_xattr(md, eb, slot);
+		break;
 	default:
 		break;
 	}
-- 
1.7.7.6


             reply	other threads:[~2013-07-31 14:24 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-31 14:23 Josef Bacik [this message]
2013-08-02 14:54 ` [PATCH] Btrfs-progs: sanitize xattrs when we specify sanitization Filipe David Manana

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=1375280638-1961-1-git-send-email-jbacik@fusionio.com \
    --to=jbacik@fusionio.com \
    --cc=linux-btrfs@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).