android_kernel_xiaomi_sm7250/drivers/android
Christian Brauner d2437b10ba UPSTREAM: binderfs: use refcount for binder control devices too
Binderfs binder-control devices are cleaned up via binderfs_evict_inode
too() which will use refcount_dec_and_test(). However, we missed to set
the refcount for binderfs binder-control devices and so we underflowed
when the binderfs instance got unmounted. Pretty obvious oversight and
should have been part of the more general UAF fix. The good news is that
having test cases (suprisingly) helps.

Technically, we could detect that we're about to cleanup the
binder-control dentry in binderfs_evict_inode() and then simply clean it
up. But that makes the assumption that the binder driver itself will
never make use of a binderfs binder-control device after the binderfs
instance it belongs to has been unmounted and the superblock for it been
destroyed. While it is unlikely to ever come to this let's be on the
safe side. Performance-wise this also really doesn't matter since the
binder-control device is only every really when creating the binderfs
filesystem or creating additional binder devices. Both operations are
pretty rare.

Fixes: f0fe2c0f050d ("binder: prevent UAF for binderfs devices II")
Link: https://lore.kernel.org/r/CA+G9fYusdfg7PMfC9Xce-xLT7NiyKSbgojpK35GOm=Pf9jXXrA@mail.gmail.com
Reported-by: Naresh Kamboju <naresh.kamboju@linaro.org>
Cc: stable@vger.kernel.org
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
Acked-by: Todd Kjos <tkjos@google.com>
Link: https://lore.kernel.org/r/20200311105309.1742827-1-christian.brauner@ubuntu.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 211b64e4b5b6bd5fdc19cd525c2cc9a90e6b0ec9)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: Idb5e9e8945fa95506f3ff4f15bde3efaf65d7c9f
2020-11-16 07:43:08 +01:00
..
binder_alloc_selftest.c FROMGIT: binder: print warnings when detecting oneway spamming. 2020-09-10 16:54:59 +00:00
binder_alloc.c FROMGIT: binder: print warnings when detecting oneway spamming. 2020-09-10 16:54:59 +00:00
binder_alloc.h FROMGIT: binder: print warnings when detecting oneway spamming. 2020-09-10 16:54:59 +00:00
binder_internal.h
binder_trace.h
binder.c UPSTREAM: binder: fix UAF when releasing todo list 2020-10-17 13:15:39 +02:00
binderfs.c UPSTREAM: binderfs: use refcount for binder control devices too 2020-11-16 07:43:08 +01:00
Kconfig
Makefile