aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNing Qiang <[email protected]>2022-07-13 23:37:34 +0800
committerMichael Ellerman <[email protected]>2022-07-20 22:06:30 +1000
commitfd97e4ad6d3b0c9fce3bca8ea8e6969d9ce7423b (patch)
treedf089f6c7100960025943d87557a07155a79bb88
parent69472ffa6575e3a1c1e3324dd06395af0f63eb71 (diff)
macintosh/adb: fix oob read in do_adb_query() function
In do_adb_query() function of drivers/macintosh/adb.c, req->data is copied 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. Cc: stable <[email protected]> Signed-off-by: Ning Qiang <[email protected]> Reviewed-by: Kees Cook <[email protected]> Reviewed-by: Greg Kroah-Hartman <[email protected]> Acked-by: Benjamin Herrenschmidt <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://lore.kernel.org/r/[email protected]
-rw-r--r--drivers/macintosh/adb.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/macintosh/adb.c b/drivers/macintosh/adb.c
index 439fab4eaa85..1bbb9ca08d40 100644
--- a/drivers/macintosh/adb.c
+++ b/drivers/macintosh/adb.c
@@ -647,7 +647,7 @@ do_adb_query(struct adb_request *req)
switch(req->data[1]) {
case ADB_QUERY_GETDEVINFO:
- if (req->nbytes < 3)
+ if (req->nbytes < 3 || req->data[2] >= 16)
break;
mutex_lock(&adb_handler_mutex);
req->reply[0] = adb_handler[req->data[2]].original_address;