• Andrew Morton's avatar
    [PATCH] ext2/3: incorrect increment of i_blocks when keeping the same xattr block · 14484915
    Andrew Morton authored
    From: Andreas Gruenbacher <agruen@suse.de>
    
    Here is a fix for extended attributes on ext2 and ext3, reported by
    Stephen Tweedie <sct@redhat.com>.
    
    From: Stephen Tweedie <sct@redhat.com>:
    
    When you have an EA block that is shared between multiple inodes; AND you
    then change an attribute in that on one inode, AND the new attribute value
    is the same as the old, then xattr computes the new EA block, finds it
    still in the cache, bumps the reference count on it (and the i_blocks field
    on the inode, incidentally), and leaves it incremented because we haven't
    changed EA block so there's no need to drop the refcount on the old block.
    
    So *every* time you have more than one inode sharing an EA block and you
    perform an identical write to an EA, you get a leak on both i_blocks and
    the EA refcount.
    
    This is a big problem for symlinks, which rely on correct i_blocks
    accounting to determine the difference between fast and slow symlinks.
    With the leak, you end up thinking that a fast symlink (ie.  one small
    enough to be stored in the inode direct blocks) is slow, so you dereference
    the ascii contents of the symlink as if they were a disk block address.
    That typically results in EIO all over the place.
    14484915
xattr.c 31.4 KB