|
|
8fced6 |
From 69d71311d3d70282dec3d1f19f9e4b90c7b7c6b9 Mon Sep 17 00:00:00 2001
|
|
|
8fced6 |
From: eperezma <eperezma@redhat.com>
|
|
|
8fced6 |
Date: Tue, 12 Jan 2021 14:36:33 -0500
|
|
|
8fced6 |
Subject: [PATCH 09/17] hw/arm/smmuv3: Fix potential integer overflow (CID
|
|
|
8fced6 |
1432363)
|
|
|
8fced6 |
MIME-Version: 1.0
|
|
|
8fced6 |
Content-Type: text/plain; charset=UTF-8
|
|
|
8fced6 |
Content-Transfer-Encoding: 8bit
|
|
|
8fced6 |
|
|
|
8fced6 |
RH-Author: eperezma <eperezma@redhat.com>
|
|
|
8fced6 |
Message-id: <20210112143638.374060-9-eperezma@redhat.com>
|
|
|
8fced6 |
Patchwork-id: 100601
|
|
|
8fced6 |
O-Subject: [RHEL-8.4.0 qemu-kvm PATCH v2 08/13] hw/arm/smmuv3: Fix potential integer overflow (CID 1432363)
|
|
|
8fced6 |
Bugzilla: 1843852
|
|
|
8fced6 |
RH-Acked-by: Xiao Wang <jasowang@redhat.com>
|
|
|
8fced6 |
RH-Acked-by: Peter Xu <peterx@redhat.com>
|
|
|
8fced6 |
RH-Acked-by: Auger Eric <eric.auger@redhat.com>
|
|
|
8fced6 |
|
|
|
8fced6 |
From: Philippe Mathieu-Daudé <philmd@redhat.com>
|
|
|
8fced6 |
|
|
|
8fced6 |
Use the BIT_ULL() macro to ensure we use 64-bit arithmetic.
|
|
|
8fced6 |
This fixes the following Coverity issue (OVERFLOW_BEFORE_WIDEN):
|
|
|
8fced6 |
|
|
|
8fced6 |
CID 1432363 (#1 of 1): Unintentional integer overflow:
|
|
|
8fced6 |
|
|
|
8fced6 |
overflow_before_widen:
|
|
|
8fced6 |
Potentially overflowing expression 1 << scale with type int
|
|
|
8fced6 |
(32 bits, signed) is evaluated using 32-bit arithmetic, and
|
|
|
8fced6 |
then used in a context that expects an expression of type
|
|
|
8fced6 |
hwaddr (64 bits, unsigned).
|
|
|
8fced6 |
|
|
|
8fced6 |
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
|
|
|
8fced6 |
Acked-by: Eric Auger <eric.auger@redhat.com>
|
|
|
8fced6 |
Message-id: 20201030144617.1535064-1-philmd@redhat.com
|
|
|
8fced6 |
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
|
|
|
8fced6 |
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
|
|
|
8fced6 |
(cherry picked from commit 744a790ec01a30033309e6a2155df4d61061e184)
|
|
|
8fced6 |
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
|
|
|
8fced6 |
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
|
|
|
8fced6 |
---
|
|
|
8fced6 |
hw/arm/smmuv3.c | 3 ++-
|
|
|
8fced6 |
1 file changed, 2 insertions(+), 1 deletion(-)
|
|
|
8fced6 |
|
|
|
8fced6 |
diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c
|
|
|
8fced6 |
index f4d5d9d8222..a418fab2aa6 100644
|
|
|
8fced6 |
--- a/hw/arm/smmuv3.c
|
|
|
8fced6 |
+++ b/hw/arm/smmuv3.c
|
|
|
8fced6 |
@@ -17,6 +17,7 @@
|
|
|
8fced6 |
*/
|
|
|
8fced6 |
|
|
|
8fced6 |
#include "qemu/osdep.h"
|
|
|
8fced6 |
+#include "qemu/bitops.h"
|
|
|
8fced6 |
#include "hw/irq.h"
|
|
|
8fced6 |
#include "hw/sysbus.h"
|
|
|
8fced6 |
#include "migration/vmstate.h"
|
|
|
8fced6 |
@@ -847,7 +848,7 @@ static void smmuv3_s1_range_inval(SMMUState *s, Cmd *cmd)
|
|
|
8fced6 |
scale = CMD_SCALE(cmd);
|
|
|
8fced6 |
num = CMD_NUM(cmd);
|
|
|
8fced6 |
ttl = CMD_TTL(cmd);
|
|
|
8fced6 |
- num_pages = (num + 1) * (1 << (scale));
|
|
|
8fced6 |
+ num_pages = (num + 1) * BIT_ULL(scale);
|
|
|
8fced6 |
}
|
|
|
8fced6 |
|
|
|
8fced6 |
if (type == SMMU_CMD_TLBI_NH_VA) {
|
|
|
8fced6 |
--
|
|
|
8fced6 |
2.27.0
|
|
|
8fced6 |
|