summaryrefslogtreecommitdiff
path: root/drivers/android
diff options
context:
space:
mode:
authorEric Biggers <ebiggers@google.com>2018-01-31 10:11:24 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-02-16 13:15:44 +0300
commitf88982679f54f75daa5b8eff3da72508f1e7422f (patch)
treefe9af10dcb73db2bea487a81e71c1cc091f786e2 /drivers/android
parent7928b2cbe55b2a410a0f5c1f154610059c57b1b2 (diff)
downloadlinux-f88982679f54f75daa5b8eff3da72508f1e7422f.tar.xz
binder: check for binder_thread allocation failure in binder_poll()
If the kzalloc() in binder_get_thread() fails, binder_poll() dereferences the resulting NULL pointer. Fix it by returning POLLERR if the memory allocation failed. This bug was found by syzkaller using fault injection. Reported-by: syzbot <syzkaller@googlegroups.com> Fixes: 457b9a6f09f0 ("Staging: android: add binder driver") Cc: stable@vger.kernel.org Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/android')
-rw-r--r--drivers/android/binder.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/android/binder.c b/drivers/android/binder.c
index 15e3d3c2260d..ad5e662e3e14 100644
--- a/drivers/android/binder.c
+++ b/drivers/android/binder.c
@@ -4391,6 +4391,8 @@ static __poll_t binder_poll(struct file *filp,
bool wait_for_proc_work;
thread = binder_get_thread(proc);
+ if (!thread)
+ return POLLERR;
binder_inner_proc_lock(thread->proc);
thread->looper |= BINDER_LOOPER_STATE_POLL;