linux/fs/ext3
Mingming Cao 8a2bfdcbfa [PATCH] ext[34]: EA block reference count racing fix
There are race issues around ext[34] xattr block release code.

ext[34]_xattr_release_block() checks the reference count of xattr block
(h_refcount) and frees that xattr block if it is the last one reference it.
 Unlike ext2, the check of this counter is unprotected by any lock.
ext[34]_xattr_release_block() will free the mb_cache entry before freeing
that xattr block.  There is a small window between the check for the re
h_refcount ==1 and the call to mb_cache_entry_free().  During this small
window another inode might find this xattr block from the mbcache and reuse
it, racing a refcount updates.  The xattr block will later be freed by the
first inode without notice other inode is still use it.  Later if that
block is reallocated as a datablock for other file, then more serious
problem might happen.

We need put a lock around places checking the refount as well to avoid
racing issue.  Another place need this kind of protection is in
ext3_xattr_block_set(), where it will modify the xattr block content in-
the-fly if the refcount is 1 (means it's the only inode reference it).

This will also fix another issue: the xattr block may not get freed at all
if no lock is to protect the refcount check at the release time.  It is
possible that the last two inodes could release the shared xattr block at
the same time.  But both of them think they are not the last one so only
decreased the h_refcount without freeing xattr block at all.

We need to call lock_buffer() after ext3_journal_get_write_access() to
avoid deadlock (because the later will call lock_buffer()/unlock_buffer
() as well).

Signed-off-by: Mingming Cao <cmm@us.ibm.com>
Cc: Andreas Gruenbacher <agruen@suse.de>
Cc: <linux-ext4@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2007-03-01 14:53:38 -08:00
..
Makefile [PATCH] ext3: uninline large functions 2006-12-07 08:39:35 -08:00
acl.c [PATCH] fs: Removing useless casts 2006-09-27 08:26:10 -07:00
acl.h
balloc.c [PATCH] ext[234]: update documentation 2007-02-20 17:10:14 -08:00
bitmap.c [PATCH] ext3 and jbd cleanup: remove whitespace 2006-09-27 08:26:09 -07:00
dir.c [PATCH] ext3: change uses of f_{dentry, vfsmnt} to use f_path 2006-12-08 08:28:41 -08:00
ext3_jbd.c [PATCH] ext3: uninline large functions 2006-12-07 08:39:35 -08:00
file.c [PATCH] mark struct inode_operations const 1 2007-02-12 09:48:46 -08:00
fsync.c [PATCH] ext3 and jbd cleanup: remove whitespace 2006-09-27 08:26:09 -07:00
hash.c [PATCH] remove many unneeded #includes of sched.h 2007-02-14 08:09:54 -08:00
ialloc.c [PATCH] inode-diet: Eliminate i_blksize from the inode structure 2006-09-27 08:26:18 -07:00
inode.c [PATCH] jbd layer function called instead of fs specific one 2007-02-11 11:18:06 -08:00
ioctl.c [PATCH] ext3: change uses of f_{dentry, vfsmnt} to use f_path 2006-12-08 08:28:41 -08:00
namei.c [PATCH] mark struct inode_operations const 1 2007-02-12 09:48:46 -08:00
namei.h
resize.c [PATCH] remove many unneeded #includes of sched.h 2007-02-14 08:09:54 -08:00
super.c [PATCH] Mark struct super_operations const 2007-02-12 09:48:47 -08:00
symlink.c [PATCH] mark struct inode_operations const 1 2007-02-12 09:48:46 -08:00
xattr.c [PATCH] ext[34]: EA block reference count racing fix 2007-03-01 14:53:38 -08:00
xattr.h
xattr_security.c
xattr_trusted.c
xattr_user.c