ANDROID: 16K: Ensure stack expansion size is __PAGE_SIZE multiple

When expanding the stack, the range of the existing stack VMA is
modified to encompass the new faulting address.

The expansion must be done is multiples of __PAGE_SIZE size to
preserve the page size emulation invariants:

    1) The VMA is 16kB aligned
    2) The VMA is 16kB multiple-sized.

For x86_64, align down the faulting address by __PAGE_SIZE to
maintain these invariants.

Bug: 383389337
Bug: 328138888
Bug: 345252092
Bug: 315325080
Bug: 302403436
Change-Id: I5e44e7204562959c3d860dcc52e364c4be8d0461
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
This commit is contained in:
Kalesh Singh
2024-06-10 11:26:15 -07:00
committed by Carlos Llamas
parent a8df614576
commit cd48f9a1f7

View File

@@ -1168,7 +1168,7 @@ int expand_downwards(struct vm_area_struct *vma, unsigned long address)
if (!(vma->vm_flags & VM_GROWSDOWN))
return -EFAULT;
address &= PAGE_MASK;
address &= __PAGE_MASK;
if (address < mmap_min_addr || address < FIRST_USER_ADDRESS)
return -EPERM;