Skip to content

Commit aaef738

Browse files
Carlos Llamasgregkh
authored andcommitted
binder: check offset alignment in binder_get_object()
Commit 6d98eb9 ("binder: avoid potential data leakage when copying txn") introduced changes to how binder objects are copied. In doing so, it unintentionally removed an offset alignment check done through calls to binder_alloc_copy_from_buffer() -> check_buffer(). These calls were replaced in binder_get_object() with copy_from_user(), so now an explicit offset alignment check is needed here. This avoids later complications when unwinding the objects gets harder. It is worth noting this check existed prior to commit 7a67a39 ("binder: add function to copy binder object from buffer"), likely removed due to redundancy at the time. Fixes: 6d98eb9 ("binder: avoid potential data leakage when copying txn") Cc: [email protected] Signed-off-by: Carlos Llamas <[email protected]> Acked-by: Todd Kjos <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent d171853 commit aaef738

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/android/binder.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1708,8 +1708,10 @@ static size_t binder_get_object(struct binder_proc *proc,
17081708
size_t object_size = 0;
17091709

17101710
read_size = min_t(size_t, sizeof(*object), buffer->data_size - offset);
1711-
if (offset > buffer->data_size || read_size < sizeof(*hdr))
1711+
if (offset > buffer->data_size || read_size < sizeof(*hdr) ||
1712+
!IS_ALIGNED(offset, sizeof(u32)))
17121713
return 0;
1714+
17131715
if (u) {
17141716
if (copy_from_user(object, u + offset, read_size))
17151717
return 0;

0 commit comments

Comments
 (0)