yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-hw-arm-smmuv3-Fix-potential-integer-overflow-CID-143.patch

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