kernel: fix bug with BSS clearing code
Code that compared cache offset to area length used unsigned
subtraction, which would underflow when a fault occurred on a
page in the uninitialized area that was not the last page.
Added additional check for this condition.
The newest version of the compiler exposed this issue.
@@ -292,7 +292,8 @@ static int soft_fault(struct vm_address_space *space, const struct vm_area *area
unlock_vm_cache();
restore_interrupts(old_flags);
- if (area->cache_length - area_offset < PAGE_SIZE)
+ if (area->cache_length < area_offset
+ || area->cache_length - area_offset < PAGE_SIZE)
size_to_read = area->cache_length - area_offset;
else
size_to_read = PAGE_SIZE;
