[PATCH] hw/intc/exynos4210_combiner: Fix out of bounds access

Samanyu Goel posted 1 patch 1 month ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20261019155519.1302964-1-samanyu.goel16@gmail.com
Maintainers: Peter Maydell <peter.maydell@linaro.org>
hw/intc/exynos4210_combiner.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] hw/intc/exynos4210_combiner: Fix out of bounds access
Posted by Samanyu Goel 1 month ago
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].

Signed-off-by: Samanyu Goel <samanyu.goel16@gmail.com>
---
 hw/intc/exynos4210_combiner.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/intc/exynos4210_combiner.c b/hw/intc/exynos4210_combiner.c
index dbbdee4d31..458949e8bb 100644
--- a/hw/intc/exynos4210_combiner.c
+++ b/hw/intc/exynos4210_combiner.c
@@ -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);
-- 
2.53.0
Re: [PATCH] hw/intc/exynos4210_combiner: Fix out of bounds access
Posted by Peter Maydell 1 month ago
On Mon, 19 Oct 2026 at 16:55, Samanyu Goel <samanyu.goel16@gmail.com> wrote:
>
> 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].
>
> Signed-off-by: Samanyu Goel <samanyu.goel16@gmail.com>
> ---

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
Re: [PATCH] hw/intc/exynos4210_combiner: Fix out of bounds access
Posted by Samanyu Goel 1 month ago
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

On Mon, Oct 19, 2026, 21:46 Peter Maydell <peter.maydell@linaro.org> wrote:

> On Mon, 19 Oct 2026 at 16:55, Samanyu Goel <samanyu.goel16@gmail.com>
> wrote:
> >
> > 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].
> >
> > Signed-off-by: Samanyu Goel <samanyu.goel16@gmail.com>
> > ---
>
> 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
>
Re: [PATCH] hw/intc/exynos4210_combiner: Fix out of bounds access
Posted by Peter Maydell 1 month ago
On Mon, 19 Oct 2026 at 17:25, Samanyu Goel <samanyu.goel16@gmail.com> wrote:
>
> 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/20261019162217.3272337-1-peter.maydell@linaro.org/

-- PMM
Re: [PATCH] hw/intc/exynos4210_combiner: Fix out of bounds access
Posted by Samanyu Goel 1 month ago
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

On Mon, Oct 19, 2026, 22:00 Peter Maydell <peter.maydell@linaro.org> wrote:

> On Mon, 19 Oct 2026 at 17:25, Samanyu Goel <samanyu.goel16@gmail.com>
> wrote:
> >
> > 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/20261019162217.3272337-1-peter.maydell@linaro.org/
>
> -- PMM
>