]> git.karo-electronics.de Git - karo-tx-linux.git/commit
holepunch: fix mmap_sem i_mutex deadlock
authorHugh Dickins <hugh@veritas.com>
Fri, 13 Apr 2007 17:27:55 +0000 (18:27 +0100)
committerGreg Kroah-Hartman <gregkh@suse.de>
Wed, 2 May 2007 00:05:56 +0000 (17:05 -0700)
commit64f586d81ecc913a557055d4804c987f8c766888
tree9fa41d46aa20c9cbf3d583cd2cdefaf4c90cdaa7
parent42988ea6a81e888a6aa28549071e00400b68f4f7
holepunch: fix mmap_sem i_mutex deadlock

sys_madvise has down_write of mmap_sem, then madvise_remove calls
vmtruncate_range which takes i_mutex and i_alloc_sem: no, we can
easily devise deadlocks from that ordering.

madvise_remove drop mmap_sem while calling vmtruncate_range: luckily,
since madvise_remove doesn't split or merge vmas, it's easy to handle
this case with a NULL prev, without restructuring sys_madvise.  (Though
sad to retake mmap_sem when it's unlikely to be needed, and certainly
down_read is sufficient for MADV_REMOVE, unlike the other madvices.)

Signed-off-by: Hugh Dickins <hugh@veritas.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
mm/madvise.c