Kernel: Fix off-by-one in Memory::is_user_range() check
This function was checking 1 byte after the provided range, which caused it to reject valid userspace ranges that happened to end exactly at the top of the user address space. This fixes a long-standing issue with mysterious Optional errors in Coredump::write_regions(). (It happened when trying to add a memory region at the very top of the address space to a coredump.)
This commit is contained in:
parent
2116fb5be9
commit
890c647e0f
Notes:
sideshowbarker
2024-07-18 04:18:36 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/890c647e0f2
1 changed files with 5 additions and 1 deletions
|
@ -302,7 +302,11 @@ inline bool is_user_range(VirtualAddress vaddr, size_t size)
|
|||
{
|
||||
if (vaddr.offset(size) < vaddr)
|
||||
return false;
|
||||
return is_user_address(vaddr) && is_user_address(vaddr.offset(size));
|
||||
if (!is_user_address(vaddr))
|
||||
return false;
|
||||
if (size <= 1)
|
||||
return true;
|
||||
return is_user_address(vaddr.offset(size - 1));
|
||||
}
|
||||
|
||||
inline bool is_user_range(VirtualRange const& range)
|
||||
|
|
Loading…
Add table
Reference in a new issue