]> git.baikalelectronics.ru Git - kernel.git/commit
binder: fix proc->files use-after-free
authorTodd Kjos <tkjos@android.com>
Mon, 27 Nov 2017 17:32:33 +0000 (09:32 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 18 Dec 2017 14:47:12 +0000 (15:47 +0100)
commit786fe7db54abca8f8b08e8a619420eb867b48bc1
tree4bfb1d5f8b5356832a99e4c1abf96c05a668e638
parent26e46e0c21de140ece1d41c219b62727eb4f0738
binder: fix proc->files use-after-free

proc->files cleanup is initiated by binder_vma_close. Therefore
a reference on the binder_proc is not enough to prevent the
files_struct from being released while the binder_proc still has
a reference. This can lead to an attempt to dereference the
stale pointer obtained from proc->files prior to proc->files
cleanup. This has been seen once in task_get_unused_fd_flags()
when __alloc_fd() is called with a stale "files".

The fix is to protect proc->files with a mutex to prevent cleanup
while in use.

Signed-off-by: Todd Kjos <tkjos@google.com>
Cc: stable <stable@vger.kernel.org> # 4.14
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/android/binder.c