From: Matthew Lugg Date: Mon, 17 Nov 2025 17:09:51 +0000 (+0000) Subject: linux-user: fix mremap unmapping adjacent region X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aaed9ca1797d70a507371aea688c5cd60b074e2d;p=thirdparty%2Fqemu.git linux-user: fix mremap unmapping adjacent region This typo meant that calls to `mremap` which shrink a mapping by some N bytes would, when the virtual address space was pre-reserved (e.g. 32-bit guest on 64-bit host), unmap the N bytes following the *original* mapping. Signed-off-by: Matthew Lugg Reviewed-by: Richard Henderson Signed-off-by: Richard Henderson Message-ID: <20251117170954.31451-2-mlugg@mlugg.co.uk> --- diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 423c77856a..ef3833a2bb 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -1171,7 +1171,8 @@ abi_long target_mremap(abi_ulong old_addr, abi_ulong old_size, errno = ENOMEM; host_addr = MAP_FAILED; } else if (reserved_va && old_size > new_size) { - mmap_reserve_or_unmap(old_addr + old_size, + /* Re-reserve pages we just shrunk out of the mapping */ + mmap_reserve_or_unmap(old_addr + new_size, old_size - new_size); } }