Skip to contentSkip to conversation

binder: fix handling of misaligned binder object

PATCH In review Todd Kjos 2 participants 2 messages Feb 14, 2019 – Feb 15, 2019 Android drivers

lore
Share & tools
lore

Todd Kjos

author maintainer
#0 lore raw

PATCH 1/1 binder: fix handling of misaligned binder object

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

---
Applies to linux-next

 drivers/android/binder.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/android/binder.c +1 -1
index 2dba539eb792c..8685882da64cd 100644
@@ -2057,7 +2057,7 @@ static size_t binder_get_object(struct binder_proc *proc,
 	size_t object_size = 0;
 
 	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;
 	binder_alloc_copy_from_buffer(&proc->alloc, object, buffer,
 				      offset, read_size);
Signature · 1 line
2.21.0.rc0.258.g878e2cd30e-goog
maintainer
#1 lore raw
Quoted 4 lines · Todd Kjos

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

Reported-by [email protected]

As the bot asked, this should be:

Reported-and-tested-by [email protected]

I'll go fix that up...

thanks,

greg k-h