qemu/hw/dma
Anastasia Belova c3a68dfd19 hw/dma: avoid apparent overflow in soc_dma_set_request
In soc_dma_set_request() we try to set a bit in a uint64_t, but we
do it with "1 << ch->num", which can't set any bits past 31;
any use for a channel number of 32 or more would fail due to
integer overflow.

This doesn't happen in practice for our current use of this code,
because the worst case is when we call soc_dma_init() with an
argument of 32 for the number of channels, and QEMU builds with
-fwrapv so the shift into the sign bit is well-defined. However,
it's obviously not the intended behaviour of the code.

Add casts to force the shift to be done as 64-bit arithmetic,
allowing up to 64 channels.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: afbb5194d4 ("Handle on-chip DMA controllers in one place, convert OMAP DMA to use it.")
Signed-off-by: Anastasia Belova <abelova@astralinux.ru>
Message-id: 20240409115301.21829-1-abelova@astralinux.ru
[PMM: Edit commit message to clarify that this doesn't actually
 bite us in our current usage of this code.]
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2024-04-25 10:21:06 +01:00
..
bcm2835_dma.c hw/dma: Constify VMState 2023-12-29 11:17:30 +11:00
etraxfs_dma.c hw/dma/etraxfs: Include missing 'exec/memory.h' header 2023-08-31 19:47:43 +02:00
i8257.c hw/dma: Pass parent object to i8257_dma_init() 2024-02-15 16:58:46 +01:00
i82374.c hw/dma: Pass parent object to i8257_dma_init() 2024-02-15 16:58:46 +01:00
Kconfig hw/dma: Implement a Xilinx CSU DMA model 2021-03-08 17:20:04 +00:00
meson.build meson: Replace softmmu_ss -> system_ss 2023-06-20 10:01:30 +02:00
omap_dma.c hw/other: spelling fixes 2023-09-21 11:31:16 +03:00
pl080.c hw/dma: Constify VMState 2023-12-29 11:17:30 +11:00
pl330.c hw/dma: Constify VMState 2023-12-29 11:17:30 +11:00
pxa2xx_dma.c hw/dma: Constify VMState 2023-12-29 11:17:30 +11:00
rc4030.c hw/dma: Constify VMState 2023-12-29 11:17:30 +11:00
sifive_pdma.c hw/dma: sifive_pdma: permit 4/8-byte access size of PDMA registers 2022-01-08 15:46:09 +10:00
soc_dma.c hw/dma: avoid apparent overflow in soc_dma_set_request 2024-04-25 10:21:06 +01:00
sparc32_dma.c hw/dma: Constify VMState 2023-12-29 11:17:30 +11:00
trace-events docs: fix references to docs/devel/tracing.rst 2021-06-02 06:51:09 +02:00
trace.h trace: switch position of headers to what Meson requires 2020-08-21 06:18:24 -04:00
xilinx_axidma.c hw/dma: Declare link using static DEFINE_PROP_LINK() macro 2023-10-19 23:13:28 +02:00
xlnx-zdma.c hw/dma: Constify VMState 2023-12-29 11:17:30 +11:00
xlnx-zynq-devcfg.c hw/dma: Constify VMState 2023-12-29 11:17:30 +11:00
xlnx_csu_dma.c hw/dma: Constify VMState 2023-12-29 11:17:30 +11:00
xlnx_dpdma.c hw/dma: Constify VMState 2023-12-29 11:17:30 +11:00