qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] exynos: Fix out-of-bounds access in exynos4210_gcomp_find
@ 2023-04-04  7:45 Feng Jiang
  2023-04-11 13:02 ` Peter Maydell
  0 siblings, 1 reply; 3+ messages in thread
From: Feng Jiang @ 2023-04-04  7:45 UTC (permalink / raw)
  To: i.mitsyanko, peter.maydell; +Cc: qemu-arm, qemu-devel, Feng Jiang

When 'res' equals -1, the array 's->g_timer.reg.comp[]' is accessed
out of bounds.

Signed-off-by: Feng Jiang <jiangfeng@kylinos.cn>
---
 hw/timer/exynos4210_mct.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/hw/timer/exynos4210_mct.c b/hw/timer/exynos4210_mct.c
index c17b247da3..446bbd2b96 100644
--- a/hw/timer/exynos4210_mct.c
+++ b/hw/timer/exynos4210_mct.c
@@ -480,11 +480,14 @@ static int32_t exynos4210_gcomp_find(Exynos4210MCTState *s)
         res = min_comp_i;
     }
 
-    DPRINTF("found comparator %d: comp 0x%llx distance 0x%llx, gfrc 0x%llx\n",
-            res,
-            s->g_timer.reg.comp[res],
-            distance_min,
-            gfrc);
+    if (res >= 0) {
+        DPRINTF("found comparator %d: "
+                "comp 0x%llx distance 0x%llx, gfrc 0x%llx\n",
+                res,
+                s->g_timer.reg.comp[res],
+                distance_min,
+                gfrc);
+    }
 
     return res;
 }
-- 
2.39.2



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] exynos: Fix out-of-bounds access in exynos4210_gcomp_find
  2023-04-04  7:45 [PATCH] exynos: Fix out-of-bounds access in exynos4210_gcomp_find Feng Jiang
@ 2023-04-11 13:02 ` Peter Maydell
  2023-04-14  1:11   ` Feng Jiang
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Maydell @ 2023-04-11 13:02 UTC (permalink / raw)
  To: Feng Jiang; +Cc: i.mitsyanko, qemu-arm, qemu-devel

On Tue, 4 Apr 2023 at 08:45, Feng Jiang <jiangfeng@kylinos.cn> wrote:
>
> When 'res' equals -1, the array 's->g_timer.reg.comp[]' is accessed
> out of bounds.
>
> Signed-off-by: Feng Jiang <jiangfeng@kylinos.cn>
> ---
>  hw/timer/exynos4210_mct.c | 13 ++++++++-----
>  1 file changed, 8 insertions(+), 5 deletions(-)

Only happens if you change the source code to enable the debug
printfs though, which isn't the default. I'll tweak the
commit message to make that clearer.

Applied to target-arm.next for 8.1, thanks.

-- PMM


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] exynos: Fix out-of-bounds access in exynos4210_gcomp_find
  2023-04-11 13:02 ` Peter Maydell
@ 2023-04-14  1:11   ` Feng Jiang
  0 siblings, 0 replies; 3+ messages in thread
From: Feng Jiang @ 2023-04-14  1:11 UTC (permalink / raw)
  To: Peter Maydell; +Cc: i.mitsyanko, qemu-arm, qemu-devel

On Tue, 2023-04-11 at 14:02 +0100, Peter Maydell wrote:
> On Tue, 4 Apr 2023 at 08:45, Feng Jiang <jiangfeng@kylinos.cn> wrote:
> > 
> > When 'res' equals -1, the array 's->g_timer.reg.comp[]' is accessed
> > out of bounds.
> > 
> > Signed-off-by: Feng Jiang <jiangfeng@kylinos.cn>
> > ---
> >  hw/timer/exynos4210_mct.c | 13 ++++++++-----
> >  1 file changed, 8 insertions(+), 5 deletions(-)
> 
> Only happens if you change the source code to enable the debug
> printfs though, which isn't the default. I'll tweak the
> commit message to make that clearer.
> 
> Applied to target-arm.next for 8.1, thanks.
> 
> -- PMM
> 
Hi Peter, Thanks very much for your review!

Next time I will write the commit message more clearly and in detail.

Best regards,
Feng


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-04-14  1:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-04  7:45 [PATCH] exynos: Fix out-of-bounds access in exynos4210_gcomp_find Feng Jiang
2023-04-11 13:02 ` Peter Maydell
2023-04-14  1:11   ` Feng Jiang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).