Commit 26528be6 authored by Todd Kjos's avatar Todd Kjos Committed by Greg Kroah-Hartman

binder: fix handling of misaligned binder object

Fixes crash found by syzbot:
kernel BUG at drivers/android/binder_alloc.c:LINE! (2)

Reported-and-tested-by: syzbot+55de1eb4975dec156d8f@syzkaller.appspotmail.com
Signed-off-by: default avatarTodd Kjos <tkjos@google.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 36f30937
...@@ -2057,7 +2057,7 @@ static size_t binder_get_object(struct binder_proc *proc, ...@@ -2057,7 +2057,7 @@ static size_t binder_get_object(struct binder_proc *proc,
size_t object_size = 0; size_t object_size = 0;
read_size = min_t(size_t, sizeof(*object), buffer->data_size - offset); read_size = min_t(size_t, sizeof(*object), buffer->data_size - offset);
if (read_size < sizeof(*hdr)) if (read_size < sizeof(*hdr) || !IS_ALIGNED(offset, sizeof(u32)))
return 0; return 0;
binder_alloc_copy_from_buffer(&proc->alloc, object, buffer, binder_alloc_copy_from_buffer(&proc->alloc, object, buffer,
offset, read_size); offset, read_size);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment