Re: [PATCH 1/2] stacktrace: Provide arch_in_irqentry_text() hook

From: Bradley Morgan

Date: Thu Aug 27 2026 - 13:09:09 EST


On 27 August 2026 16:00:21 BST, Yuanhe Shu <xiangzao@xxxxxxxxxxxxxxxxx>
wrote:
>in_irqentry_text() decides whether a stack address belongs to interrupt
>entry code by checking the .irqentry.text and .softirqentry.text section
>ranges. filter_irq_stacks() uses it to truncate interrupt stacks at the
>entry point, which stack depot depends on to deduplicate them: traces
>that continue past the interrupt entry lead to unbounded depot growth,
>see commit e94006608949 ("lib/stackdepot: always do filter_irq_stacks()
>in stack_depot_save()").
>
>An architecture may deliver interrupts through entry code that cannot be
>placed in .irqentry.text. in_irqentry_text() then never recognizes the
>entry point and the truncation silently stops happening. The markers are
>meant to cover all interrupt entry functions; when they do not, the depot
>ends up holding essentially random stacks:
>
> https://lore.kernel.org/all/CACT4Y+aReMGLYua2rCLHgFpS9io5cZC04Q8GLs-uNmrn1ezxYQ@xxxxxxxxxxxxxx/
>
>Add an optional arch_in_irqentry_text() hook, consulted in addition to
>the section range checks, gated on a new ARCH_HAS_IN_IRQENTRY_TEXT
>symbol. Gating keeps the default a static inline returning false, which
>folds away entirely on every architecture that does not opt in, instead
>of a __weak stub that every architecture would have to call. This
>mirrors the existing ARCH_HAS_* hooks in lib/Kconfig such as
>ARCH_HAS_COPY_MC.
>
>No functional change on its own.
>
>The first user is the FRED fix in the follow-up patch, which carries a
>Fixes: tag and is Cc'ed to stable; tag this prerequisite for stable too,
>so the two are picked up as a pair.
>
>Cc: stable@xxxxxxxxxxxxxxx

LGTM, thanks

Reviewed-by: Bradley Morgan <brads@xxxxxxxxxxxxxx>

>Signed-off-by: Yuanhe Shu <xiangzao@xxxxxxxxxxxxxxxxx>
>---
> include/linux/stacktrace.h | 16 ++++++++++++++++
> kernel/stacktrace.c | 3 ++-
> lib/Kconfig | 3 +++
> 3 files changed, 21 insertions(+), 1 deletion(-)
>
>diff --git a/include/linux/stacktrace.h b/include/linux/stacktrace.h
>index 525cf60673fe..e933ce86447f 100644
>--- a/include/linux/stacktrace.h
>+++ b/include/linux/stacktrace.h
>@@ -62,6 +62,22 @@ void arch_stack_walk_user(stack_trace_consume_fn consume_entry, void *cookie,
> const struct pt_regs *regs);
> #endif /* CONFIG_ARCH_STACKWALK */
>
>+/*
>+ * Optional arch provided check for additional IRQ entry text, called
>+ * in addition to the .irqentry.text and .softirqentry.text range
>+ * checks in in_irqentry_text(). Implement this if the architecture
>+ * delivers interrupts or exceptions through entry code which cannot
>+ * reside in those sections.
>+ */
>+#ifdef CONFIG_ARCH_HAS_IN_IRQENTRY_TEXT
>+bool arch_in_irqentry_text(unsigned long addr);
>+#else
>+static inline bool arch_in_irqentry_text(unsigned long addr)
>+{
>+ return false;
>+}
>+#endif
>+
> #ifdef CONFIG_STACKTRACE
> void stack_trace_print(const unsigned long *trace, unsigned int
> nr_entries,
> int spaces);
>diff --git a/kernel/stacktrace.c b/kernel/stacktrace.c
>index afb3c116da91..9e85ac900889 100644
>--- a/kernel/stacktrace.c
>+++ b/kernel/stacktrace.c
>@@ -379,7 +379,8 @@ static inline bool in_irqentry_text(unsigned long ptr)
> return (ptr >= (unsigned long)&__irqentry_text_start &&
> ptr < (unsigned long)&__irqentry_text_end) ||
> (ptr >= (unsigned long)&__softirqentry_text_start &&
>- ptr < (unsigned long)&__softirqentry_text_end);
>+ ptr < (unsigned long)&__softirqentry_text_end) ||
>+ arch_in_irqentry_text(ptr);
> }
>
> /**
>diff --git a/lib/Kconfig b/lib/Kconfig
>index 4e6b34c3346d..45ff30d0a995 100644
>--- a/lib/Kconfig
>+++ b/lib/Kconfig
>@@ -551,6 +551,9 @@ config ARCH_HAS_COPY_MC
> config ARCH_STACKWALK
> bool
>
>+config ARCH_HAS_IN_IRQENTRY_TEXT
>+ bool
>+
> config STACKDEPOT
> bool
> select STACKTRACE
>


--- Thanks!
https://lore.kernel.org/all/EE579805-42F2-4C58-B752-F28779EEB717@xxxxxxxxx/