ANDROID: 16K: brk: __PAGE_ALIGN brk

In page-compat mode, brk() syscalls must be at __PAGE_ALIGN-ed
addresses and of __PAGE_SIZE-multiple length.

Bug: 383389337
Bug: 315325080
Bug: 302403436
Change-Id: Ifdb1579580fb9ad90778c58102514e7aaed1c846
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
This commit is contained in:
Kalesh Singh
2023-11-20 14:11:08 -08:00
committed by Carlos Llamas
parent 7852452429
commit 4daa4c1fec

View File

@@ -157,8 +157,8 @@ SYSCALL_DEFINE1(brk, unsigned long, brk)
mm->end_data, mm->start_data))
goto out;
newbrk = PAGE_ALIGN(brk);
oldbrk = PAGE_ALIGN(mm->brk);
newbrk = __PAGE_ALIGN(brk);
oldbrk = __PAGE_ALIGN(mm->brk);
if (oldbrk == newbrk) {
mm->brk = brk;
goto success;
@@ -192,8 +192,8 @@ SYSCALL_DEFINE1(brk, unsigned long, brk)
* expansion area
*/
vma_iter_init(&vmi, mm, oldbrk);
next = vma_find(&vmi, newbrk + PAGE_SIZE + stack_guard_gap);
if (next && newbrk + PAGE_SIZE > vm_start_gap(next))
next = vma_find(&vmi, newbrk + __PAGE_SIZE + stack_guard_gap);
if (next && newbrk + __PAGE_SIZE > vm_start_gap(next))
goto out;
brkvma = vma_prev_limit(&vmi, mm->start_brk);