Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1672044 > unrolled thread

[PATCH 15/32] ext4: fix ext4_xattr_move_to_block()

Started byTahsin Erdogan <tahsin@google.com>
First post2017-06-21 23:30 +0200
Last post2017-06-22 04:20 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 15/32] ext4: fix ext4_xattr_move_to_block() Tahsin Erdogan <tahsin@google.com> - 2017-06-21 23:30 +0200
    Re: [PATCH 15/32] ext4: fix ext4_xattr_move_to_block() Theodore Ts'o <tytso@mit.edu> - 2017-06-22 04:20 +0200

#1672044 — [PATCH 15/32] ext4: fix ext4_xattr_move_to_block()

FromTahsin Erdogan <tahsin@google.com>
Date2017-06-21 23:30 +0200
Subject[PATCH 15/32] ext4: fix ext4_xattr_move_to_block()
Message-ID<tUVmi-3od-15@gated-at.bofh.it>
When moving xattr entries from inline area to a xattr block, entries
that refer to external xattr inodes need special handling because
value data is not available in the inline area but rather should be
read from its external inode.

Signed-off-by: Tahsin Erdogan <tahsin@google.com>
---
 fs/ext4/xattr.c | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
index 6a6bee246873..9c243b3510b7 100644
--- a/fs/ext4/xattr.c
+++ b/fs/ext4/xattr.c
@@ -1658,18 +1658,16 @@ static int ext4_xattr_move_to_block(handle_t *handle, struct inode *inode,
 	struct ext4_xattr_ibody_find *is = NULL;
 	struct ext4_xattr_block_find *bs = NULL;
 	char *buffer = NULL, *b_entry_name = NULL;
-	size_t value_offs, value_size;
+	size_t value_size = le32_to_cpu(entry->e_value_size);
 	struct ext4_xattr_info i = {
 		.value = NULL,
 		.value_len = 0,
 		.name_index = entry->e_name_index,
+		.in_inode = !!entry->e_value_inum,
 	};
 	struct ext4_xattr_ibody_header *header = IHDR(inode, raw_inode);
 	int error;
 
-	value_offs = le16_to_cpu(entry->e_value_offs);
-	value_size = le32_to_cpu(entry->e_value_size);
-
 	is = kzalloc(sizeof(struct ext4_xattr_ibody_find), GFP_NOFS);
 	bs = kzalloc(sizeof(struct ext4_xattr_block_find), GFP_NOFS);
 	buffer = kmalloc(value_size, GFP_NOFS);
@@ -1685,7 +1683,17 @@ static int ext4_xattr_move_to_block(handle_t *handle, struct inode *inode,
 	bs->bh = NULL;
 
 	/* Save the entry name and the entry value */
-	memcpy(buffer, (void *)IFIRST(header) + value_offs, value_size);
+	if (entry->e_value_inum) {
+		error = ext4_xattr_inode_get(inode,
+					     le32_to_cpu(entry->e_value_inum),
+					     buffer, value_size);
+		if (error)
+			goto out;
+	} else {
+		size_t value_offs = le16_to_cpu(entry->e_value_offs);
+		memcpy(buffer, (void *)IFIRST(header) + value_offs, value_size);
+	}
+
 	memcpy(b_entry_name, entry->e_name, entry->e_name_len);
 	b_entry_name[entry->e_name_len] = '\0';
 	i.name = b_entry_name;
@@ -1703,7 +1711,6 @@ static int ext4_xattr_move_to_block(handle_t *handle, struct inode *inode,
 	if (error)
 		goto out;
 
-	i.name = b_entry_name;
 	i.value = buffer;
 	i.value_len = value_size;
 	error = ext4_xattr_block_find(inode, &i, bs);
-- 
2.13.1.611.g7e3b11ae1-goog

[toc] | [next] | [standalone]


#1672253

FromTheodore Ts'o <tytso@mit.edu>
Date2017-06-22 04:20 +0200
Message-ID<tUZSV-6En-1@gated-at.bofh.it>
In reply to#1672044
On Wed, Jun 21, 2017 at 02:21:25PM -0700, Tahsin Erdogan wrote:
> When moving xattr entries from inline area to a xattr block, entries
> that refer to external xattr inodes need special handling because
> value data is not available in the inline area but rather should be
> read from its external inode.
> 
> Signed-off-by: Tahsin Erdogan <tahsin@google.com>

Thanks, applied.

					- Ted

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web