[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 08/13] linux-user/mmap: Avoid asserts for out of range mremap call
From: |
Laurent Vivier |
Subject: |
[PULL 08/13] linux-user/mmap: Avoid asserts for out of range mremap calls |
Date: |
Mon, 15 Feb 2021 13:45:14 +0100 |
From: Richard Purdie <richard.purdie@linuxfoundation.org>
If mremap() is called without the MREMAP_MAYMOVE flag with a start address
just before the end of memory (reserved_va) where new_size would exceed
it (and GUEST_ADDR_MAX), the assert(end - 1 <= GUEST_ADDR_MAX) in
page_set_flags() would trigger.
Add an extra guard to the guest_range_valid() checks to prevent this and
avoid asserting binaries when reserved_va is set.
This meant a bug I was seeing locally now gives the same behaviour
regardless of whether reserved_va is set or not.
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <70c46e7b999bafbb01d54bfafd44b420d0b782e9.camel@linuxfoundation.org>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
linux-user/mmap.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/linux-user/mmap.c b/linux-user/mmap.c
index 810653c50357..1c9faef47699 100644
--- a/linux-user/mmap.c
+++ b/linux-user/mmap.c
@@ -724,7 +724,9 @@ abi_long target_mremap(abi_ulong old_addr, abi_ulong
old_size,
if (!guest_range_valid(old_addr, old_size) ||
((flags & MREMAP_FIXED) &&
- !guest_range_valid(new_addr, new_size))) {
+ !guest_range_valid(new_addr, new_size)) ||
+ ((flags & MREMAP_MAYMOVE) == 0 &&
+ !guest_range_valid(old_addr, new_size))) {
errno = ENOMEM;
return -1;
}
--
2.29.2
- [PULL 00/13] Linux user for 6.0 patches, Laurent Vivier, 2021/02/15
- [PULL 05/13] linux-user: fix O_NONBLOCK usage for hppa target, Laurent Vivier, 2021/02/15
- [PULL 06/13] linux-user: fix O_NONBLOCK in signalfd4() and eventfd2() syscalls, Laurent Vivier, 2021/02/15
- [PULL 09/13] linux-user/syscall: Fix do_ioctl_ifconf() for 64 bit targets., Laurent Vivier, 2021/02/15
- [PULL 07/13] linux-user: Fix loading of BSS segments, Laurent Vivier, 2021/02/15
- [PULL 04/13] linux-user: Add missing TARGET___O_TMPFILE for hppa and alpha, Laurent Vivier, 2021/02/15
- [PULL 12/13] docs/user: Remove outdated 'Quick Start' section, Laurent Vivier, 2021/02/15
- [PULL 13/13] linux-user/mips: Support the n32 ABI for the R5900, Laurent Vivier, 2021/02/15
- [PULL 10/13] linux-user: add TARGET_SO_{DOMAIN,PROTOCOL}, Laurent Vivier, 2021/02/15
- [PULL 08/13] linux-user/mmap: Avoid asserts for out of range mremap calls,
Laurent Vivier <=
- [PULL 02/13] linux-user/mips64: Support o32 ABI syscalls, Laurent Vivier, 2021/02/15
- [PULL 01/13] linux-user/mips64: Restore setup_frame() for o32 ABI, Laurent Vivier, 2021/02/15
- [PULL 11/13] linux-user: target: signal: Support TARGET_SS_AUTODISARM, Laurent Vivier, 2021/02/15
- [PULL 03/13] linux-user/signal: Decode waitid si_code, Laurent Vivier, 2021/02/15
- Re: [PULL 00/13] Linux user for 6.0 patches, Philippe Mathieu-Daudé, 2021/02/15