1From 24aed6bcb6b6d266149591f955c2460c28759eb4 Mon Sep 17 00:00:00 2001 2From: =?utf8?q?Philippe=20Mathieu-Daud=C3=A9?= <philmd@redhat.com> 3Date: Fri, 17 Dec 2021 23:56:14 +0100 4Subject: [PATCH] dma: Let st*_dma() propagate MemTxResult 5MIME-Version: 1.0 6Content-Type: text/plain; charset=utf8 7Content-Transfer-Encoding: 8bit 8 9dma_memory_write() returns a MemTxResult type. Do not discard 10it, return it to the caller. 11 12CVE: CVE-2021-3611 13Upstream-Status: Backport [https://git.qemu.org/?p=qemu.git;a=commit;h=24aed6bcb6b6d266149591f955c2460c28759eb4] 14 15Reviewed-by: Richard Henderson <richard.henderson@linaro.org> 16Reviewed-by: Cédric Le Goater <clg@kaod.org> 17Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> 18Message-Id: <20211223115554.3155328-18-philmd@redhat.com> 19Signed-off-by: Bhabu Bindu <bhabu.bindu@kpit.com> 20--- 21 include/sysemu/dma.h | 20 ++++++++++---------- 22 1 file changed, 10 insertions(+), 10 deletions(-) 23 24diff --git a/include/sysemu/dma.h b/include/sysemu/dma.h 25index d1635f5..895044d 100644 26--- a/include/sysemu/dma.h 27+++ b/include/sysemu/dma.h 28@@ -248,13 +248,13 @@ static inline void dma_memory_unmap(AddressSpace *as, 29 dma_memory_read(as, addr, &val, (_bits) / 8, attrs); \ 30 return _end##_bits##_to_cpu(val); \ 31 } \ 32- static inline void st##_sname##_##_end##_dma(AddressSpace *as, \ 33- dma_addr_t addr, \ 34- uint##_bits##_t val, \ 35- MemTxAttrs attrs) \ 36- { \ 37- val = cpu_to_##_end##_bits(val); \ 38- dma_memory_write(as, addr, &val, (_bits) / 8, attrs); \ 39+ static inline MemTxResult st##_sname##_##_end##_dma(AddressSpace *as, \ 40+ dma_addr_t addr, \ 41+ uint##_bits##_t val, \ 42+ MemTxAttrs attrs) \ 43+ { \ 44+ val = cpu_to_##_end##_bits(val); \ 45+ return dma_memory_write(as, addr, &val, (_bits) / 8, attrs); \ 46 } 47 48 static inline uint8_t ldub_dma(AddressSpace *as, dma_addr_t addr, MemTxAttrs attrs) 49@@ -265,10 +265,10 @@ static inline uint8_t ldub_dma(AddressSpace *as, dma_addr_t addr, MemTxAttrs att 50 return val; 51 } 52 53-static inline void stb_dma(AddressSpace *as, dma_addr_t addr, 54- uint8_t val, MemTxAttrs attrs) 55+static inline MemTxResult stb_dma(AddressSpace *as, dma_addr_t addr, 56+ uint8_t val, MemTxAttrs attrs) 57 { 58- dma_memory_write(as, addr, &val, 1, attrs); 59+ return dma_memory_write(as, addr, &val, 1, attrs); 60 } 61 62 DEFINE_LDST_DMA(uw, w, 16, le); 63-- 641.8.3.1 65 66