hw/misc/aspeed_hace: Fix OOB read in has_padding()
PATCH 1/1 hw/misc/aspeed_hace: Fix OOB read in has_padding()
When total_msg_len equals total_req_len, padding_size is 0, making pad_offset equal to req_len. The subsequent padding[pad_offset] read accesses one byte past the buffer. Return false early when padding_size is zero.
Fixes 5cd7d8564a8b ("aspeed/hace: Support AST2600 HACE")
Reported-by Christopher Boker <[email protected]>
Signed-off-by Cédric Le Goater <[email protected]>
--- hw/misc/aspeed_hace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/misc/aspeed_hace.c +1 -1
@@ -225,7 +225,7 @@ static bool has_padding(AspeedHACEState *s, struct iovec *iov,uint32_t padding_size = s->total_req_len - *total_msg_len;uint8_t *padding = iov->iov_base; -if (padding_size > req_len) { +if (padding_size ==0 || padding_size > req_len) {return false; }
Signature · 1 line
2.55.0
Quoted 28 lines
Subject: [PATCH] hw/misc/aspeed_hace: Fix OOB read in
has_padding()When
total_msg_lenequalstotal_req_len,padding_sizeis 0, makingpad_offsetequal toreq_len. The subsequent padding[pad_offset] read accesses one byte past the buffer. Return false early whenpadding_sizeis zero.Fixes 5cd7d8564a8b ("aspeed/hace: Support AST2600 HACE")Reported-by Christopher Boker <[email protected]>Signed-off-by Cédric Le Goater <[email protected]>--- hw/misc/aspeed_hace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/misc/aspeed_hace.c index renamed from hw/misc/aspeed_hace.c +0
-0
8de05a9d98b3..bf8af710335d100644hw/misc/aspeed_hace.c +1
-2@@ -225,7 +225,7 @@ static bool has_padding(AspeedHACEState *s, structiovec *iov, uint32_t padding_size = s->total_req_len - *total_msg_len;uint8_t *padding = iov->iov_base; -if (padding_size > req_len) { +if (padding_size ==0 || padding_size > req_len) {return false; } --
Quoted 1 line
2.55.0
Reviewed-by Jamin Lin <[email protected]>
Thanks,
Jamin