Skip to contentSkip to conversation

linux-user/mmap.c: fix integer underflow in target_mremap

PATCH In review Jonathan Marler 2 participants 3 messages May 2, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 linux-user/mmap.c: fix integer underflow in target_mremap

---
 linux-user/mmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
linux-user/mmap.c +1 -1
index e378033797..caab62909e 100644
@@ -708,7 +708,7 @@ 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);
+                mmap_reserve(old_addr + old_size, old_size - new_size);
             }
         } else {
             errno = ENOMEM;
Signature · 1 line
2.23.1
#1 lore raw

Hi,

does this patch replace your previous one?

Please add more details in the description, as you did in the launchpad bug.

You can also add:
Fixes: https://bugs.launchpad.net/bugs/1876373

You must also send the patch to [email protected]

Thanks,
Laurent

Le 02/05/2020 à 09:49, Jonathan Marler a écrit :

Quoted 19 lines
---
 linux-user/mmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
linux-user/mmap.c +1 -1
index e378033797..caab62909e 100644
@@ -708,7 +708,7 @@ 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);
+                mmap_reserve(old_addr + old_size, old_size - new_size);
             }
         } else {
             errno = ENOMEM;
#2 lore raw

Yes the first patch was incorrect. The second patch should be the correct one.

Thanks for the guidance. I have created a new patch with a "Fixes: ..." and a description of the fix, and have sent that patch to [email protected]

Quoted 40 lines · Laurent Vivier

Hi,

does this patch replace your previous one?

Please add more details in the description, as you did in the launchpad bug.

You can also add:
Fixes: https://bugs.launchpad.net/bugs/1876373

You must also send the patch to [email protected]

Thanks,
Laurent

linux-user/mmap.c abi_long target_mremap(abi_ulong old_addr, abi_ulong

Quoted 10 lines · Jonathan Marler
---
 linux-user/mmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
linux-user/mmap.c +0 -0
index e378033797..caab62909e 100644
@@ -708,7 +708,7 @@ abi_long target_mremap(abi_ulong old_addr, abi_ulong

old_size,

linux-user/mmap.c abi_long target_mremap(abi_ulong old_addr, abi_ulong · line 709

Quoted 2 lines
linux-user/mmap.c +0 -0
         if (prot == 0) {
             host_addr = mremap(g2h(old_addr), old_size, new_size,

flags);

linux-user/mmap.c abi_long target_mremap(abi_ulong old_addr, abi_ulong · line 710

Quoted 1 line
linux-user/mmap.c +0 -0
             if (host_addr != MAP_FAILED && reserved_va && old_size >

new_size) {

Quoted 6 lines
linux-user/mmap.c +1 -1
-                mmap_reserve(old_addr + old_size, new_size - old_size);
+                mmap_reserve(old_addr + old_size, old_size - new_size);
             }
         } else {
             errno = ENOMEM;