[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 080/115] exec: set map length to zero when returning NULL
From: |
Paolo Bonzini |
Subject: |
[PULL 080/115] exec: set map length to zero when returning NULL |
Date: |
Thu, 11 Jun 2020 15:44:14 -0400 |
From: Prasad J Pandit <pjp@fedoraproject.org>
When mapping physical memory into host's virtual address space,
'address_space_map' may return NULL if BounceBuffer is in_use.
Set and return '*plen = 0' to avoid later NULL pointer dereference.
Reported-by: Alexander Bulekov <alxndr@bu.edu>
Fixes: https://bugs.launchpad.net/qemu/+bug/1878259
Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Suggested-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
Message-Id: <20200526111743.428367-1-ppandit@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
exec.c | 1 +
include/exec/memory.h | 3 ++-
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/exec.c b/exec.c
index 9cbde85d8c..778263f1c6 100644
--- a/exec.c
+++ b/exec.c
@@ -3540,6 +3540,7 @@ void *address_space_map(AddressSpace *as,
if (!memory_access_is_direct(mr, is_write)) {
if (atomic_xchg(&bounce.in_use, true)) {
+ *plen = 0;
return NULL;
}
/* Avoid unbounded allocations */
diff --git a/include/exec/memory.h b/include/exec/memory.h
index bd7fdd6081..af8ca7824e 100644
--- a/include/exec/memory.h
+++ b/include/exec/memory.h
@@ -2314,7 +2314,8 @@ bool address_space_access_valid(AddressSpace *as, hwaddr
addr, hwaddr len,
/* address_space_map: map a physical memory region into a host virtual address
*
* May map a subset of the requested range, given by and returned in @plen.
- * May return %NULL if resources needed to perform the mapping are exhausted.
+ * May return %NULL and set *@plen to zero(0), if resources needed to perform
+ * the mapping are exhausted.
* Use only for reads OR writes - not for read-modify-write operations.
* Use cpu_register_map_client() to know when retrying the map operation is
* likely to succeed.
--
2.26.2
- [PULL 082/115] target/i386: correct fix for pcmpxstrx substring search, (continued)
- [PULL 082/115] target/i386: correct fix for pcmpxstrx substring search, Paolo Bonzini, 2020/06/11
- [PULL 081/115] target/i386: fix IEEE x87 floating-point exception raising, Paolo Bonzini, 2020/06/11
- [PULL 089/115] i386: hvf: Drop unused variable, Paolo Bonzini, 2020/06/11
- [PULL 092/115] i386: hvf: Drop fetch_rip from HVFX86EmulatorState, Paolo Bonzini, 2020/06/11
- [PULL 088/115] i386: hvf: Drop useless declarations in sysemu, Paolo Bonzini, 2020/06/11
- [PULL 090/115] i386: hvf: Use ins_len to advance IP, Paolo Bonzini, 2020/06/11
- [PULL 085/115] sysemu/hvf: Only declare hvf_allowed when HVF is available, Paolo Bonzini, 2020/06/11
- [PULL 083/115] sysemu/accel: Restrict machine methods to system-mode, Paolo Bonzini, 2020/06/11
- [PULL 069/115] KVM: Kick resamplefd for split kernel irqchip, Paolo Bonzini, 2020/06/11
- [PULL 095/115] i386: hvf: Drop regs in HVFX86EmulatorState, Paolo Bonzini, 2020/06/11
- [PULL 080/115] exec: set map length to zero when returning NULL,
Paolo Bonzini <=
- [PULL 091/115] i386: hvf: Use IP from CPUX86State, Paolo Bonzini, 2020/06/11
- [PULL 094/115] i386: hvf: Drop copy of RFLAGS defines, Paolo Bonzini, 2020/06/11
- [PULL 097/115] i386: hvf: Move mmio_buf into CPUX86State, Paolo Bonzini, 2020/06/11
- [PULL 096/115] i386: hvf: Move lazy_flags into CPUX86State, Paolo Bonzini, 2020/06/11
- [PULL 098/115] i386: hvf: Drop HVFX86EmulatorState, Paolo Bonzini, 2020/06/11
- [PULL 093/115] i386: hvf: Drop rflags from HVFX86EmulatorState, Paolo Bonzini, 2020/06/11
- [PULL 087/115] i386: hvf: Move HVFState definition into hvf, Paolo Bonzini, 2020/06/11
- [PULL 101/115] target/i386: sev: Move local structure definitions into .c file, Paolo Bonzini, 2020/06/11
- [PULL 100/115] target/i386: sev: Remove unused QSevGuestInfoClass, Paolo Bonzini, 2020/06/11
- [PULL 102/115] target/i386: sev: Rename QSevGuestInfo, Paolo Bonzini, 2020/06/11