Kernel: Pointer range validation should fail on wraparound

Let's reject address ranges that wrap around the 2^32 mark.
This commit is contained in:
Andreas Kling 2019-12-31 18:23:17 +01:00
parent 903b159856
commit 36f1de3c89
Notes: sideshowbarker 2024-07-19 10:30:40 +09:00

View File

@ -1971,6 +1971,8 @@ bool Process::validate_read(const void* address, ssize_t size) const
ASSERT(size >= 0);
VirtualAddress first_address((u32)address);
VirtualAddress last_address = first_address.offset(size - 1);
if (last_address < first_address)
return false;
if (is_ring0()) {
auto kmc_result = check_kernel_memory_access(first_address, false);
if (kmc_result == KernelMemoryCheckResult::AccessGranted)
@ -1995,6 +1997,8 @@ bool Process::validate_write(void* address, ssize_t size) const
ASSERT(size >= 0);
VirtualAddress first_address((u32)address);
VirtualAddress last_address = first_address.offset(size - 1);
if (last_address < first_address)
return false;
if (is_ring0()) {
if (is_kmalloc_address(address))
return true;