mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 15:48:12 +00:00
Kernel: Do 2 validations in annotate_mapping syscall outside a spinlock
This commit is contained in:
parent
bedd90b1f0
commit
08de5abc6d
1 changed files with 5 additions and 6 deletions
|
@ -575,11 +575,13 @@ ErrorOr<FlatPtr> Process::sys$allocate_tls(Userspace<char const*> initial_data,
|
|||
ErrorOr<FlatPtr> Process::sys$annotate_mapping(Userspace<void*> address, int flags)
|
||||
{
|
||||
VERIFY_NO_PROCESS_BIG_LOCK(this);
|
||||
if (flags == to_underlying(VirtualMemoryRangeFlags::None))
|
||||
return EINVAL;
|
||||
|
||||
if (!Memory::is_user_address(address.vaddr()))
|
||||
return EFAULT;
|
||||
|
||||
return address_space().with([&](auto& space) -> ErrorOr<FlatPtr> {
|
||||
if (flags == to_underlying(VirtualMemoryRangeFlags::None))
|
||||
return EINVAL;
|
||||
|
||||
if (space->enforces_syscall_regions() && (flags & to_underlying(VirtualMemoryRangeFlags::SyscallCode)))
|
||||
return EPERM;
|
||||
|
||||
|
@ -588,9 +590,6 @@ ErrorOr<FlatPtr> Process::sys$annotate_mapping(Userspace<void*> address, int fla
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (!Memory::is_user_address(address.vaddr()))
|
||||
return EFAULT;
|
||||
|
||||
auto* region = space->find_region_containing(Memory::VirtualRange { address.vaddr(), 1 });
|
||||
if (!region)
|
||||
return EINVAL;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue