mm: Hold a file reference in madvise_remove
authorAndy Lutomirski <luto@amacapital.net>
Thu, 5 Jul 2012 23:00:11 +0000 (16:00 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 6 Jul 2012 17:34:38 +0000 (10:34 -0700)
commit9ab4233dd08036fe34a89c7dc6f47a8bf2eb29eb
treed69ebd5c2e2af1a2de34cc8abe2d57a4eebd35a5
parent1b7fa4c27111757789b21bb78543317dad4cfd08
mm: Hold a file reference in madvise_remove

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>
Cc: stable@vger.kernel.org
Signed-off-by: Andy Lutomirski <luto@amacapital.net>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/madvise.c