From a9e38ff89ac8400c5e5232ff579e9e5604e6442c Mon Sep 17 00:00:00 2001 From: Kalesh Singh Date: Thu, 8 Feb 2024 23:31:09 -0800 Subject: [PATCH] ANDROID: 16K: __PAGE_ALIGN stack_[top|base] In page-compat mode, align the stack top / base by the emulated page-size. Bug: 383389337 Bug: 315325080 Bug: 302403436 Change-Id: I46e08a3b99842e7810866f48a2f53365c0bbd2bc Signed-off-by: Kalesh Singh --- fs/exec.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/fs/exec.c b/fs/exec.c index 131f5ac70eb9..ee89e0f3a636 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include @@ -283,7 +284,7 @@ static int __bprm_mm_init(struct linux_binprm *bprm) */ BUILD_BUG_ON(VM_STACK_FLAGS & VM_STACK_INCOMPLETE_SETUP); vma->vm_end = STACK_TOP_MAX; - vma->vm_start = vma->vm_end - PAGE_SIZE; + vma->vm_start = vma->vm_end - __PAGE_SIZE; vm_flags_init(vma, VM_SOFTDIRTY | VM_STACK_FLAGS | VM_STACK_INCOMPLETE_SETUP); vma->vm_page_prot = vm_get_page_prot(vma->vm_flags); @@ -745,14 +746,14 @@ int setup_arg_pages(struct linux_binprm *bprm, if (vma->vm_end - vma->vm_start > stack_base) return -ENOMEM; - stack_base = PAGE_ALIGN(stack_top - stack_base); + stack_base = __PAGE_ALIGN(stack_top - stack_base); stack_shift = vma->vm_start - stack_base; mm->arg_start = bprm->p - stack_shift; bprm->p = vma->vm_end - stack_shift; #else stack_top = arch_align_stack(stack_top); - stack_top = PAGE_ALIGN(stack_top); + stack_top = __PAGE_ALIGN(stack_top); if (unlikely(stack_top < mmap_min_addr) || unlikely(vma->vm_end - vma->vm_start >= stack_top - mmap_min_addr)) @@ -822,7 +823,7 @@ int setup_arg_pages(struct linux_binprm *bprm, * Align this down to a page boundary as expand_stack * will align it up. */ - rlim_stack = bprm->rlim_stack.rlim_cur & PAGE_MASK; + rlim_stack = bprm->rlim_stack.rlim_cur & __PAGE_MASK; stack_expand = min(rlim_stack, stack_size + stack_expand);