Skip to content

Commit ef38de9

Browse files
aleastogregkh
authored andcommitted
binder: Gracefully handle BINDER_TYPE_FDA objects with num_fds=0
Some android userspace is sending BINDER_TYPE_FDA objects with num_fds=0. Like the previous patch, this is reproducible when playing a video. Before commit 09184ae BINDER_TYPE_FDA objects with num_fds=0 were 'correctly handled', as in no fixup was performed. After commit 09184ae we aggregate fixup and skip regions in binder_ptr_fixup structs and distinguish between the two by using the skip_size field: if it's 0, then it's a fixup, otherwise skip. When processing BINDER_TYPE_FDA objects with num_fds=0 we add a skip region of skip_size=0, and this causes issues because now binder_do_deferred_txn_copies will think this was a fixup region. To address that, return early from binder_translate_fd_array to avoid adding an empty skip region. Fixes: 09184ae ("binder: defer copies of pre-patched txn data") Acked-by: Todd Kjos <[email protected]> Cc: stable <[email protected]> Signed-off-by: Alessandro Astone <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 2d1746e commit ef38de9

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/android/binder.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2491,6 +2491,9 @@ static int binder_translate_fd_array(struct list_head *pf_head,
24912491
struct binder_proc *proc = thread->proc;
24922492
int ret;
24932493

2494+
if (fda->num_fds == 0)
2495+
return 0;
2496+
24942497
fd_buf_size = sizeof(u32) * fda->num_fds;
24952498
if (fda->num_fds >= SIZE_MAX / sizeof(u32)) {
24962499
binder_user_error("%d:%d got transaction with invalid number of fds (%lld)\n",

0 commit comments

Comments
 (0)