reiserfs: fix corruption during shrinking of xattrs

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Linux Kernel Mailing List
Date: Saturday, April 24, 2010 - 3:59 pm

Gitweb:     http://git.kernel.org/linus/fb2162df74bb19552db3d988fd11c787cf5fad56
Commit:     fb2162df74bb19552db3d988fd11c787cf5fad56
Parent:     93d5c9be1ddd57d4063ce463c9ac2be1e5ee14f1
Author:     Jeff Mahoney <jeffm@suse.com>
AuthorDate: Fri Apr 23 13:17:41 2010 -0400
Committer:  Linus Torvalds <torvalds@linux-foundation.org>
CommitDate: Sat Apr 24 11:31:24 2010 -0700

    reiserfs: fix corruption during shrinking of xattrs
    
    Commit 48b32a3553a54740d236b79a90f20147a25875e3 ("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>
---
 fs/reiserfs/xattr.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/fs/reiserfs/xattr.c b/fs/reiserfs/xattr.c
index 28f0a44..e7cc00e 100644
--- a/fs/reiserfs/xattr.c
+++ b/fs/reiserfs/xattr.c
@@ -554,7 +554,7 @@ reiserfs_xattr_set_handle(struct reiserfs_transaction_handle *th,
 	if (!err && new_size < i_size_read(dentry->d_inode)) {
 		struct iattr newattrs = {
 			.ia_ctime = current_fs_time(inode->i_sb),
-			.ia_size = buffer_size,
+			.ia_size = new_size,
 			.ia_valid = ATTR_SIZE | ATTR_CTIME,
 		};
 
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
reiserfs: fix corruption during shrinking of xattrs, Linux Kernel Mailing ..., (Sat Apr 24, 3:59 pm)