mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-25 02:40:49 +00:00
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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user