Skip to content

Commit fb2162d

Browse files
jeffmahoneytorvalds
authored andcommitted
reiserfs: fix corruption during shrinking of xattrs
Commit 48b32a3 ("reiserfs: use generic xattr handlers") introduced a problem that causes corruption when extended attributes are replaced with a smaller value. The issue is that the reiserfs_setattr to shrink the xattr file was moved from before the write to after the write. The root issue has always been in the reiserfs xattr code, but was papered over by the fact that in the shrink case, the file would just be expanded again while the xattr was written. The end result is that the last 8 bytes of xattr data are lost. This patch fixes it to use new_size. Addresses https://bugzilla.kernel.org/show_bug.cgi?id=14826 Signed-off-by: Jeff Mahoney <jeffm@suse.com> Reported-by: Christian Kujau <lists@nerdbynature.de> Tested-by: Christian Kujau <lists@nerdbynature.de> Cc: Edward Shishkin <edward.shishkin@gmail.com> Cc: Jethro Beekman <kernel@jbeekman.nl> Cc: Greg Surbey <gregsurbey@hotmail.com> Cc: Marco Gatti <marco.gatti@gmail.com> Cc: <stable@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 93d5c9b commit fb2162d

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎fs/reiserfs/xattr.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ reiserfs_xattr_set_handle(struct reiserfs_transaction_handle *th,
554554
if (!err && new_size < i_size_read(dentry->d_inode)) {
555555
struct iattr newattrs = {
556556
.ia_ctime = current_fs_time(inode->i_sb),
557-
.ia_size = buffer_size,
557+
.ia_size = new_size,
558558
.ia_valid = ATTR_SIZE | ATTR_CTIME,
559559
};
560560

0 commit comments

Comments
 (0)