mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
Kernel: sys$mmap() without MAP_FIXED should consider address a hint
If we can't use that specific address, it's still okay to put it anywhere else in VM.
This commit is contained in:
parent
e2f9e557d3
commit
5ab27e4bdc
Notes:
sideshowbarker
2024-07-18 22:49:04 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/5ab27e4bdcd
1 changed files with 6 additions and 3 deletions
|
@ -134,14 +134,17 @@ void* Process::sys$mmap(Userspace<const Syscall::SC_mmap_params*> user_params)
|
|||
|
||||
Region* region = nullptr;
|
||||
auto range = allocate_range(VirtualAddress(addr), size, alignment);
|
||||
if (!range.is_valid())
|
||||
if (!range.is_valid()) {
|
||||
if (addr && !map_fixed) {
|
||||
// If there's an address but MAP_FIXED wasn't specified, the address is just a hint.
|
||||
range = allocate_range({}, size, alignment);
|
||||
}
|
||||
return (void*)-ENOMEM;
|
||||
}
|
||||
|
||||
if (map_anonymous) {
|
||||
auto strategy = map_noreserve ? AllocationStrategy::None : AllocationStrategy::Reserve;
|
||||
auto region_or_error = allocate_region(range, !name.is_null() ? name : "mmap", prot, strategy);
|
||||
if (region_or_error.is_error() && (!map_fixed && addr != 0))
|
||||
region_or_error = allocate_region(allocate_range({}, size), !name.is_null() ? name : "mmap", prot, strategy);
|
||||
if (region_or_error.is_error())
|
||||
return (void*)region_or_error.error().error();
|
||||
region = region_or_error.value();
|
||||
|
|
Loading…
Reference in a new issue