From: sashiko-bot@kernel.org
To: "Ian Rogers" <irogers@google.com>, linux-trace-kernel@vger.kernel.org
Cc: jpoimboe@kernel.org, rostedt@goodmis.org, peterz@infradead.org,
mingo@redhat.com, tglx@kernel.org, bp@alien8.de,
dave.hansen@linux.intel.com, x86@kernel.org,
catalin.marinas@arm.com, will@kernel.org, mark.rutland@arm.com,
pjw@kernel.org, palmer@dabbelt.com, aou@eecs.berkeley.edu,
alex@ghiti.fr, acme@kernel.org, namhyung@kernel.org,
linux-perf-users@vger.kernel.org, mhiramat@kernel.org,
ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org,
bpf@vger.kernel.org, nathan@kernel.org, nsc@kernel.org,
linux-kbuild@vger.kernel.org, ojeda@kernel.org, ardb@kernel.org,
linux-efi@vger.kernel.org, "Marc Zyngier" <maz@kernel.org>,
"Oliver Upton" <oupton@kernel.org>,
kvmarm@lists.linux.dev, shuah@kernel.org, indu.bhagat@oracle.com,
jremus@linux.ibm.com, wnliu@google.com, dylanbhatch@google.com,
gary@garyguo.net
Subject: Re: [RFC PATCH v1 06/11] arm64: unwind_user: Support Minimal DWARF CFI and FP user unwinding
Date: Mon, 23 Nov 2026 00:16:10 +0000 [thread overview]
Message-ID: <sashiko-outbox-228465@kernel.org> (raw)
In-Reply-To: <20261122235757.3456048-7-irogers@google.com>
Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Medium] arm64: unwind_user: shifted rt_sigframe base in
unwind_user_sigreturn()
- [Medium] arm64: unwind_user: wrong state->sp on FP-to-CFI frame
transition
- [Medium] arm64: unwind_user: Thumb bit 0 not stripped in
unwind_user_strip_pac()
--
commit 6b2ce687ccf3b40dba131fb7a09e5054f9d0557a
Author: Ian Rogers <irogers@google.com>
arm64: unwind_user: Support Minimal DWARF CFI and FP user unwinding
This commit adds arm64 support for user-space DWARF CFI and frame pointer
unwinding, including register mappings, pointer authentication stripping,
and vDSO signal trampoline recovery.
> diff --git a/arch/arm64/include/asm/unwind_user.h b/arch/arm64/include/asm/unwind_user.h
> new file mode 100644
> index 0000000000000..38d0641ae5549
> --- /dev/null
> +++ b/arch/arm64/include/asm/unwind_user.h
> @@ -0,0 +1,126 @@
[ ... ]
> +static inline unsigned long unwind_user_strip_pac(unsigned long ip,
> + bool ra_signed)
> +{
> + if (IS_ENABLED(CONFIG_COMPAT) &&
> + compat_user_mode(task_pt_regs(current)))
> + return ip;
> + return ptrauth_strip_user_insn_pac(ip);
> +}
> +#define unwind_user_strip_pac unwind_user_strip_pac
[Severity: Medium]
Should unwind_user_strip_pac() clear bit 0 (ip & ~1UL) for 32-bit compat
tasks?
In AArch32 Thumb mode, BL/BLX and compat_setup_return() set bit 0 of LR to
indicate Thumb state. Leaving bit 0 set records odd addresses in the
callchain and causes lookup_ip = state->ip - 1 in unwind_user_next_cfi() to
evaluate to return_pc rather than return_pc - 1, applying post-call CFA rule
changes prematurely or missing the FDE when a call is at the end of a
function.
[ ... ]
> +#ifdef CONFIG_HAVE_UNWIND_USER_FP
> +
> +/*
> + * AArch64 PCS stores {fp, lr} at [fp, fp + 16), while 32-bit AArch32 compat
> + * APCS stores struct compat_frame_tail {fp, sp, lr} at [compat_fp - 12, compat_fp).
> + */
> +#define ARCH_INIT_USER_FP_FRAME(ws) \
> + .cfa_off = (ws) == 8 ? 2 * (ws) : 0, \
> + .ra_off = -1 * (ws), \
> + .fp_off = (ws) == 8 ? -2 * (ws) : -3 * (ws), \
> + .use_fp = true,
> +
> +#endif /* CONFIG_HAVE_UNWIND_USER_FP */
[Severity: Medium]
Does ARCH_INIT_USER_FP_FRAME() leave state->sp inaccurate when an inner
frame unwound via FP transitions to an outer frame unwound via SP-based
DWARF CFI?
On AArch64, a function with frame size N > 16 places its frame record at the
lowest address of its frame (callee_fp = caller_sp - N). Setting cfa_off =
16 with use_fp = true updates state->sp to callee_fp + 16 = caller_sp -
(N - 16) rather than caller_sp (and on AArch32, cfa_off = 0 sets state->sp
to compat_fp rather than loading compat_frame_tail.sp from [compat_fp - 8]).
If unwind_user_next() then resumes UNWIND_USER_TYPE_CFI on an outer caller
whose FDE uses DWARF_CFI_BASE_SP, the outer CFA is computed from the wrong
state->sp and reads the caller's saved registers from the wrong stack
offset.
> diff --git a/arch/arm64/kernel/signal.c b/arch/arm64/kernel/signal.c
> index 80398ac83c3b1..41dfbfcc1d2eb 100644
> --- a/arch/arm64/kernel/signal.c
> +++ b/arch/arm64/kernel/signal.c
[ ... ]
> @@ -1705,6 +1706,59 @@ void __init minsigstksz_setup(void)
> +bool unwind_user_sigreturn(struct unwind_user_state *state)
> +{
> + struct mm_struct *mm = current->mm;
> + struct rt_sigframe __user *sf;
> + unsigned long sigtramp;
> + u64 fp_lr[2], sp_pc[2];
> +
> + if (!mm || state->ws != 8 || !mm->context.vdso)
> + return false;
> +
> + sigtramp = (unsigned long)VDSO_SYMBOL(mm->context.vdso, sigtramp);
> + if (state->ip != sigtramp &&
> + !(state->topmost && state->ip == sigtramp + 4))
> + return false;
> +
> + if (state->sp & 0xfUL)
> + return false;
> +
> + sf = (struct rt_sigframe __user *)state->sp;
> + if (copy_from_user(fp_lr, &sf->uc.uc_mcontext.regs[29], sizeof(fp_lr)) ||
> + copy_from_user(sp_pc, &sf->uc.uc_mcontext.sp, sizeof(sp_pc)))
> + return false;
[Severity: Medium]
Can unwind_user_sigreturn() read from a shifted struct rt_sigframe pointer
when the signal handler was unwound via frame pointers?
When a signal handler with stack frame size S > 16 is unwound via
UNWIND_USER_TYPE_FP, unwind_user_next_fp() sets state->ip = sigtramp and
state->sp = handler_fp + 16 = (unsigned long)user->sigframe - (S - 16),
which remains 16-byte aligned. On the next step, unwind_user_sigreturn()
casts that shifted state->sp to struct rt_sigframe __user *; for a 32-byte
handler frame, sf is user->sigframe - 16, so reading regs[29..30] and
{sp, pc} actually reads regs[27..28] and regs[29..30] from the real
sigcontext, passing the alignment and non-zero checks and corrupting the
rest of the unwind walk.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261122235757.3456048-1-irogers@google.com?part=6
next prev parent reply other threads:[~2026-11-23 0:16 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-22 23:57 [RFC PATCH v1 00/11] unwind: Minimal DWARF CFI stack unwinding for x86, arm64, and riscv Ian Rogers
2026-11-22 23:57 ` [RFC PATCH v1 01/11] unwind: Add Minimal DWARF CFI bytecode interpreter and KUnit tests Ian Rogers
2026-11-23 0:11 ` sashiko-bot
2026-11-23 0:40 ` bot+bpf-ci
2026-11-22 23:57 ` [RFC PATCH v1 02/11] unwind_user: Support Minimal DWARF CFI user-space unwinding Ian Rogers
2026-11-23 0:11 ` sashiko-bot
2026-11-23 0:39 ` bot+bpf-ci
2026-11-22 23:57 ` [RFC PATCH v1 03/11] scripts, unwind: Add build-time .eh_frame minifier Ian Rogers
2026-11-23 0:40 ` bot+bpf-ci
2026-11-22 23:57 ` [RFC PATCH v1 04/11] objtool/ibt: Ignore .eh_frame relocations during ENDBR validation Ian Rogers
2026-11-22 23:57 ` [RFC PATCH v1 05/11] x86/unwind: Add Minimal DWARF CFI kernel unwinder Ian Rogers
2026-11-23 0:56 ` bot+bpf-ci
2026-11-22 23:57 ` [RFC PATCH v1 06/11] arm64: unwind_user: Support Minimal DWARF CFI and FP user unwinding Ian Rogers
2026-11-23 0:16 ` sashiko-bot [this message]
2026-11-22 23:57 ` [RFC PATCH v1 07/11] arm64/unwind: Add Minimal DWARF CFI kernel unwinder Ian Rogers
2026-11-23 0:24 ` sashiko-bot
2026-11-23 0:56 ` bot+bpf-ci
2026-11-22 23:57 ` [RFC PATCH v1 08/11] riscv: unwind_user: Support Minimal DWARF CFI and FP user unwinding Ian Rogers
2026-11-23 0:39 ` bot+bpf-ci
2026-11-22 23:57 ` [RFC PATCH v1 09/11] riscv/unwind: Add Minimal DWARF CFI kernel unwinder Ian Rogers
2026-11-23 0:24 ` sashiko-bot
2026-11-23 0:56 ` bot+bpf-ci
2026-11-22 23:57 ` [RFC PATCH v1 10/11] selftests/perf_events: Add Minimal DWARF CFI deferred user unwind test Ian Rogers
2026-11-23 0:40 ` bot+bpf-ci
2026-11-22 23:57 ` [RFC PATCH v1 11/11] scripts: Add eh_frame_min.py .eh_frame coverage and size analyzer Ian Rogers
2026-11-23 0:39 ` bot+bpf-ci
2026-11-23 0:24 ` [RFC PATCH v1 00/11] unwind: Minimal DWARF CFI stack unwinding for x86, arm64, and riscv sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-228465@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=acme@kernel.org \
--cc=alex@ghiti.fr \
--cc=andrii@kernel.org \
--cc=aou@eecs.berkeley.edu \
--cc=ardb@kernel.org \
--cc=ast@kernel.org \
--cc=bp@alien8.de \
--cc=bpf@vger.kernel.org \
--cc=catalin.marinas@arm.com \
--cc=daniel@iogearbox.net \
--cc=dave.hansen@linux.intel.com \
--cc=dylanbhatch@google.com \
--cc=gary@garyguo.net \
--cc=indu.bhagat@oracle.com \
--cc=irogers@google.com \
--cc=jpoimboe@kernel.org \
--cc=jremus@linux.ibm.com \
--cc=kvmarm@lists.linux.dev \
--cc=linux-efi@vger.kernel.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=maz@kernel.org \
--cc=mhiramat@kernel.org \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=nathan@kernel.org \
--cc=nsc@kernel.org \
--cc=ojeda@kernel.org \
--cc=oupton@kernel.org \
--cc=palmer@dabbelt.com \
--cc=peterz@infradead.org \
--cc=pjw@kernel.org \
--cc=rostedt@goodmis.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=shuah@kernel.org \
--cc=tglx@kernel.org \
--cc=will@kernel.org \
--cc=wnliu@google.com \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox