Skip to content

Commit 551a785

Browse files
toddkjosgregkh
authored andcommitted
binder: fix handling of error during copy
[ Upstream commit fe6b186 ] If a memory copy function fails to copy the whole buffer, a positive integar with the remaining bytes is returned. In binder_translate_fd_array() this can result in an fd being skipped due to the failed copy, but the loop continues processing fds since the early return condition expects a negative integer on error. Fix by returning "ret > 0 ? -EINVAL : ret" to handle this case. Fixes: bb4a2e4 ("binder: return errors from buffer copy functions") Suggested-by: Dan Carpenter <dan.carpenter@oracle.com> Acked-by: Christian Brauner <christian.brauner@ubuntu.com> Signed-off-by: Todd Kjos <tkjos@google.com> Link: https://lore.kernel.org/r/20211130185152.437403-2-tkjos@google.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 88ddf03 commit 551a785

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎drivers/android/binder.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2657,8 +2657,8 @@ static int binder_translate_fd_array(struct binder_fd_array_object *fda,
26572657
if (!ret)
26582658
ret = binder_translate_fd(fd, offset, t, thread,
26592659
in_reply_to);
2660-
if (ret < 0)
2661-
return ret;
2660+
if (ret)
2661+
return ret > 0 ? -EINVAL : ret;
26622662
}
26632663
return 0;
26642664
}

0 commit comments

Comments
 (0)