From: Ning Qiang <hidden> Date: 2022-07-13 15:38:50
In do_adb_query function of drivers/macintosh/adb.c, req->data is copy
form userland. the parameter "req->data[2]" is Missing check, the
array size of adb_handler[] is 16, so "adb_handler[
req->data[2]].original_address" and "adb_handler[
req->data[2]].handler_id" will lead to oob read.
Signed-off-by: Ning Qiang <redacted>
---
drivers/macintosh/adb.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
On Wed, Jul 13, 2022 at 11:37:34PM +0800, Ning Qiang wrote:
In do_adb_query function of drivers/macintosh/adb.c, req->data is copy
form userland. the parameter "req->data[2]" is Missing check, the
array size of adb_handler[] is 16, so "adb_handler[
req->data[2]].original_address" and "adb_handler[
req->data[2]].handler_id" will lead to oob read.
Signed-off-by: Ning Qiang <redacted>
On Wed, Jul 13, 2022 at 11:37:34PM +0800, Ning Qiang wrote:
In do_adb_query function of drivers/macintosh/adb.c, req->data is copy
form userland. the parameter "req->data[2]" is Missing check, the
array size of adb_handler[] is 16, so "adb_handler[
req->data[2]].original_address" and "adb_handler[
req->data[2]].handler_id" will lead to oob read.
Signed-off-by: Ning Qiang <redacted>
Thanks for catching this!
Do you have a reproducer for this? I'd expect CONFIG_UBSAN_BOUNDS=y to
notice this at runtime, at least.
I'd prefer this was:
+ if (req->nbytes < 3 || req->data[2] >= ARRAY_SIZE(adb_handler))
so it's tied to the actual variable (if its size ever changes).
With that:
Reviewed-by: Kees Cook <redacted>
-Kees
From: Benjamin Herrenschmidt <benh@kernel.crashing.org> Date: 2022-07-14 22:35:52
On Wed, 2022-07-13 at 23:37 +0800, Ning Qiang wrote:
In do_adb_query function of drivers/macintosh/adb.c, req->data is
copy
form userland. the parameter "req->data[2]" is Missing check, the
array size of adb_handler[] is 16, so "adb_handler[
req->data[2]].original_address" and "adb_handler[
req->data[2]].handler_id" will lead to oob read.
Signed-off-by: Ning Qiang <redacted>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
From: Benjamin Herrenschmidt <benh@kernel.crashing.org> Date: 2022-07-14 22:36:13
On Wed, 2022-07-13 at 11:53 -0700, Kees Cook wrote:
On Wed, Jul 13, 2022 at 11:37:34PM +0800, Ning Qiang wrote:
quoted
In do_adb_query function of drivers/macintosh/adb.c, req->data is
copy
form userland. the parameter "req->data[2]" is Missing check, the
array size of adb_handler[] is 16, so "adb_handler[
req->data[2]].original_address" and "adb_handler[
req->data[2]].handler_id" will lead to oob read.
Signed-off-by: Ning Qiang <redacted>
Thanks for catching this!
Do you have a reproducer for this? I'd expect CONFIG_UBSAN_BOUNDS=y
to notice this at runtime, at least.
For that you would need an ancient Mac with an ADB bus which might be
tricky ... I have some in the basement that could possibly be revived
if you really insist but I'd rather not waste the time...
Cheers,
Ben.
I'd prefer this was:
+ if (req->nbytes < 3 || req->data[2] >=
ARRAY_SIZE(adb_handler))
so it's tied to the actual variable (if its size ever changes).
With that:
Reviewed-by: Kees Cook <redacted>
-Kees
From: Michael Ellerman <hidden> Date: 2022-07-29 13:23:08
On Wed, 13 Jul 2022 23:37:34 +0800, Ning Qiang wrote:
In do_adb_query function of drivers/macintosh/adb.c, req->data is copy
form userland. the parameter "req->data[2]" is Missing check, the
array size of adb_handler[] is 16, so "adb_handler[
req->data[2]].original_address" and "adb_handler[
req->data[2]].handler_id" will lead to oob read.
[...]