From: sashiko-bot@kernel.org
To: "Jens Remus" <jremus@linux.ibm.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH v14 11/19] unwind_user/sframe: Show file name in debug output
Date: Tue, 05 May 2026 18:46:37 +0000 [thread overview]
Message-ID: <20260505184638.5648DC2BCB4@smtp.kernel.org> (raw)
In-Reply-To: <20260505121718.3572346-12-jremus@linux.ibm.com>
Thank you for your contribution! Sashiko AI review found 6 potential issue(s) to consider:
- [High] Potential use-after-free of `sec` and `sec->filename` in the error path of `__sframe_remove_section`.
- [High] A race condition in the `-EFAULT` error path of `sframe_find()` allows an unprivileged local attacker to trigger a `WARN_ON_ONCE` and potentially panic the kernel.
- [High] Unbounded kernel memory allocations controlled by user space do not use `__GFP_ACCOUNT`, allowing memory cgroup limit bypass.
- [Medium] dbg_init() fails to fall back to other VMA naming methods if vma->vm_ops->name(vma) returns NULL.
- [Medium] Directly checking `vma->vm_file` in a conditional to classify the VMA violates VMA architectural rules.
- [Medium] The functions `sframe_find()` and `sframe_add_section()` mix scope-based cleanup helpers with manual `goto`-based cleanup labels, violating kernel refactoring guidelines.
--
commit d6a437647b4507fcb6d70115c0d08b1d68cafa8a
Author: Josh Poimboeuf <jpoimboe@kernel.org>
unwind_user/sframe: Show file name in debug output
This commit adds the file name to debug output messages for sframe sections
to make debugging easier. It records the filename when the section is added
by inspecting the associated VMA.
> diff --git a/kernel/unwind/sframe.c b/kernel/unwind/sframe.c
> index 8eed6a7d96256..4419626f01734 100644
> --- a/kernel/unwind/sframe.c
> +++ b/kernel/unwind/sframe.c
> @@ -359,14 +359,17 @@ int sframe_find(unsigned long ip, struct unwind_user_frame *frame)
> end:
> user_read_access_end();
>
> - if (ret == -EFAULT)
> + if (ret == -EFAULT) {
> + dbg_sec("removing bad .sframe section\n");
> WARN_ON_ONCE(sframe_remove_section(sec->sframe_start));
> + }
Can concurrent executions of this error path trigger the WARN_ON_ONCE()? If
two threads hit the EFAULT path concurrently, the first successfully removes
the section, but the second fails to find it and returns EINVAL, which
triggers the warning.
Also, does this code mix goto-based error handling with scope-based cleanup
helpers? The sframe_find() function uses guard(srcu)(&sframe_srcu) while
also using the goto end label. The sframe_add_section() function similarly
mixes scoped_guard with goto. The guidelines specify that functions should
convert all resources to scope-based cleanup or convert none of them.
[ ... ]
> @@ -496,7 +501,7 @@ static int __sframe_remove_section(struct mm_struct *mm,
> struct sframe_section *sec)
> {
> if (!mtree_erase(&mm->sframe_mt, sec->text_start)) {
> - dbg("mtree_erase failed: text=%lx\n", sec->text_start);
> + dbg_sec("mtree_erase failed: text=%lx\n", sec->text_start);
Does accessing sec->filename in dbg_sec() risk a use-after-free here? If
mtree_erase() fails, it indicates the section might have been concurrently
removed. The SRCU grace period could expire, causing sec to be freed before
dbg_sec() is called.
[ ... ]
> diff --git a/kernel/unwind/sframe_debug.h b/kernel/unwind/sframe_debug.h
> index 36352124cde81..e568be4172b1b 100644
> --- a/kernel/unwind/sframe_debug.h
> +++ b/kernel/unwind/sframe_debug.h
[ ... ]
> +static inline void dbg_init(struct sframe_section *sec)
> +{
> + struct mm_struct *mm = current->mm;
> + struct vm_area_struct *vma;
> +
> + guard(mmap_read_lock)(mm);
> + vma = vma_lookup(mm, sec->sframe_start);
> + if (!vma)
> + sec->filename = kstrdup("(vma gone???)", GFP_KERNEL);
> + else if (vma->vm_file)
> + sec->filename = kstrdup_quotable_file(vma->vm_file, GFP_KERNEL);
Does checking vma->vm_file directly skip proper classification for some
anonymous VMAs? According to the VMA guidelines, certain anonymous VMAs like
private mappings of /dev/zero have vma->vm_file set. Should this use
!vma_is_anonymous(vma) instead?
Do these string allocations need __GFP_ACCOUNT? Since they are triggered by
user space and persist until the section is removed, could a user allocate
large amounts of uncharged memory and bypass memory cgroup limits?
> + else if (vma->vm_ops && vma->vm_ops->name)
> + sec->filename = kstrdup(vma->vm_ops->name(vma), GFP_KERNEL);
If vma->vm_ops->name(vma) returns NULL, will kstrdup() return NULL and skip
the subsequent fallback naming methods? Does this leave sec->filename as
NULL, causing debug logs to print (null)?
> + else if (arch_vma_name(vma))
> + sec->filename = kstrdup(arch_vma_name(vma), GFP_KERNEL);
> + else if (!vma->vm_mm)
> + sec->filename = kstrdup("(vdso)", GFP_KERNEL);
> + else
> + sec->filename = kstrdup("(anonymous)", GFP_KERNEL);
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260505121718.3572346-1-jremus@linux.ibm.com?part=11
next prev parent reply other threads:[~2026-05-05 18:46 UTC|newest]
Thread overview: 80+ 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-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 [this message]
2026-05-12 14:52 ` Jens Remus
2026-05-13 9:20 ` 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-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-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-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=20260505184638.5648DC2BCB4@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=jremus@linux.ibm.com \
--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