]> git.baikalelectronics.ru Git - kernel.git/commitdiff
kasan: stackdepot: move filter_irq_stacks() to stackdepot.c
authorAlexander Potapenko <glider@google.com>
Tue, 7 Apr 2020 03:10:22 +0000 (20:10 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 7 Apr 2020 17:43:43 +0000 (10:43 -0700)
filter_irq_stacks() can be used by other tools (e.g.  KMSAN), so it needs
to be moved to a common location.  lib/stackdepot.c seems a good place, as
filter_irq_stacks() is usually applied to the output of
stack_trace_save().

This patch has been previously mailed as part of KMSAN RFC patch series.

[glider@google.co: nds32: linker script: add SOFTIRQENTRY_TEXT\
Link: http://lkml.kernel.org/r/20200311121002.241430-1-glider@google.com
[glider@google.com: add IRQENTRY_TEXT and SOFTIRQENTRY_TEXT to linker script]
Link: http://lkml.kernel.org/r/20200311121124.243352-1-glider@google.com
Signed-off-by: Alexander Potapenko <glider@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Vegard Nossum <vegard.nossum@oracle.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Marco Elver <elver@google.com>
Cc: Andrey Konovalov <andreyknvl@google.com>
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Link: http://lkml.kernel.org/r/20200220141916.55455-3-glider@google.com
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
arch/ia64/kernel/vmlinux.lds.S
arch/nds32/kernel/vmlinux.lds.S
include/linux/stackdepot.h
lib/stackdepot.c
mm/kasan/common.c

index 1ec6b703c5b4f75a616eddf6cc9c3c5e1566c3b9..6b5652ee76f96f4085955203dfcf0cb2535ce44c 100644 (file)
@@ -54,6 +54,8 @@ SECTIONS {
                CPUIDLE_TEXT
                LOCK_TEXT
                KPROBES_TEXT
+               IRQENTRY_TEXT
+               SOFTIRQENTRY_TEXT
                *(.gnu.linkonce.t*)
        }
 
index f679d33974366205b7d39d25de03311127bcac07..7a6c1cefe3fe5cd61043e0dee72197b170f0a1c5 100644 (file)
@@ -47,6 +47,7 @@ SECTIONS
                LOCK_TEXT
                KPROBES_TEXT
                IRQENTRY_TEXT
+               SOFTIRQENTRY_TEXT
                *(.fixup)
        }
 
index 3efa97d482cbea57df8a678635d2c136f2786d40..24d49c732341ab3f85bf18b7478cca921e0317a5 100644 (file)
@@ -19,4 +19,6 @@ depot_stack_handle_t stack_depot_save(unsigned long *entries,
 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);
+
 #endif
index 1ec36ee344e011e48b3254620a7f6790c2c0e45e..2caffc64e4c82891948abb97019c0c88d1b83584 100644 (file)
@@ -20,6 +20,7 @@
  */
 
 #include <linux/gfp.h>
+#include <linux/interrupt.h>
 #include <linux/jhash.h>
 #include <linux/kernel.h>
 #include <linux/mm.h>
@@ -316,3 +317,26 @@ 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);
index e61b4a49221828628e9bd1767255bf4b9ee7b8f1..2906358e42f05287731deb8f2c7e86ddbc5b4a59 100644 (file)
@@ -15,7 +15,6 @@
  */
 
 #include <linux/export.h>
-#include <linux/interrupt.h>
 #include <linux/init.h>
 #include <linux/kasan.h>
 #include <linux/kernel.h>
 #include "kasan.h"
 #include "../slab.h"
 
-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);
-}
-
-static inline 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;
-}
-
 static inline depot_stack_handle_t save_stack(gfp_t flags)
 {
        unsigned long entries[KASAN_STACK_DEPTH];