Skip to content

Commit 1698174

Browse files
Todd Kjosgregkh
authored andcommitted
binder: fix incorrect calculation for num_valid
For BINDER_TYPE_PTR and BINDER_TYPE_FDA transactions, the num_valid local was calculated incorrectly causing the range check in binder_validate_ptr() to miss out-of-bounds offsets. Fixes: bde4a19 ("binder: use userspace pointer as base of buffer space") Signed-off-by: Todd Kjos <[email protected]> Cc: stable <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 3e42fe5 commit 1698174

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/android/binder.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3310,7 +3310,7 @@ static void binder_transaction(struct binder_proc *proc,
33103310
binder_size_t parent_offset;
33113311
struct binder_fd_array_object *fda =
33123312
to_binder_fd_array_object(hdr);
3313-
size_t num_valid = (buffer_offset - off_start_offset) *
3313+
size_t num_valid = (buffer_offset - off_start_offset) /
33143314
sizeof(binder_size_t);
33153315
struct binder_buffer_object *parent =
33163316
binder_validate_ptr(target_proc, t->buffer,
@@ -3384,7 +3384,7 @@ static void binder_transaction(struct binder_proc *proc,
33843384
t->buffer->user_data + sg_buf_offset;
33853385
sg_buf_offset += ALIGN(bp->length, sizeof(u64));
33863386

3387-
num_valid = (buffer_offset - off_start_offset) *
3387+
num_valid = (buffer_offset - off_start_offset) /
33883388
sizeof(binder_size_t);
33893389
ret = binder_fixup_parent(t, thread, bp,
33903390
off_start_offset,

0 commit comments

Comments
 (0)