]> git.karo-electronics.de Git - karo-tx-linux.git/commit
mm: Hold a file reference in madvise_remove
authorAndy Lutomirski <luto@amacapital.net>
Thu, 5 Jul 2012 23:00:11 +0000 (16:00 -0700)
committerBen Hutchings <ben@decadent.org.uk>
Thu, 12 Jul 2012 03:32:19 +0000 (04:32 +0100)
commit1935549ba38cf30ebe8748ccb88fb99d009241d4
tree9670b6c22ff039161f2b0650572c48c788a41625
parent6d60474a0f04010b7b9446abe68bcf2fb772c9bd
mm: Hold a file reference in madvise_remove

commit 9ab4233dd08036fe34a89c7dc6f47a8bf2eb29eb upstream.

Otherwise the code races with munmap (causing a use-after-free
of the vma) or with close (causing a use-after-free of the struct
file).

The bug was introduced by commit 90ed52ebe481 ("[PATCH] holepunch: fix
mmap_sem i_mutex deadlock")

Cc: 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: Andy Lutomirski <luto@amacapital.net>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
[bwh: Backported to 3.2:
 - Adjust context
 - madvise_remove() calls vmtruncate_range(), not do_fallocate()]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
mm/madvise.c