All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Jens Remus" <jremus@linux.ibm.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH v16 20/20] unwind_user/sframe: Add prctl() interface for registering .sframe sections
Date: Thu, 21 May 2026 15:23:35 +0000	[thread overview]
Message-ID: <20260521152335.6E80E1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260521142546.3908498-21-jremus@linux.ibm.com>

Thank you for your contribution! Sashiko AI review found 6 potential issue(s) to consider:

New issues:
- [High] The patch adds a test-only UAPI interface that is explicitly not intended for mainline inclusion, violating ABI stability rules.
- [High] Unbounded memory allocation in PR_ADD_SFRAME allows a local Denial of Service (DoS) via memory exhaustion.
- [Low] When SFrame support is disabled, the prctl options incorrectly return -ENOSYS instead of -EINVAL.

Pre-existing issues:
- [Critical] Improper handling of -EFAULT in sframe_find() leads to premature deletion of valid unwinding metadata and poses a severe NMI deadlock risk.
- [High] A malicious user application can reliably trigger a WARN_ON_ONCE in sframe_find() by causing concurrent removals of an .sframe section, potentially panicking the system.
- [High] Unbounded iteration in sframe_validate_section() without yielding the CPU can cause softlockup DoS.
--

commit f2ba64c060979156a7ef9c545cd667594369670a
Author: Josh Poimboeuf <jpoimboe@kernel.org>

unwind_user/sframe: Add prctl() interface for registering .sframe sections

The kernel doesn't have direct visibility to the ELF contents of shared
libraries. This commit adds prctl() interfaces to allow glibc to tell the
kernel where to find .sframe sections for unwinding.

> [
>   This adds an interface for prctl() for testing loading of sframes for
>   libraries. But this interface should really be a system call. This patch
>   is for testing purposes only and should not be applied to mainline.
> ]

[Severity: High]
Since this is explicitly marked as a temporary test patch, should it be
redesigned as a proper system call or removed before being merged?

Adding temporary or experimental prctl() interfaces exposes a temporary ABI to
userspace which must be maintained indefinitely, polluting the UAPI.

> diff --git a/kernel/sys.c b/kernel/sys.c
> index 62e842055cc9c..b0a9b1e3ccd7c 100644
> --- a/kernel/sys.c
> +++ b/kernel/sys.c

[ ... ]

> @@ -2907,6 +2908,14 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3,
>  		if (arg3 & PR_CFI_LOCK && !(arg3 & PR_CFI_DISABLE))
>  			error = arch_prctl_lock_branch_landing_pad_state(me);
>  		break;
> +	case PR_ADD_SFRAME:
> +		error = sframe_add_section(arg2, arg3, arg4, arg5);

[Severity: High]
Could this allow a local Denial of Service via memory exhaustion?

A user process can repeatedly call prctl(PR_ADD_SFRAME) with valid, small
ranges. If each call allocates a new struct sframe_section and inserts it
into the mm->sframe_mt maple tree using GFP_KERNEL_ACCOUNT, an unprivileged
user might exhaust kernel memory since there is no upper limit on the total
number of sections a process can register.

[Severity: Low]
Is it intentional that the fallback stub for sframe_add_section() returns
-ENOSYS when SFrame support is disabled?

include/linux/sframe.h:sframe_add_section() {
    ...
    return -ENOSYS;
}

Standard kernel conventions dictate that unsupported or disabled prctl options
should return -EINVAL. Returning -ENOSYS incorrectly indicates to userspace
that the entire prctl syscall is unimplemented.

[Severity: High]
This is a pre-existing issue, but is there a risk of a softlockup Denial of
Service during section validation?

When registering a new .sframe section via PR_ADD_SFRAME, the kernel
synchronously validates all FDE and FRE entries in sframe_validate_section().
Because the number of FDEs is read from user-space memory and can be extremely
large, an attacker could provide a massive amount of FDEs/FREs.

Since the validation loop does not contain cond_resched(), the kernel could
spin here for seconds without yielding, triggering the softlockup detector.

> +		break;
> +	case PR_REMOVE_SFRAME:
> +		if (arg3 || arg4 || arg5)
> +			return -EINVAL;
> +		error = sframe_remove_section(arg2);

[Severity: Critical]
This is a pre-existing issue, but does handling -EFAULT in sframe_find() risk
a severe NMI deadlock and premature deletion of valid metadata?

If unsafe_get_user() cleanly faults because the memory is temporarily paged
out, it sets ret = -EFAULT. The cleanup block then calls
WARN_ON_ONCE(sframe_remove_section(sec->sframe_start)).

Because sframe_find() is used by stack unwinders (like perf) that execute
in NMI context, triggering sframe_remove_section() inside an NMI attempts
to acquire the maple tree's internal spinlock (mt_lock). If the NMI
interrupted a thread already holding mt_lock, this could result in a hard
deadlock. Furthermore, this permanently destroys perfectly valid unwinding
metadata simply because a page was not resident.

[Severity: High]
This is a pre-existing issue, but might a malicious application reliably
trigger the WARN_ON_ONCE in sframe_find(), potentially panicking the system?

If an .sframe section returns -EFAULT because it is paged out, the error
path calls WARN_ON_ONCE(sframe_remove_section(sec->sframe_start)).
If sframe_remove_section() fails to find the section, it returns -EINVAL,
causing the warning to fire.

This condition could be reliably triggered if multiple threads concurrently
unwind through the same paged-out section, or if one thread unwinds while
another explicitly removes the section using the newly added
prctl(PR_REMOVE_SFRAME). If panic_on_warn is enabled, this might allow
unprivileged users to reliably crash the system.

> +		break;
>  	default:
>  		trace_task_prctl_unknown(option, arg2, arg3, arg4, arg5);
>  		error = -EINVAL;

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260521142546.3908498-1-jremus@linux.ibm.com?part=20

      reply	other threads:[~2026-05-21 15:23 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-21 14:25 [PATCH v16 00/20] unwind_deferred: Implement sframe handling Jens Remus
2026-05-21 14:25 ` [PATCH v16 01/20] unwind_user: Add generic and arch-specific headers to MAINTAINERS Jens Remus
2026-05-21 14:25 ` [PATCH v16 02/20] unwind_user/sframe: Add support for reading .sframe headers Jens Remus
2026-05-21 14:51   ` sashiko-bot
2026-05-22 10:11     ` Jens Remus
2026-05-27 20:09   ` Steven Rostedt
2026-05-21 14:25 ` [PATCH v16 03/20] unwind_user/sframe: Store .sframe section data in per-mm maple tree Jens Remus
2026-05-21 15:04   ` sashiko-bot
2026-05-27 20:20   ` Steven Rostedt
2026-05-21 14:25 ` [PATCH v16 04/20] x86/uaccess: Add unsafe_copy_from_user() implementation Jens Remus
2026-05-21 14:25 ` [PATCH v16 05/20] unwind_user/sframe: Add support for reading .sframe contents Jens Remus
2026-05-21 15:18   ` sashiko-bot
2026-05-22  9:26     ` Jens Remus
2026-05-27 19:49       ` Steven Rostedt
2026-05-21 14:25 ` [PATCH v16 06/20] unwind_user/sframe: Detect .sframe sections in executables Jens Remus
2026-05-21 14:25 ` [PATCH v16 07/20] unwind_user/sframe: Wire up unwind_user to sframe Jens Remus
2026-05-21 14:53   ` sashiko-bot
2026-05-22  9:55     ` Jens Remus
2026-05-21 14:25 ` [PATCH v16 08/20] unwind_user: Stop when reaching an outermost frame Jens Remus
2026-05-21 14:47   ` sashiko-bot
2026-05-22 10:12     ` Jens Remus
2026-05-21 14:25 ` [PATCH v16 09/20] unwind_user/sframe: Add support for outermost frame indication Jens Remus
2026-05-21 14:25 ` [PATCH v16 10/20] unwind_user/sframe: Remove .sframe section on detected corruption Jens Remus
2026-05-21 15:19   ` sashiko-bot
2026-05-22 10:03     ` Jens Remus
2026-05-21 14:25 ` [PATCH v16 11/20] unwind_user/sframe: Show file name in debug output Jens Remus
2026-05-21 15:05   ` sashiko-bot
2026-05-22  9:58     ` Jens Remus
2026-05-21 14:25 ` [PATCH v16 12/20] unwind_user/sframe: Add .sframe validation option Jens Remus
2026-05-21 15:02   ` sashiko-bot
2026-05-22 10:08     ` Jens Remus
2026-05-21 14:25 ` [PATCH v16 13/20] unwind_user: Enable archs that pass RA in a register Jens Remus
2026-05-21 14:25 ` [PATCH v16 14/20] unwind_user: Flexible FP/RA recovery rules Jens Remus
2026-05-21 14:25 ` [PATCH v16 15/20] unwind_user: Flexible CFA " Jens Remus
2026-05-21 14:25 ` [PATCH v16 16/20] unwind_user/sframe: Add support for SFrame V3 flexible FDEs Jens Remus
2026-05-21 15:14   ` sashiko-bot
2026-05-22 10:15     ` Jens Remus
2026-05-21 14:25 ` [PATCH v16 17/20] unwind_user/sframe: Separate reading of FRE from reading of FRE data words Jens Remus
2026-05-21 14:25 ` [PATCH v16 18/20] unwind_user/sframe: Duplicate registered .sframe section data on clone/fork Jens Remus
2026-05-21 15:37   ` sashiko-bot
2026-05-21 14:25 ` [PATCH v16 19/20] unwind_user/sframe/x86: Enable sframe unwinding on x86 Jens Remus
2026-05-21 14:25 ` [PATCH v16 20/20] unwind_user/sframe: Add prctl() interface for registering .sframe sections Jens Remus
2026-05-21 15:23   ` sashiko-bot [this message]

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=20260521152335.6E80E1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=jremus@linux.ibm.com \
    --cc=sashiko-reviews@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.