diff --git a/libos/src/sys/libos_mmap.c b/libos/src/sys/libos_mmap.c index 08aa05696c..cb175e0b50 100644 --- a/libos/src/sys/libos_mmap.c +++ b/libos/src/sys/libos_mmap.c @@ -67,6 +67,7 @@ void* libos_syscall_mmap(void* addr, size_t length, int prot, int flags, int fd, unsigned long offset) { struct libos_handle* hdl = NULL; long ret = 0; + bool unlock = false; ret = check_prot(prot); if (ret < 0) @@ -165,6 +166,10 @@ void* libos_syscall_mmap(void* addr, size_t length, int prot, int flags, int fd, memory_range_start = g_pal_public_state->memory_address_start; memory_range_end = g_pal_public_state->memory_address_end; } + + rwlock_read_lock(&checkpoint_lock); + unlock = true; + if (flags & (MAP_FIXED | MAP_FIXED_NOREPLACE)) { /* We know that `addr + length` does not overflow (`access_ok` above). */ if (addr < memory_range_start || (uintptr_t)memory_range_end < (uintptr_t)addr + length) { @@ -270,6 +275,9 @@ void* libos_syscall_mmap(void* addr, size_t length, int prot, int flags, int fd, } out_handle: + if (unlock) + rwlock_read_unlock(&checkpoint_lock); + if (hdl) { put_handle(hdl); }