Skip to contentSkip to conversation

linux-user/mmap.c: fix integer underflow during mremap shrink

PATCH New Jonathan Marler 1 participant 1 message May 2, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 linux-user/mmap.c: fix integer underflow during mremap shrink

---
 linux-user/mmap.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
linux-user/mmap.c +2 -1
index e378033797..da0fe4cc86 100644
@@ -708,7 +708,8 @@ abi_long target_mremap(abi_ulong old_addr, abi_ulong old_size,
         if (prot == 0) {
             host_addr = mremap(g2h(old_addr), old_size, new_size, flags);
             if (host_addr != MAP_FAILED && reserved_va && old_size > new_size) {
-                mmap_reserve(old_addr + old_size, new_size - old_size);
+                if (new_size > old_size)
+                    mmap_reserve(old_addr + old_size, new_size - old_size);
             }
         } else {
             errno = ENOMEM;
Signature · 1 line
2.23.1