Skip to contentSkip to conversation

hw/intc/exynos4210_combiner: Fix out of bounds access

PATCH In review Samanyu Goel 2 participants 5 messages Oct 19 Arm Samsung Exynos

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/intc/exynos4210_combiner: Fix out of bounds access

In exynos4210_combiner_write(), the bounds check used req_quad_base_n instead of grp_quad_base_n. Because req_quad_base_n counts 4-group blocks rather than individual groups, invalid offsets were allowed through.

For example, writing to offset 0x100 resulted in req_quad_base_n = 16, passing the check (16 < 64). As verified in GDB, this caused grp_quad_base_n to reach 64, leading to an out-of-bounds write at s->group[64].

---
 hw/intc/exynos4210_combiner.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/intc/exynos4210_combiner.c +1 -1
index dbbdee4d31..458949e8bb 100644
@@ -184,7 +184,7 @@ static void exynos4210_combiner_write(void *opaque, hwaddr offset,
     grp_quad_base_n = req_quad_base_n << 2;
     reg_n = (offset - (req_quad_base_n << 4)) >> 2;
 
-    if (req_quad_base_n >= IIC_NGRP) {
+    if (grp_quad_base_n >= IIC_NGRP) {
         qemu_log_mask(LOG_GUEST_ERROR,
                       "exynos4210.combiner: unallowed write access at offset 0x"
                       HWADDR_FMT_plx "\n", offset);
Signature · 1 line
2.53.0
#1 lore raw
Quoted 5 lines · Samanyu Goel

In exynos4210_combiner_write(), the bounds check used req_quad_base_n instead of grp_quad_base_n. Because req_quad_base_n counts 4-group blocks rather than individual groups, invalid offsets were allowed through.

Quoted 7 lines

For example, writing to offset 0x100 resulted in req_quad_base_n = 16, passing the check (16 < 64). As verified in GDB, this caused grp_quad_base_n to reach 64, leading to an out-of-bounds write at s->group[64].

---

This is https://gitlab.com/qemu-project/qemu/-/work_items/4709.

You've missed the equivalent check in the read function.

As it happens I was working on this bug this afternoon; I have a patch nearly ready to send which fixes this and also cleans up some other oddities about the checks in these functions.

thanks
-- PMM

#2 lore raw

Thanks Peter! Good catch on the read function, I totally missed that part of it while focusing just on the main issue.

It makes complete sense to clean up both functions together in your fix. This was a great learning experience for me, so thank you for taking the time to review and share feedback.

Best,
Samanyu

Quoted 26 lines · On Mon, Oct 19, 2026, 21:46 Peter Maydell <[email protected]> wrote:
Quoted 5 lines · Samanyu Goel

In exynos4210_combiner_write(), the bounds check used req_quad_base_n instead of grp_quad_base_n. Because req_quad_base_n counts 4-group blocks rather than individual groups, invalid offsets were allowed through.

Quoted 7 lines

For example, writing to offset 0x100 resulted in req_quad_base_n = 16, passing the check (16 < 64). As verified in GDB, this caused grp_quad_base_n to reach 64, leading to an out-of-bounds write at s->group[64].

---

This is https://gitlab.com/qemu-project/qemu/-/work_items/4709.

You've missed the equivalent check in the read function.

As it happens I was working on this bug this afternoon; I have a patch nearly ready to send which fixes this and also cleans up some other oddities about the checks in these functions.

thanks
-- PMM

#3 lore raw
Quoted 4 lines · Samanyu Goel

Thanks Peter! Good catch on the read function, I totally missed that part of it while focusing just on the main issue.

It makes complete sense to clean up both functions together in your fix. This was a great learning experience for me, so thank you for taking the time to review and share feedback.

No worries, and sorry that we ended up duplicating effort. I've got a bit lazy about not assigning issues in gitlab to myself before starting work on them, I should be more careful about that.

I've just posted my series, if you're interested:
https://patchew.org/QEMU/[email protected]/

-- PMM

#4 lore raw

No worries at all, Peter. Since this was my first contribution, tracing the bug, writing the fix, and going through the mailing list workflow was a fantastic learning experience for me. Thanks again for the feedback and for sharing the series link, I'll definitely check it out.

Best,
Samanyu

Quoted 19 lines · On Mon, Oct 19, 2026, 22:00 Peter Maydell <[email protected]> wrote:
Quoted 2 lines · Samanyu Goel

Thanks Peter! Good catch on the read function, I totally missed that

part of it while focusing just on the main issue.

Quoted 2 lines

It makes complete sense to clean up both functions together in your fix.

This was a great learning experience for me, so thank you for taking the time to review and share feedback.

No worries, and sorry that we ended up duplicating effort. I've got a bit lazy about not assigning issues in gitlab to myself before starting work on them, I should be more careful about that.

I've just posted my series, if you're interested:
https://patchew.org/QEMU/[email protected]/

-- PMM