qemu/hw/dma
Peter Maydell a7d8244be9 hw/dma/xlnx_dpdma: Read descriptor into buffer, not into pointer-to-buffer
In fdf029762f we factored out the handling of reading and writing
DMA descriptors from guest memory.  Unfortunately we accidentally
made the descriptor-read read the descriptor into the address of the
buffer rather than into the buffer, because we didn't notice we
needed to update the arguments to the dma_memory_read() call. Before
the refactoring, "&desc" is the address of a local struct DPDMADescriptor
variable in xlnx_dpdma_start_operation(), which is the correct target
for the guest-memory-read. But after the refactoring 'desc' is the
"DPDMADescriptor *desc" argument to the new function, and so it is
already an address.

This bug is an overrun of a stack variable, since a pointer is at
most 8 bytes long and we try to read 64 bytes, as well as being
incorrect behaviour.

Pass 'desc' rather than '&desc' as the dma_memory_read() argument
to fix this.

(The same bug is not present in xlnx_dpdma_write_descriptor(),
because there we are writing the descriptor from a local struct
variable "DPDMADescriptor tmp_desc" and so passing &tmp_desc to
dma_memory_write() is correct.)

Spotted by Coverity: CID 1546649

Fixes: fdf029762f ("xlnx_dpdma: fix descriptor endianness bug")
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@amd.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20240531124628.476938-1-peter.maydell@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
2024-06-04 11:53:43 +02: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_csu_dma.c hw/dma: Constify VMState 2023-12-29 11:17:30 +11:00
xlnx_dpdma.c hw/dma/xlnx_dpdma: Read descriptor into buffer, not into pointer-to-buffer 2024-06-04 11:53:43 +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