]> 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)
committerOliver Wendt <ow@karo-electronics.de>
Mon, 30 Sep 2013 12:12:27 +0000 (14:12 +0200)
commitf1a39f8a4513de81fc733c288093af53ff7124d3
tree3d3b059498b44f97724527a2450ec4f933399a6c
parent843f4973b07673dc1efaab6a312b84fbe168bcf3
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")

[bwh: Backported to 3.2:
 - Adjust context
 - madvise_remove() calls vmtruncate_range(), not do_fallocate()]
[luto: Backported to 3.0: Adjust context]

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: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: Andy Lutomirski <luto@amacapital.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
mm/madvise.c