Skip to content

Commit d4bdf5e

Browse files
sohu0106smb49
authored andcommitted
macintosh/adb: fix oob read in do_adb_query() function
BugLink: https://bugs.launchpad.net/bugs/1989230 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 <stable@kernel.org> Signed-off-by: Ning Qiang <sohu0106@126.com> Reviewed-by: Kees Cook <keescook@chromium.org> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://lore.kernel.org/r/20220713153734.2248-1-sohu0106@126.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Kamal Mostafa <kamal@canonical.com> Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
1 parent 717d283 commit d4bdf5e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/macintosh/adb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ do_adb_query(struct adb_request *req)
647647

648648
switch(req->data[1]) {
649649
case ADB_QUERY_GETDEVINFO:
650-
if (req->nbytes < 3)
650+
if (req->nbytes < 3 || req->data[2] >= 16)
651651
break;
652652
mutex_lock(&adb_handler_mutex);
653653
req->reply[0] = adb_handler[req->data[2]].original_address;

0 commit comments

Comments
 (0)