From: Jens Remus <jremus@linux.ibm.com>
To: Steven Rostedt <rostedt@kernel.org>
Cc: bpf@vger.kernel.org, sashiko@lists.linux.dev,
Indu Bhagat <ibhagatgnu@gmail.com>,
Josh Poimboeuf <jpoimboe@kernel.org>,
Dylan Hatch <dylanbhatch@google.com>
Subject: Re: [PATCH v14 13/19] unwind_user: Enable archs that pass RA in a register
Date: Mon, 18 May 2026 18:16:52 +0200 [thread overview]
Message-ID: <bd711f74-a1f3-4410-975b-64e9009aaf30@linux.ibm.com> (raw)
In-Reply-To: <8761b037-d8f8-4142-9091-cc51d0d19df8@linux.ibm.com>
On 5/18/2026 4:57 PM, Jens Remus wrote:
> On 5/5/2026 8:35 PM, sashiko-bot@kernel.org wrote:
>> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
>> - [High] Unprivileged user space can trigger a kernel warning (`WARN_ON_ONCE`) and potential panic by providing a maliciously crafted `.sframe` section.
>> --
>>
>> commit 20f03d41baa46baef137fb9a88081c8f92b5eb5f
>> Author: Jens Remus <jremus@linux.ibm.com>
>>
>> unwind_user: Enable archs that pass RA in a register
>>
>> This commit updates the user space stack unwinder to support architectures
>> that pass the return address in a register instead of saving it on the
>> stack. It also handles architectures where the stack pointer may be
>> unchanged in the topmost frame.
>>
>>> diff --git a/include/linux/unwind_user.h b/include/linux/unwind_user.h
>>> index 64618618febde..bc2edae399556 100644
>>> --- a/include/linux/unwind_user.h
>>> +++ b/include/linux/unwind_user.h
>>> @@ -23,6 +23,15 @@ static inline bool unwind_user_at_function_start(struct pt_regs *regs)
>>> #define unwind_user_at_function_start unwind_user_at_function_start
>>> #endif
>>>
>>> +#ifndef unwind_user_get_ra_reg
>>> +static inline int unwind_user_get_ra_reg(unsigned long *val)
>>> +{
>>> + WARN_ON_ONCE(1);
>
> Replace with the following to resolve below issue:
>
> dbg_once("unwind_user_get_ra_reg() not implemented\n");
Omit or replace by the following?
pr_debug_once("%s (%d): unwind_user_get_ra_reg() not implemented\n",
current->comm, current->pid);
This did not work with dbg_once() defined in kernel/unwind/user.c as
follows, as linux/unwind_deferred.h includes linux/unwind_user.h and
therefore gets included into other modules that do not define dbg_once()
(e.g. via linux/irq-entry-common.h including linux/unwind_deferred.h).
Steven, Should I omit the dbg_once() or could I replace by the above
unguarded pr_debug_once()?
#ifdef CONFIG_DYNAMIC_DEBUG
#define dbg_once(fmt, ...) \
pr_debug_once("%s (%d): " fmt, current->comm, current->pid, ##__VA_ARGS__)
#else /* !CONFIG_DYNAMIC_DEBUG */
#define dbg_once(args...) no_printk(args)
#endif /* !CONFIG_DYNAMIC_DEBUG */
>
>>
>> Can a maliciously crafted .sframe section trigger this warning and panic
>> the kernel if panic_on_warn is enabled?
>>
>> The SFrame unwind data is parsed from user-provided ELF binaries, so the
>> .sframe sections are entirely user-controlled.
>>
>> If an unprivileged user on an architecture using the generic fallback
>> provides an SFrame Frame Row Entry with dataword_count > 0 but an
>> explicit ra_off dataword of 0, it appears this would bypass the
>> frame->outermost check while keeping frame->ra_off == 0.
>
> Valid. On architectures that pass the RA on the stack and therefore do
> not implement unwind_user_get_ra_reg(), such as x86-64, above
> WARN_ON_ONCE(1) can be triggered using forged .sframe that maliciously
> specifies the SFrame fixed RA offset (from CFA) as zero and has a SFrame
> FRE with either no RA and FP offsets with a RA padding offset of zero.
>
>>
>> When the kernel unwinds the stack, unwind_user_next_common() would see
>> frame->ra_off == 0 and call unwind_user_get_ra_reg():
>>
>> kernel/unwind/user.c:unwind_user_next_common() {
>> ...
>> if (frame->ra_off) {
>> if (get_user_word(&ra, cfa, frame->ra_off, state->ws))
>> return -EINVAL;
>> } else {
>> if (!state->topmost || unwind_user_get_ra_reg(&ra))
>> return -EINVAL;
>> }
>> ...
>> }
>>
>> Would it be better to gracefully return an error code like -EINVAL here
>> without raising a warning?
>>
>>> + return -EINVAL;
>>> +}
>>
>> [ ... ]
>>
>
> Regards,
> Jens
Thanks and regards,
Jens
--
Jens Remus
Linux on Z Development (D3303)
jremus@de.ibm.com / jremus@linux.ibm.com
IBM Deutschland Research & Development GmbH; Vorsitzender des Aufsichtsrats: Wolfgang Wendt; Geschäftsführung: David Faller; Sitz der Gesellschaft: Ehningen; Registergericht: Amtsgericht Stuttgart, HRB 243294
IBM Data Privacy Statement: https://www.ibm.com/privacy/
next prev parent reply other threads:[~2026-05-18 16:29 UTC|newest]
Thread overview: 91+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-05 12:16 [PATCH v14 00/19] unwind_deferred: Implement sframe handling Jens Remus
2026-05-05 12:17 ` [PATCH v14 01/19] unwind_user: Add generic and arch-specific headers to MAINTAINERS Jens Remus
2026-05-05 12:17 ` [PATCH v14 02/19] unwind_user/sframe: Add support for reading .sframe headers Jens Remus
2026-05-05 12:49 ` sashiko-bot
2026-05-06 13:42 ` Jens Remus
2026-05-07 14:55 ` Jens Remus
2026-05-08 23:02 ` Indu Bhagat
2026-05-11 10:05 ` Jens Remus
2026-05-05 12:17 ` [PATCH v14 03/19] unwind_user/sframe: Store .sframe section data in per-mm maple tree Jens Remus
2026-05-05 18:51 ` sashiko-bot
2026-05-06 13:50 ` Jens Remus
2026-05-06 15:21 ` Steven Rostedt
2026-05-12 15:52 ` Jens Remus
2026-05-20 14:48 ` Jens Remus
2026-05-18 15:22 ` Jens Remus
2026-05-05 12:17 ` [PATCH v14 04/19] x86/uaccess: Add unsafe_copy_from_user() implementation Jens Remus
2026-05-05 18:22 ` sashiko-bot
2026-05-06 14:13 ` Jens Remus
2026-05-06 15:05 ` Steven Rostedt
2026-05-06 14:09 ` Jens Remus
2026-05-06 15:03 ` Steven Rostedt
2026-05-06 21:13 ` David Laight
2026-05-06 21:17 ` David Laight
2026-05-05 12:17 ` [PATCH v14 05/19] unwind_user/sframe: Add support for reading .sframe contents Jens Remus
2026-05-05 18:59 ` sashiko-bot
2026-05-06 14:34 ` Jens Remus
2026-05-06 15:01 ` Steven Rostedt
2026-05-06 15:29 ` Jens Remus
2026-05-08 9:49 ` Jens Remus
2026-05-08 23:04 ` Indu Bhagat
2026-05-12 13:35 ` Jens Remus
2026-05-13 12:22 ` Steven Rostedt
2026-05-08 23:03 ` Indu Bhagat
2026-05-08 10:50 ` Jens Remus
2026-05-11 16:16 ` Jens Remus
2026-05-05 12:17 ` [PATCH v14 06/19] unwind_user/sframe: Detect .sframe sections in executables Jens Remus
2026-05-05 12:53 ` sashiko-bot
2026-05-06 14:56 ` Jens Remus
2026-05-06 15:36 ` Steven Rostedt
2026-05-08 23:05 ` Indu Bhagat
2026-05-05 12:17 ` [PATCH v14 07/19] unwind_user/sframe: Wire up unwind_user to sframe Jens Remus
2026-05-05 18:55 ` sashiko-bot
2026-05-07 16:18 ` Jens Remus
2026-05-08 23:07 ` Indu Bhagat
2026-05-11 16:46 ` Steven Rostedt
2026-05-05 12:17 ` [PATCH v14 08/19] unwind_user: Stop when reaching an outermost frame Jens Remus
2026-05-05 12:40 ` sashiko-bot
2026-05-06 15:01 ` Jens Remus
2026-05-06 15:40 ` Steven Rostedt
2026-05-05 12:17 ` [PATCH v14 09/19] unwind_user/sframe: Add support for outermost frame indication Jens Remus
2026-05-05 12:17 ` [PATCH v14 10/19] unwind_user/sframe: Remove .sframe section on detected corruption Jens Remus
2026-05-05 20:39 ` sashiko-bot
2026-05-07 16:23 ` Jens Remus
2026-05-05 12:17 ` [PATCH v14 11/19] unwind_user/sframe: Show file name in debug output Jens Remus
2026-05-05 18:46 ` sashiko-bot
2026-05-12 14:52 ` Jens Remus
2026-05-13 9:20 ` Jens Remus
2026-05-18 15:27 ` Jens Remus
2026-05-05 12:17 ` [PATCH v14 12/19] unwind_user/sframe: Add .sframe validation option Jens Remus
2026-05-05 18:32 ` sashiko-bot
2026-05-12 14:23 ` Jens Remus
2026-05-13 12:30 ` Steven Rostedt
2026-05-08 10:51 ` Jens Remus
2026-05-05 12:17 ` [PATCH v14 13/19] unwind_user: Enable archs that pass RA in a register Jens Remus
2026-05-05 18:35 ` sashiko-bot
2026-05-18 14:57 ` Jens Remus
2026-05-18 16:16 ` Jens Remus [this message]
2026-05-18 16:31 ` Steven Rostedt
2026-05-19 12:24 ` Jens Remus
2026-05-19 12:42 ` Steven Rostedt
2026-05-19 14:30 ` Jens Remus
2026-05-05 12:17 ` [PATCH v14 14/19] unwind_user: Flexible FP/RA recovery rules Jens Remus
2026-05-05 18:34 ` sashiko-bot
2026-05-18 15:08 ` Jens Remus
2026-05-05 12:17 ` [PATCH v14 15/19] unwind_user: Flexible CFA " Jens Remus
2026-05-05 12:17 ` [PATCH v14 16/19] unwind_user/sframe: Add support for SFrame V3 flexible FDEs Jens Remus
2026-05-05 18:55 ` sashiko-bot
2026-05-07 15:30 ` Jens Remus
2026-05-13 6:26 ` Indu Bhagat
2026-05-13 13:50 ` Jens Remus
2026-05-13 15:16 ` Steven Rostedt
2026-05-05 12:17 ` [PATCH v14 17/19] unwind_user/sframe: Separate reading of FRE from reading of FRE data words Jens Remus
2026-05-05 19:05 ` sashiko-bot
2026-05-07 16:01 ` Jens Remus
2026-05-05 12:17 ` [PATCH v14 18/19] unwind_user/sframe/x86: Enable sframe unwinding on x86 Jens Remus
2026-05-05 19:07 ` sashiko-bot
2026-05-18 15:33 ` Jens Remus
2026-05-05 12:17 ` [PATCH v14 19/19] unwind_user/sframe: Add prctl() interface for registering .sframe sections Jens Remus
2026-05-05 18:45 ` sashiko-bot
2026-05-07 14:14 ` Jens Remus
2026-05-05 12:25 ` [PATCH v14 00/19] unwind_deferred: Implement sframe handling Jens Remus
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=bd711f74-a1f3-4410-975b-64e9009aaf30@linux.ibm.com \
--to=jremus@linux.ibm.com \
--cc=bpf@vger.kernel.org \
--cc=dylanbhatch@google.com \
--cc=ibhagatgnu@gmail.com \
--cc=jpoimboe@kernel.org \
--cc=rostedt@kernel.org \
--cc=sashiko@lists.linux.dev \
/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