mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-21 18:00:16 +00:00
Kernel: Move incorrect early return in sys$mprotect
Since we're iterating over multiple regions that interesect with the requested range, just one of them having the requested access flags is not enough to finish the syscall early.
This commit is contained in:
parent
a9e436c4a3
commit
f27bbec7b2
Notes:
sideshowbarker
2024-07-17 23:13:34 +09:00
Author: https://github.com/IdanHo
Commit: f27bbec7b2
Pull-request: https://github.com/SerenityOS/serenity/pull/10674
Reviewed-by: https://github.com/bgianfo
Reviewed-by: https://github.com/linusg ✅
1 changed files with 3 additions and 2 deletions
|
@ -331,8 +331,6 @@ ErrorOr<FlatPtr> Process::sys$mprotect(Userspace<void*> addr, size_t size, int p
|
|||
return EPERM;
|
||||
if (!validate_mmap_prot(prot, region->is_stack(), region->vmobject().is_anonymous(), region))
|
||||
return EINVAL;
|
||||
if (region->access() == Memory::prot_to_region_access_flags(prot))
|
||||
return 0;
|
||||
if (region->vmobject().is_inode()
|
||||
&& !validate_inode_mmap_prot(*this, prot, static_cast<Memory::InodeVMObject const&>(region->vmobject()).inode(), region->is_shared())) {
|
||||
return EACCES;
|
||||
|
@ -345,6 +343,9 @@ ErrorOr<FlatPtr> Process::sys$mprotect(Userspace<void*> addr, size_t size, int p
|
|||
|
||||
// then do all the other stuff
|
||||
for (auto* old_region : regions) {
|
||||
if (old_region->access() == Memory::prot_to_region_access_flags(prot))
|
||||
continue;
|
||||
|
||||
const auto intersection_to_mprotect = range_to_mprotect.intersect(old_region->range());
|
||||
// full sub region
|
||||
if (intersection_to_mprotect == old_region->range()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue