mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-28 03:40:04 +00:00
binder: fix handling of error during copy
[ Upstream commitfe6b186924
] 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:bb4a2e48d5
("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>
This commit is contained in:
parent
f3c2c7f3f8
commit
48fc8eebd1
1 changed files with 2 additions and 2 deletions
|
@ -2660,8 +2660,8 @@ static int binder_translate_fd_array(struct binder_fd_array_object *fda,
|
||||||
if (!ret)
|
if (!ret)
|
||||||
ret = binder_translate_fd(fd, offset, t, thread,
|
ret = binder_translate_fd(fd, offset, t, thread,
|
||||||
in_reply_to);
|
in_reply_to);
|
||||||
if (ret < 0)
|
if (ret)
|
||||||
return ret;
|
return ret > 0 ? -EINVAL : ret;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue