提交 c7e9561f 编写于 作者: T Todd Kjos 提交者: Zheng Zengkai

binder: fix handling of error during copy

stable inclusion
from stable-v5.10.94
commit 551a785c26f6ff41cccd527e7bd9f032f91332c2
bugzilla: https://gitee.com/openeuler/kernel/issues/I531X9

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=551a785c26f6ff41cccd527e7bd9f032f91332c2

--------------------------------

[ Upstream commit fe6b1869 ]

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: bb4a2e48 ("binder: return errors from buffer copy functions")
Suggested-by: NDan Carpenter <dan.carpenter@oracle.com>
Acked-by: NChristian Brauner <christian.brauner@ubuntu.com>
Signed-off-by: NTodd Kjos <tkjos@google.com>
Link: https://lore.kernel.org/r/20211130185152.437403-2-tkjos@google.comSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
Acked-by: NXie XiuQi <xiexiuqi@huawei.com>
上级 8738029d
...@@ -2657,8 +2657,8 @@ static int binder_translate_fd_array(struct binder_fd_array_object *fda, ...@@ -2657,8 +2657,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;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册