diff mbox series

[v2,1/6] linux-user: Unset MAP_FIXED_NOREPLACE for host

Message ID 20230802071754.14876-2-akihiko.odaki@daynix.com
State New
Headers show
Series linux-user: brk/mmap fixes | expand

Commit Message

Akihiko Odaki Aug. 2, 2023, 7:17 a.m. UTC
Passing MAP_FIXED_NOREPLACE to host will fail if the virtual
address space is reserved with mmap. Replace it with MAP_FIXED in such
a case.

Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
---
 linux-user/mmap.c | 4 ++++
 1 file changed, 4 insertions(+)
diff mbox series

Patch

diff --git a/linux-user/mmap.c b/linux-user/mmap.c
index a5dfb56545..14cd1b9feb 100644
--- a/linux-user/mmap.c
+++ b/linux-user/mmap.c
@@ -610,6 +610,10 @@  abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot,
             goto fail;
         }
 
+        if (reserved_va) {
+            flags = (flags & ~MAP_FIXED_NOREPLACE) | MAP_FIXED;
+        }
+
         /*
          * worst case: we cannot map the file because the offset is not
          * aligned, so we read it