Re: [PATCH] macintosh:fix oob read in do_adb_query function

From
Benjamin Herrenschmidt <benh@kernel.crashing.org>
Date
2022-07-14 22:35:52
Reply to
Ning Qiang, 2022-07-13
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>
quoted hunk ↗ jump to hunk
---
 drivers/macintosh/adb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
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-
quoted
data[2]].original_address;
  
Thread (6 messages) 6 messages, 5 authors, last reply 2022-07-29
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help