mirror of
https://git.openwrt.org/openwrt/openwrt.git
synced 2026-03-12 01:58:19 +01:00
Some checks are pending
Build Kernel / Build all affected Kernels (push) Waiting to run
On MT7620-class platforms (CONFIG_NET_RALINK_MT7620) we observe sporadic
wrong-jump-targets, kernel oopses, hanging, corrupted backtraces or even
"half-written" instructions when the compiler emits a direct 'jal imm26'
call.
This is triggered in:
- the small random helpers inside get_random_u32_below(), and
- the blkcg_maybe_throttle_current() call in resume_user_mode_work().
This patch forces those two call sites to use an indirect call via
a volatile function pointer (load into register + jalr) when building
for MT7620, avoiding embedding a 26-bit immediate jump target.
Additionally, on MT7620 builds the exec path in fs/exec.c is modified:
- skip arch_align_stack() + PAGE_ALIGN() in setup_arg_pages()
because the micro-randomization (< PAGE_SIZE) implemented by many
ports (including MT7620) is negated immediately by PAGE_ALIGN().
Skipping the redundant PAGE_ALIGN() reduces exposure to the
problematic code pattern.
These changes are targeted workarounds for MT7620; behavioral logic is unchanged.
Signed-off-by: Mieczyslaw Nalewaj <namiltd@yahoo.com>
Link: https://github.com/openwrt/openwrt/pull/20553
Signed-off-by: Robert Marko <robimarko@gmail.com>
30 lines
1.1 KiB
Diff
30 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
|
|
@@ -750,8 +750,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))
|