[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20211130185152.437403-2-tkjos@google.com>
Date: Tue, 30 Nov 2021 10:51:49 -0800
From: Todd Kjos <tkjos@...gle.com>
To: tkjos@...gle.com, gregkh@...uxfoundation.org, christian@...uner.io,
arve@...roid.com, devel@...verdev.osuosl.org,
linux-kernel@...r.kernel.org, maco@...gle.com
Cc: joel@...lfernandes.org, kernel-team@...roid.com, avakj45@...il.com,
Dan Carpenter <dan.carpenter@...cle.com>
Subject: [PATCH v2 1/4] binder: fix handling of error during copy
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@...cle.com>
Signed-off-by: Todd Kjos <tkjos@...gle.com>
---
v2: Added this patch to fix bug noticed by Dan Carpenter
drivers/android/binder.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/android/binder.c b/drivers/android/binder.c
index 49fb74196d02..984e6263dcc7 100644
--- a/drivers/android/binder.c
+++ b/drivers/android/binder.c
@@ -2269,8 +2269,8 @@ static int binder_translate_fd_array(struct binder_fd_array_object *fda,
if (!ret)
ret = binder_translate_fd(fd, offset, t, thread,
in_reply_to);
- if (ret < 0)
- return ret;
+ if (ret)
+ return ret > 0 ? -EINVAL : ret;
}
return 0;
}
--
2.34.0.rc2.393.gf8c9666880-goog
Powered by blists - more mailing lists