Skip to content

Commit

Permalink
binder: check for binder_thread allocation failure in binder_poll()
Browse files Browse the repository at this point in the history
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: 457b9a6 ("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>
  • Loading branch information
ebiggers authored and gregkh committed Feb 16, 2018
1 parent 7928b2c commit f889826
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/android/binder.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit f889826

Please sign in to comment.