[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH for-5.1] hw/arm/armsse: Assert info->num_cpus is in-bounds in arm
From: |
Peter Maydell |
Subject: |
[PATCH for-5.1] hw/arm/armsse: Assert info->num_cpus is in-bounds in armsse_realize() |
Date: |
Mon, 12 Oct 2020 16:33:33 +0100 |
In armsse_realize() we have a loop over [0, info->num_cpus), which
indexes into various fixed-size arrays in the ARMSSE struct. This
confuses Coverity, which warns that we might overrun those arrays
(CID 1430326, 1430337, 1430371, 1430414, 1430430). This can't
actually happen, because the info struct is always one of the entries
in the armsse_variants[] array and num_cpus is either 1 or 2; we also
already assert in armsse_init() that num_cpus is not too large.
However, adding an assert to armsse_realize() like the one in
armsse_init() should help Coverity figure out that these code paths
aren't possible.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
hw/arm/armsse.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/hw/arm/armsse.c b/hw/arm/armsse.c
index 64fcab895f7..dcbff9bd8f4 100644
--- a/hw/arm/armsse.c
+++ b/hw/arm/armsse.c
@@ -452,6 +452,8 @@ static void armsse_realize(DeviceState *dev, Error **errp)
return;
}
+ assert(info->num_cpus <= SSE_MAX_CPUS);
+
/* max SRAM_ADDR_WIDTH: 24 - log2(SRAM_NUM_BANK) */
assert(is_power_of_2(info->sram_banks));
addr_width_max = 24 - ctz32(info->sram_banks);
--
2.20.1
- Re: [PATCH] Deprecate TileGX port, (continued)
- [PATCH for-5.1] Makefile: Remove config-devices.mak on "make clean", Peter Maydell, 2020/10/12
- [PATCH] Deprecate lm32 port, Peter Maydell, 2020/10/12
- [PATCH] Deprecate Unicore32 port, Peter Maydell, 2020/10/12
- [PATCH RISU] arm.risu, thumb.risu: Add v8.2 DP and FHM insns, Peter Maydell, 2020/10/12
- [PATCH RISU] arm.risu: Add patterns for fp16 insns, Peter Maydell, 2020/10/12
- [PATCH 01/10] decodetree: Fix codegen for non-overlapping group inside overlapping group, Peter Maydell, 2020/10/12
- [PATCH for-5.1] docs/system/arm/virt: Document mte machine option, Peter Maydell, 2020/10/12
- [PATCH] configure: Test that gio libs from pkg-config work, Peter Maydell, 2020/10/12
- [PATCH for-5.1] hw/arm/armsse: Assert info->num_cpus is in-bounds in armsse_realize(),
Peter Maydell <=
- [PATCH for-5.1] hw/arm/netduino2, netduinoplus2: Set system_clock_scale, Peter Maydell, 2020/10/12
[PATCH for-5.1] hw/arm/nrf51_soc: Set system_clock_scale, Peter Maydell, 2020/10/12
[PATCH] hw/arm/mps2: New board model mps2-386, Peter Maydell, 2020/10/12
[PATCH] hw/display/bcm2835_fb.c: Initialize all fields of struct, Peter Maydell, 2020/10/12
[PATCH] hw/intc/arm_gicv3_cpuif: Don't copy CPU's maintenance interrupt, Peter Maydell, 2020/10/12
[PATCH for-5.1] hw/timer/imx_epit: Avoid assertion when CR.SWR is written, Peter Maydell, 2020/10/12