Make invalid mprotects warn instead of panicking

This commit is contained in:
wheremyfoodat 2025-08-03 18:23:45 +03:00
commit c0794dd3d5

View file

@ -114,8 +114,10 @@ void Kernel::controlMemory() {
// Official kernel has an internal state bit to indicate that the region's permissions may be changed // Official kernel has an internal state bit to indicate that the region's permissions may be changed
// But this should account for all cases // But this should account for all cases
if (!mem.testMemoryState(addr0, pages, MemoryState::Private) && !mem.testMemoryState(addr0, pages, MemoryState::Alias) && if (!mem.testMemoryState(addr0, pages, MemoryState::Private) && !mem.testMemoryState(addr0, pages, MemoryState::Alias) &&
!mem.testMemoryState(addr0, pages, MemoryState::Aliased) && !mem.testMemoryState(addr0, pages, MemoryState::AliasCode)) !mem.testMemoryState(addr0, pages, MemoryState::Aliased) && !mem.testMemoryState(addr0, pages, MemoryState::AliasCode)) {
Helpers::panic("Tried to mprotect invalid region!"); Helpers::warn("Tried to mprotect invalid region!");
return;
}
mem.changePermissions(addr0, pages, r, w, false); mem.changePermissions(addr0, pages, r, w, false);
regs[1] = addr0; regs[1] = addr0;