From: gerben@altlinux.org
To: philmd@linaro.org, andrew@openedhand.com,
richard.henderson@linaro.org, qemu-devel@nongnu.org
Cc: sdl.qemu@linuxtesting.org, Denis Rastyogin <gerben@altlinux.org>,
Denis Sergeev <zeff@altlinux.org>
Subject: [PATCH] target/arm/tcg: fix potential integer overflow in iwmmxt_macuw()
Date: Thu, 12 Dec 2024 17:27:09 +0300 [thread overview]
Message-ID: <20241212142716.523980-1-gerben@altlinux.org> (raw)
From: Denis Rastyogin <gerben@altlinux.org>
The function iwmmxt_macuw() could potentially cause an integer
overflow when summing up four 32-bit multiplications.
This occurs because the intermediate results may exceed the 32-bit
range before being cast to uint64_t. The fix ensures each
multiplication is explicitly cast to uint64_t prior to summation,
preventing potential issues and ensuring correctness.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Signed-off-by: Denis Sergeev <zeff@altlinux.org>
Signed-off-by: Denis Rastyogin <gerben@altlinux.org>
---
target/arm/tcg/iwmmxt_helper.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/target/arm/tcg/iwmmxt_helper.c b/target/arm/tcg/iwmmxt_helper.c
index 610b1b2103..19c709655e 100644
--- a/target/arm/tcg/iwmmxt_helper.c
+++ b/target/arm/tcg/iwmmxt_helper.c
@@ -140,7 +140,7 @@ uint64_t HELPER(iwmmxt_macsw)(uint64_t a, uint64_t b)
uint64_t HELPER(iwmmxt_macuw)(uint64_t a, uint64_t b)
{
-#define MACU(SHR) ( \
+#define MACU(SHR) (uint64_t)( \
(uint32_t) ((a >> SHR) & 0xffff) * \
(uint32_t) ((b >> SHR) & 0xffff))
return MACU(0) + MACU(16) + MACU(32) + MACU(48);
--
2.42.2
next reply other threads:[~2024-12-12 14:28 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-12 14:27 gerben [this message]
2024-12-12 14:54 ` [PATCH] target/arm/tcg: fix potential integer overflow in iwmmxt_macuw() Richard Henderson
2024-12-13 16:16 ` Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241212142716.523980-1-gerben@altlinux.org \
--to=gerben@altlinux.org \
--cc=andrew@openedhand.com \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=sdl.qemu@linuxtesting.org \
--cc=zeff@altlinux.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.