openwrt/target/linux/ramips/patches-6.18/332-mt7620-conditional-stack-align.patch
Mieczyslaw Nalewaj eac2a6c404 ramips: 6.18: refresh patches
Refreshed patches for ramips/patches-6.18 by running
make target/linux/refresh

Signed-off-by: Mieczyslaw Nalewaj <namiltd@yahoo.com>
Link: https://github.com/openwrt/openwrt/pull/21418
Signed-off-by: Robert Marko <robimarko@gmail.com>
2026-04-06 11:26:27 +02:00

31 lines
1.1 KiB
Diff

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))