From: Mieczyslaw Nalewaj <namiltd@yahoo.com>
Date: Sun, 26 Oct 2025 10:36:02 +0100
Subject: [PATCH] mt7620: conditional stack align

This patch avoids applying arch_align_stack() and PAGE_ALIGN() in the exec
path on CONFIG_NET_RALINK_MT7620 builds. Many ports (including mt7620)
implement only micro-randomization inside arch_align_stack() (random offset
< PAGE_SIZE and then align-down to small alignment). Callers that immediately
apply PAGE_ALIGN() will round that micro-offset back to the original page
boundary, so invoking arch_align_stack() then PAGE_ALIGN() is pointless and
can be avoided on the affected platform.

Signed-off-by: Mieczyslaw Nalewaj <namiltd@yahoo.com>
---
 a/fs/exec.c | 2 ++
 1 file changed, 2 insertions(+)

--- a/fs/exec.c
+++ b/fs/exec.c
@@ -632,8 +632,10 @@ int setup_arg_pages(struct linux_binprm
 	mm->arg_start = bprm->p - stack_shift;
 	bprm->p = vma->vm_end - stack_shift;
 #else
+#ifndef CONFIG_NET_RALINK_MT7620
 	stack_top = arch_align_stack(stack_top);
 	stack_top = PAGE_ALIGN(stack_top);
+#endif
 
 	if (unlikely(stack_top < mmap_min_addr) ||
 	    unlikely(vma->vm_end - vma->vm_start >= stack_top - mmap_min_addr))
