linux-stable/fs
cmm@us.ibm.com fa0726854c [PATCH] ext3: fix race between ext3 make block reservation and reservation window discard
This patch fixed a race between ext3_discard_reservation() and
ext3_try_to_allocate_with_rsv().

There is a window where ext3_discard_reservation will remove an already
unlinked reservation window node from the filesystem reservation tree:
It thinks the reservation is still linked in the filesystem reservation
tree, but it is actually temperately removed from the tree by
allocate_new_reservation() when it failed to make a new reservation from
the current group and try to make a new reservation from next block
group.

Here is how it could happen:

CPU 1
try to allocate a block in group1 with given reservation window my_rsv
ext3_try_to_allocate_with_rsv(group
	----copy reservation window my_rsv into local rsv_copy
	ext3_try_to_allocate(...rsv_copy)
		----no free block in existing reservation window,
		----need a new reservation window
	spin_lock(&rsv_lock);

CPU 2

ext3_discard_reservation
	if (!rsv_is_empty()
		----this is true
	spin_lock(&rsv_lock)
		----waiting for thread 1

CPU 1:

	allocate_new_reservation
		failed to reserve blocks in this group
		remove the window from the tree
		rsv_window_remove(my_rsv)
			----window node is unlinked from the tree here
		return -1
	spin_unlock(&rsv_lock)
ext3_try_to_allocate_with_rsv() failed in this group
group++

CPU 2
	spin_lock(&rsv_lock) succeed
	rsv_remove_window ()
		---------------break, trying to remove a unlinked node from the tree
	....

CPU 1:
ext3_try_to_allocate_with_rsv(group, my_rsv)
	rsv_is_empty is true, need a new reservation window
	spin_lock(&rsv_lock);
		^--------------- spinning forever

We need to re-check whether the reservation window is still linked to
the tree after grab the rsv_lock spin lock in ext3_discard_reservation,
to prevent panic in rsv_remove_window->rb_erase.

Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Chris Wright <chrisw@osdl.org>
2005-05-26 21:20:03 -07:00
..
adfs 2.6.11 import 2005-05-12 09:59:06 -07:00
affs 2.6.11 import 2005-05-12 09:59:06 -07:00
afs 2.6.11 import 2005-05-12 09:59:06 -07:00
autofs 2.6.11 import 2005-05-12 09:59:06 -07:00
autofs4 2.6.11 import 2005-05-12 09:59:06 -07:00
befs 2.6.11 import 2005-05-12 09:59:06 -07:00
bfs 2.6.11 import 2005-05-12 09:59:06 -07:00
cifs 2.6.11 import 2005-05-12 09:59:06 -07:00
coda 2.6.11 import 2005-05-12 09:59:06 -07:00
cramfs [PATCH] cramfs: small stat(2) fix 2005-05-12 10:00:07 -07:00
debugfs 2.6.11 import 2005-05-12 09:59:06 -07:00
devfs 2.6.11 import 2005-05-12 09:59:06 -07:00
devpts 2.6.11 import 2005-05-12 09:59:06 -07:00
efs 2.6.11 import 2005-05-12 09:59:06 -07:00
exportfs 2.6.11 import 2005-05-12 09:59:06 -07:00
ext2 [PATCH] Suspected information leak (mem pages) in ext2 2005-05-12 10:00:17 -07:00
ext3 [PATCH] ext3: fix race between ext3 make block reservation and reservation window discard 2005-05-26 21:20:03 -07:00
fat 2.6.11 import 2005-05-12 09:59:06 -07:00
freevxfs 2.6.11 import 2005-05-12 09:59:06 -07:00
hfs 2.6.11 import 2005-05-12 09:59:06 -07:00
hfsplus 2.6.11 import 2005-05-12 09:59:06 -07:00
hostfs 2.6.11 import 2005-05-12 09:59:06 -07:00
hpfs 2.6.11 import 2005-05-12 09:59:06 -07:00
hppfs 2.6.11 import 2005-05-12 09:59:06 -07:00
hugetlbfs 2.6.11 import 2005-05-12 09:59:06 -07:00
isofs [PATCH] isofs: more defensive checks against corrupt isofs images 2005-05-12 10:00:16 -07:00
jbd [PATCH] Prevent race condition in jbd 2005-05-12 10:00:18 -07:00
jffs 2.6.11 import 2005-05-12 09:59:06 -07:00
jffs2 2.6.11 import 2005-05-12 09:59:06 -07:00
jfs 2.6.11 import 2005-05-12 09:59:06 -07:00
lockd 2.6.11 import 2005-05-12 09:59:06 -07:00
minix 2.6.11 import 2005-05-12 09:59:06 -07:00
msdos 2.6.11 import 2005-05-12 09:59:06 -07:00
ncpfs 2.6.11 import 2005-05-12 09:59:06 -07:00
nfs 2.6.11 import 2005-05-12 09:59:06 -07:00
nfsd 2.6.11 import 2005-05-12 09:59:06 -07:00
nls 2.6.11 import 2005-05-12 09:59:06 -07:00
ntfs 2.6.11 import 2005-05-12 09:59:06 -07:00
openpromfs 2.6.11 import 2005-05-12 09:59:06 -07:00
partitions [PATCH] Cset exclude: khali@linux-fr.org[gregkh]|ChangeSet|20050430010004|65088 2005-05-12 10:00:23 -07:00
proc 2.6.11 import 2005-05-12 09:59:06 -07:00
qnx4 2.6.11 import 2005-05-12 09:59:06 -07:00
ramfs 2.6.11 import 2005-05-12 09:59:06 -07:00
reiserfs 2.6.11 import 2005-05-12 09:59:06 -07:00
romfs 2.6.11 import 2005-05-12 09:59:06 -07:00
smbfs 2.6.11 import 2005-05-12 09:59:06 -07:00
sysfs 2.6.11 import 2005-05-12 09:59:06 -07:00
sysv 2.6.11 import 2005-05-12 09:59:06 -07:00
udf 2.6.11 import 2005-05-12 09:59:06 -07:00
ufs 2.6.11 import 2005-05-12 09:59:06 -07:00
umsdos 2.6.11 import 2005-05-12 09:59:06 -07:00
vfat 2.6.11 import 2005-05-12 09:59:06 -07:00
xfs 2.6.11 import 2005-05-12 09:59:06 -07:00
Kconfig 2.6.11 import 2005-05-12 09:59:06 -07:00
Kconfig.binfmt 2.6.11 import 2005-05-12 09:59:06 -07:00
Makefile 2.6.11 import 2005-05-12 09:59:06 -07:00
aio.c 2.6.11 import 2005-05-12 09:59:06 -07:00
attr.c 2.6.11 import 2005-05-12 09:59:06 -07:00
bad_inode.c 2.6.11 import 2005-05-12 09:59:06 -07:00
binfmt_aout.c 2.6.11 import 2005-05-12 09:59:06 -07:00
binfmt_elf.c [PATCH] fix Linux kernel ELF core dump privilege elevation 2005-05-12 10:00:25 -07:00
binfmt_elf_fdpic.c 2.6.11 import 2005-05-12 09:59:06 -07:00
binfmt_em86.c 2.6.11 import 2005-05-12 09:59:06 -07:00
binfmt_flat.c 2.6.11 import 2005-05-12 09:59:06 -07:00
binfmt_misc.c 2.6.11 import 2005-05-12 09:59:06 -07:00
binfmt_script.c 2.6.11 import 2005-05-12 09:59:06 -07:00
binfmt_som.c 2.6.11 import 2005-05-12 09:59:06 -07:00
bio.c 2.6.11 import 2005-05-12 09:59:06 -07:00
block_dev.c 2.6.11 import 2005-05-12 09:59:06 -07:00
buffer.c 2.6.11 import 2005-05-12 09:59:06 -07:00
char_dev.c 2.6.11 import 2005-05-12 09:59:06 -07:00
compat.c 2.6.11 import 2005-05-12 09:59:06 -07:00
compat_ioctl.c 2.6.11 import 2005-05-12 09:59:06 -07:00
dcache.c 2.6.11 import 2005-05-12 09:59:06 -07:00
dcookies.c 2.6.11 import 2005-05-12 09:59:06 -07:00
direct-io.c 2.6.11 import 2005-05-12 09:59:06 -07:00
dnotify.c 2.6.11 import 2005-05-12 09:59:06 -07:00
dquot.c 2.6.11 import 2005-05-12 09:59:06 -07:00
eventpoll.c [PATCH] epoll: return proper error on overflow condition 2005-05-12 10:00:06 -07:00
exec.c [PATCH] use strncpy in get_task_comm 2005-05-12 10:00:11 -07:00
fcntl.c 2.6.11 import 2005-05-12 09:59:06 -07:00
fifo.c 2.6.11 import 2005-05-12 09:59:06 -07:00
file.c 2.6.11 import 2005-05-12 09:59:06 -07:00
file_table.c 2.6.11 import 2005-05-12 09:59:06 -07:00
filesystems.c 2.6.11 import 2005-05-12 09:59:06 -07:00
fs-writeback.c 2.6.11 import 2005-05-12 09:59:06 -07:00
inode.c 2.6.11 import 2005-05-12 09:59:06 -07:00
ioctl.c 2.6.11 import 2005-05-12 09:59:06 -07:00
libfs.c 2.6.11 import 2005-05-12 09:59:06 -07:00
locks.c 2.6.11 import 2005-05-12 09:59:06 -07:00
mbcache.c 2.6.11 import 2005-05-12 09:59:06 -07:00
mpage.c 2.6.11 import 2005-05-12 09:59:06 -07:00
namei.c 2.6.11 import 2005-05-12 09:59:06 -07:00
namespace.c 2.6.11 import 2005-05-12 09:59:06 -07:00
nfsctl.c 2.6.11 import 2005-05-12 09:59:06 -07:00
open.c 2.6.11 import 2005-05-12 09:59:06 -07:00
pipe.c 2.6.11 import 2005-05-12 09:59:06 -07:00
posix_acl.c 2.6.11 import 2005-05-12 09:59:06 -07:00
quota.c 2.6.11 import 2005-05-12 09:59:06 -07:00
quota_v1.c 2.6.11 import 2005-05-12 09:59:06 -07:00
quota_v2.c 2.6.11 import 2005-05-12 09:59:06 -07:00
read_write.c 2.6.11 import 2005-05-12 09:59:06 -07:00
readdir.c 2.6.11 import 2005-05-12 09:59:06 -07:00
select.c 2.6.11 import 2005-05-12 09:59:06 -07:00
seq_file.c 2.6.11 import 2005-05-12 09:59:06 -07:00
stat.c 2.6.11 import 2005-05-12 09:59:06 -07:00
super.c 2.6.11 import 2005-05-12 09:59:06 -07:00
xattr.c 2.6.11 import 2005-05-12 09:59:06 -07:00
xattr_acl.c 2.6.11 import 2005-05-12 09:59:06 -07:00