]> pilppa.com Git - linux-2.6-omap-h63xx.git/commit
[PATCH] holepunch: fix mmap_sem i_mutex deadlock
authorHugh Dickins <hugh@veritas.com>
Thu, 29 Mar 2007 08:20:38 +0000 (01:20 -0700)
committerLinus Torvalds <torvalds@woody.linux-foundation.org>
Thu, 29 Mar 2007 15:22:26 +0000 (08:22 -0700)
commit90ed52ebe48181d3c5427b3bd1d24f659e7575ad
treebfb735ab12ebe7964714c637bcb64163646cd347
parent16a100190d39592d1d56ff5a0b978b20288c3427
[PATCH] 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>
Cc: Miklos Szeredi <mszeredi@suse.cz>
Cc: Badari Pulavarty <pbadari@us.ibm.com>
Cc: Nick Piggin <npiggin@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/madvise.c