Skip to content

Commit

Permalink
macintosh/adb: fix oob read in do_adb_query() function
Browse files Browse the repository at this point in the history
commit fd97e4a upstream.

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]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
sohu0106 authored and gregkh committed Aug 11, 2022
1 parent 75742ff commit e5b556a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/macintosh/adb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit e5b556a

Please sign in to comment.