From 2d91761cf6fb79cdc587c90270455396a8170d37 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Tue, 13 Apr 2021 19:27:49 +0200 Subject: Kernel: Make sure the offset stays the same when using mremap() When using mmap() on a file with a non-zero offset subsequent calls to mremap() would incorrectly reset the offset to zero. --- Kernel/Syscalls/mmap.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Kernel') diff --git a/Kernel/Syscalls/mmap.cpp b/Kernel/Syscalls/mmap.cpp index db401a59c5..3e8ede3c8a 100644 --- a/Kernel/Syscalls/mmap.cpp +++ b/Kernel/Syscalls/mmap.cpp @@ -566,6 +566,7 @@ KResultOr Process::sys$mremap(Userspacerange(); auto old_name = old_region->name(); auto old_prot = region_access_flags_to_prot(old_region->access()); + auto old_offset = old_region->offset_in_vmobject(); NonnullRefPtr inode = static_cast(old_region->vmobject()).inode(); // Unmap without deallocating the VM range since we're going to reuse it. @@ -575,7 +576,7 @@ KResultOr Process::sys$mremap(Userspace