From: Greg Kroah-Hartman Date: Tue, 12 Apr 2022 16:38:57 +0000 (+0200) Subject: 5.15-stable patches X-Git-Tag: v5.17.3~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2bdd5423998b0c5ada7d5530fb857c44703479ac;p=thirdparty%2Fkernel%2Fstable-queue.git 5.15-stable patches added patches: stacktrace-move-filter_irq_stacks-to-kernel-stacktrace.c.patch --- diff --git a/queue-5.15/series b/queue-5.15/series index 5d09df55bf4..dc38a07ef77 100644 --- a/queue-5.15/series +++ b/queue-5.15/series @@ -275,3 +275,4 @@ irqchip-gic-gic-v3-prevent-gsi-to-sgi-translations.patch mm-sparsemem-fix-mem_section-will-never-be-null-gcc-12-warning.patch static_call-don-t-make-__static_call_return0-static.patch powerpc-fix-virt_addr_valid-for-64-bit-book3e-32-bit.patch +stacktrace-move-filter_irq_stacks-to-kernel-stacktrace.c.patch diff --git a/queue-5.15/stacktrace-move-filter_irq_stacks-to-kernel-stacktrace.c.patch b/queue-5.15/stacktrace-move-filter_irq_stacks-to-kernel-stacktrace.c.patch new file mode 100644 index 00000000000..240527d17e7 --- /dev/null +++ b/queue-5.15/stacktrace-move-filter_irq_stacks-to-kernel-stacktrace.c.patch @@ -0,0 +1,138 @@ +From f39f21b3ddc7fc0f87eb6dc75ddc81b5bbfb7672 Mon Sep 17 00:00:00 2001 +From: Marco Elver +Date: Fri, 5 Nov 2021 13:45:25 -0700 +Subject: stacktrace: move filter_irq_stacks() to kernel/stacktrace.c + +From: Marco Elver + +commit f39f21b3ddc7fc0f87eb6dc75ddc81b5bbfb7672 upstream. + +filter_irq_stacks() has little to do with the stackdepot implementation, +except that it is usually used by users (such as KASAN) of stackdepot to +reduce the stack trace. + +However, filter_irq_stacks() itself is not useful without a stack trace +as obtained by stack_trace_save() and friends. + +Therefore, move filter_irq_stacks() to kernel/stacktrace.c, so that new +users of filter_irq_stacks() do not have to start depending on +STACKDEPOT only for filter_irq_stacks(). + +Link: https://lkml.kernel.org/r/20210923104803.2620285-1-elver@google.com +Signed-off-by: Marco Elver +Acked-by: Dmitry Vyukov +Cc: Alexander Potapenko +Cc: Jann Horn +Cc: Aleksandr Nogikh +Cc: Taras Madan +Signed-off-by: Andrew Morton +Signed-off-by: Linus Torvalds +Signed-off-by: Greg Kroah-Hartman +--- + include/linux/stackdepot.h | 2 -- + include/linux/stacktrace.h | 1 + + kernel/stacktrace.c | 30 ++++++++++++++++++++++++++++++ + lib/stackdepot.c | 24 ------------------------ + 4 files changed, 31 insertions(+), 26 deletions(-) + +--- a/include/linux/stackdepot.h ++++ b/include/linux/stackdepot.h +@@ -19,8 +19,6 @@ depot_stack_handle_t stack_depot_save(un + unsigned int stack_depot_fetch(depot_stack_handle_t handle, + unsigned long **entries); + +-unsigned int filter_irq_stacks(unsigned long *entries, unsigned int nr_entries); +- + #ifdef CONFIG_STACKDEPOT + int stack_depot_init(void); + #else +--- a/include/linux/stacktrace.h ++++ b/include/linux/stacktrace.h +@@ -21,6 +21,7 @@ unsigned int stack_trace_save_tsk(struct + unsigned int stack_trace_save_regs(struct pt_regs *regs, unsigned long *store, + unsigned int size, unsigned int skipnr); + unsigned int stack_trace_save_user(unsigned long *store, unsigned int size); ++unsigned int filter_irq_stacks(unsigned long *entries, unsigned int nr_entries); + + /* Internal interfaces. Do not use in generic code */ + #ifdef CONFIG_ARCH_STACKWALK +--- a/kernel/stacktrace.c ++++ b/kernel/stacktrace.c +@@ -13,6 +13,7 @@ + #include + #include + #include ++#include + + /** + * stack_trace_print - Print the entries in the stack trace +@@ -373,3 +374,32 @@ unsigned int stack_trace_save_user(unsig + #endif /* CONFIG_USER_STACKTRACE_SUPPORT */ + + #endif /* !CONFIG_ARCH_STACKWALK */ ++ ++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); ++} ++ ++/** ++ * filter_irq_stacks - Find first IRQ stack entry in trace ++ * @entries: Pointer to stack trace array ++ * @nr_entries: Number of entries in the storage array ++ * ++ * Return: Number of trace entries until IRQ stack starts. ++ */ ++unsigned int filter_irq_stacks(unsigned long *entries, unsigned int nr_entries) ++{ ++ unsigned int i; ++ ++ for (i = 0; i < nr_entries; i++) { ++ if (in_irqentry_text(entries[i])) { ++ /* Include the irqentry function into the stack. */ ++ return i + 1; ++ } ++ } ++ return nr_entries; ++} ++EXPORT_SYMBOL_GPL(filter_irq_stacks); +--- a/lib/stackdepot.c ++++ b/lib/stackdepot.c +@@ -20,7 +20,6 @@ + */ + + #include +-#include + #include + #include + #include +@@ -341,26 +340,3 @@ fast_exit: + return retval; + } + EXPORT_SYMBOL_GPL(stack_depot_save); +- +-static inline int 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); +-} +- +-unsigned int filter_irq_stacks(unsigned long *entries, +- unsigned int nr_entries) +-{ +- unsigned int i; +- +- for (i = 0; i < nr_entries; i++) { +- if (in_irqentry_text(entries[i])) { +- /* Include the irqentry function into the stack. */ +- return i + 1; +- } +- } +- return nr_entries; +-} +-EXPORT_SYMBOL_GPL(filter_irq_stacks);