]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit
binder: fix handling of error during copy
authorTodd Kjos <tkjos@google.com>
Tue, 30 Nov 2021 18:51:49 +0000 (10:51 -0800)
committerPaolo Pisati <paolo.pisati@canonical.com>
Fri, 28 Jan 2022 10:00:06 +0000 (11:00 +0100)
commitc24dbaf6e907fa0093ce5c02adce58358465b99b
tree1bb2fdb14c38c4b4c845c7d76aa46927f56798e5
parent9446ef7558e4f790694020908f0c06f130fd1fe7
binder: fix handling of error during copy

BugLink: https://bugs.launchpad.net/bugs/1959376
[ Upstream commit fe6b1869243f23a485a106c214bcfdc7aa0ed593 ]

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: bb4a2e48d510 ("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>
Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
drivers/android/binder.c