linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/8] x86/entry: KCSAN/KASAN/UBSAN vs noinstr
@ 2020-06-04 10:22 Peter Zijlstra
  2020-06-04 10:22 ` [PATCH 1/8] x86, kcsan: Remove __no_kcsan_or_inline usage Peter Zijlstra
                   ` (8 more replies)
  0 siblings, 9 replies; 13+ messages in thread
From: Peter Zijlstra @ 2020-06-04 10:22 UTC (permalink / raw)
  To: tglx
  Cc: x86, elver, paulmck, kasan-dev, linux-kernel, peterz, will,
	dvyukov, glider, andreyknvl

Hai,

Here's the remaining few patches to make KCSAN/KASAN and UBSAN work with noinstr.



^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 1/8] x86, kcsan: Remove __no_kcsan_or_inline usage
  2020-06-04 10:22 [PATCH 0/8] x86/entry: KCSAN/KASAN/UBSAN vs noinstr Peter Zijlstra
@ 2020-06-04 10:22 ` Peter Zijlstra
  2020-06-04 10:22 ` [PATCH 2/8] kcsan: Remove __no_kcsan_or_inline Peter Zijlstra
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 13+ messages in thread
From: Peter Zijlstra @ 2020-06-04 10:22 UTC (permalink / raw)
  To: tglx
  Cc: x86, elver, paulmck, kasan-dev, linux-kernel, peterz, will,
	dvyukov, glider, andreyknvl

Now that KCSAN relies on -tsan-distinguish-volatile we no longer need
the annotation for constant_test_bit(). Remove it.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
 arch/x86/include/asm/bitops.h |    6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

--- a/arch/x86/include/asm/bitops.h
+++ b/arch/x86/include/asm/bitops.h
@@ -201,12 +201,8 @@ arch_test_and_change_bit(long nr, volati
 	return GEN_BINARY_RMWcc(LOCK_PREFIX __ASM_SIZE(btc), *addr, c, "Ir", nr);
 }
 
-static __no_kcsan_or_inline bool constant_test_bit(long nr, const volatile unsigned long *addr)
+static __always_inline bool constant_test_bit(long nr, const volatile unsigned long *addr)
 {
-	/*
-	 * Because this is a plain access, we need to disable KCSAN here to
-	 * avoid double instrumentation via instrumented bitops.
-	 */
 	return ((1UL << (nr & (BITS_PER_LONG-1))) &
 		(addr[nr >> _BITOPS_LONG_SHIFT])) != 0;
 }



^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 2/8] kcsan: Remove __no_kcsan_or_inline
  2020-06-04 10:22 [PATCH 0/8] x86/entry: KCSAN/KASAN/UBSAN vs noinstr Peter Zijlstra
  2020-06-04 10:22 ` [PATCH 1/8] x86, kcsan: Remove __no_kcsan_or_inline usage Peter Zijlstra
@ 2020-06-04 10:22 ` Peter Zijlstra
  2020-06-04 10:22 ` [PATCH 3/8] x86, kcsan: Add __no_kcsan to noinstr Peter Zijlstra
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 13+ messages in thread
From: Peter Zijlstra @ 2020-06-04 10:22 UTC (permalink / raw)
  To: tglx
  Cc: x86, elver, paulmck, kasan-dev, linux-kernel, peterz, will,
	dvyukov, glider, andreyknvl

There are no more user of this function attribute, also, with us now
actively supporting '__no_kcsan inline' it doesn't make sense to have
in any case.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
 Documentation/dev-tools/kcsan.rst |    6 ------
 include/linux/compiler_types.h    |    5 +----
 2 files changed, 1 insertion(+), 10 deletions(-)

--- a/Documentation/dev-tools/kcsan.rst
+++ b/Documentation/dev-tools/kcsan.rst
@@ -114,12 +114,6 @@ functions, compilation units, or entire
   To dynamically limit for which functions to generate reports, see the
   `DebugFS interface`_ blacklist/whitelist feature.
 
-  For ``__always_inline`` functions, replace ``__always_inline`` with
-  ``__no_kcsan_or_inline`` (which implies ``__always_inline``)::
-
-    static __no_kcsan_or_inline void foo(void) {
-        ...
-
 * To disable data race detection for a particular compilation unit, add to the
   ``Makefile``::
 
--- a/include/linux/compiler_types.h
+++ b/include/linux/compiler_types.h
@@ -193,10 +193,7 @@ struct ftrace_likely_data {
 
 #define __no_kcsan __no_sanitize_thread
 #ifdef __SANITIZE_THREAD__
-# define __no_kcsan_or_inline __no_kcsan notrace __maybe_unused
-# define __no_sanitize_or_inline __no_kcsan_or_inline
-#else
-# define __no_kcsan_or_inline __always_inline
+# define __no_sanitize_or_inline __no_kcsan notrace __maybe_unused
 #endif
 
 #ifndef __no_sanitize_or_inline



^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 3/8] x86, kcsan: Add __no_kcsan to noinstr
  2020-06-04 10:22 [PATCH 0/8] x86/entry: KCSAN/KASAN/UBSAN vs noinstr Peter Zijlstra
  2020-06-04 10:22 ` [PATCH 1/8] x86, kcsan: Remove __no_kcsan_or_inline usage Peter Zijlstra
  2020-06-04 10:22 ` [PATCH 2/8] kcsan: Remove __no_kcsan_or_inline Peter Zijlstra
@ 2020-06-04 10:22 ` Peter Zijlstra
  2020-06-04 10:22 ` [PATCH 4/8] kasan: Bump required compiler version Peter Zijlstra
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 13+ messages in thread
From: Peter Zijlstra @ 2020-06-04 10:22 UTC (permalink / raw)
  To: tglx
  Cc: x86, elver, paulmck, kasan-dev, linux-kernel, peterz, will,
	dvyukov, glider, andreyknvl

The 'noinstr' function attribute means no-instrumentation, this should
very much include *SAN. Because lots of that is broken at present,
only include KCSAN for now, as that is limited to clang11, which has
sane function attribute behaviour.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
 include/linux/compiler_types.h |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

--- a/include/linux/compiler_types.h
+++ b/include/linux/compiler_types.h
@@ -118,10 +118,6 @@ struct ftrace_likely_data {
 #define notrace			__attribute__((__no_instrument_function__))
 #endif
 
-/* Section for code which can't be instrumented at all */
-#define noinstr								\
-	noinline notrace __attribute((__section__(".noinstr.text")))
-
 /*
  * it doesn't make sense on ARM (currently the only user of __naked)
  * to trace naked functions because then mcount is called without
@@ -200,6 +196,10 @@ struct ftrace_likely_data {
 #define __no_sanitize_or_inline __always_inline
 #endif
 
+/* Section for code which can't be instrumented at all */
+#define noinstr								\
+	noinline notrace __attribute((__section__(".noinstr.text"))) __no_kcsan
+
 #endif /* __KERNEL__ */
 
 #endif /* __ASSEMBLY__ */



^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 4/8] kasan: Bump required compiler version
  2020-06-04 10:22 [PATCH 0/8] x86/entry: KCSAN/KASAN/UBSAN vs noinstr Peter Zijlstra
                   ` (2 preceding siblings ...)
  2020-06-04 10:22 ` [PATCH 3/8] x86, kcsan: Add __no_kcsan to noinstr Peter Zijlstra
@ 2020-06-04 10:22 ` Peter Zijlstra
  2020-06-04 10:22 ` [PATCH 5/8] compiler_types.h: Add __no_sanitize_{address,undefined} to noinstr Peter Zijlstra
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 13+ messages in thread
From: Peter Zijlstra @ 2020-06-04 10:22 UTC (permalink / raw)
  To: tglx
  Cc: x86, elver, paulmck, kasan-dev, linux-kernel, peterz, will,
	dvyukov, glider, andreyknvl, Nick Desaulniers

From: Marco Elver <elver@google.com>

Adds config variable CC_HAS_WORKING_NOSANITIZE_ADDRESS, which will be
true if we have a compiler that does not fail builds due to
no_sanitize_address functions. This does not yet mean they work as
intended, but for automated build-tests, this is the minimum
requirement.

For example, we require that __always_inline functions used from
no_sanitize_address functions do not generate instrumentation. On GCC <=
7 this fails to build entirely, therefore we make the minimum version
GCC 8.

Suggested-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Marco Elver <elver@google.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Acked-by: Andrey Konovalov <andreyknvl@google.com>
Link: https://lkml.kernel.org/r/20200602175859.GC2604@hirez.programming.kicks-ass.net
---
Apply after:
https://lkml.kernel.org/r/20200602173103.931412766@infradead.org

v2:
* No longer restrict UBSAN (and KCSAN), since the attributes behave
  differently for different sanitizers. For UBSAN the above case with GCC
  <= 7 actually works fine (no compiler error). So it seems that only
  KASAN is affected by this -- let's limit our restriction to KASAN.
---
 lib/Kconfig.kasan |    4 ++++
 1 file changed, 4 insertions(+)

--- a/lib/Kconfig.kasan
+++ b/lib/Kconfig.kasan
@@ -15,11 +15,15 @@ config CC_HAS_KASAN_GENERIC
 config CC_HAS_KASAN_SW_TAGS
 	def_bool $(cc-option, -fsanitize=kernel-hwaddress)
 
+config CC_HAS_WORKING_NOSANITIZE_ADDRESS
+	def_bool !CC_IS_GCC || GCC_VERSION >= 80000
+
 config KASAN
 	bool "KASAN: runtime memory debugger"
 	depends on (HAVE_ARCH_KASAN && CC_HAS_KASAN_GENERIC) || \
 		   (HAVE_ARCH_KASAN_SW_TAGS && CC_HAS_KASAN_SW_TAGS)
 	depends on (SLUB && SYSFS) || (SLAB && !DEBUG_SLAB)
+	depends on CC_HAS_WORKING_NOSANITIZE_ADDRESS
 	help
 	  Enables KASAN (KernelAddressSANitizer) - runtime memory debugger,
 	  designed to find out-of-bounds accesses and use-after-free bugs.



^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 5/8] compiler_types.h: Add __no_sanitize_{address,undefined} to noinstr
  2020-06-04 10:22 [PATCH 0/8] x86/entry: KCSAN/KASAN/UBSAN vs noinstr Peter Zijlstra
                   ` (3 preceding siblings ...)
  2020-06-04 10:22 ` [PATCH 4/8] kasan: Bump required compiler version Peter Zijlstra
@ 2020-06-04 10:22 ` Peter Zijlstra
  2020-06-04 10:22 ` [PATCH 6/8] x86/entry, cpumask: Provide non-instrumented variant of cpu_is_offline() Peter Zijlstra
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 13+ messages in thread
From: Peter Zijlstra @ 2020-06-04 10:22 UTC (permalink / raw)
  To: tglx
  Cc: x86, elver, paulmck, kasan-dev, linux-kernel, peterz, will,
	dvyukov, glider, andreyknvl, syzbot+dc1fa714cb070b184db5,
	Miguel Ojeda

From: Marco Elver <elver@google.com>

Adds the portable definitions for __no_sanitize_address, and
__no_sanitize_undefined, and subsequently changes noinstr to use the
attributes to disable instrumentation via KASAN or UBSAN.

Reported-by: syzbot+dc1fa714cb070b184db5@syzkaller.appspotmail.com
Signed-off-by: Marco Elver <elver@google.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
Link: https://lore.kernel.org/lkml/000000000000d2474c05a6c938fe@google.com/
---

Note: __no_sanitize_coverage (for KCOV) isn't possible right now,
because neither GCC nor Clang support such an attribute. This means
going and changing the compilers again (for Clang it's fine, for GCC,
it'll take a while).

However, it looks like that KCOV_INSTRUMENT := n is currently in all the
right places. Short-term, this should be reasonable.

v2:
* No change.
---
 include/linux/compiler-clang.h | 8 ++++++++
 include/linux/compiler-gcc.h   | 6 ++++++
 include/linux/compiler_types.h | 3 ++-
 3 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/include/linux/compiler-clang.h b/include/linux/compiler-clang.h
index 2cb42d8bdedc..c0e4b193b311 100644
--- a/include/linux/compiler-clang.h
+++ b/include/linux/compiler-clang.h
@@ -33,6 +33,14 @@
 #define __no_sanitize_thread
 #endif
 
+#if __has_feature(undefined_behavior_sanitizer)
+/* GCC does not have __SANITIZE_UNDEFINED__ */
+#define __no_sanitize_undefined \
+		__attribute__((no_sanitize("undefined")))
+#else
+#define __no_sanitize_undefined
+#endif
+
 /*
  * Not all versions of clang implement the the type-generic versions
  * of the builtin overflow checkers. Fortunately, clang implements
diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h
index 7dd4e0349ef3..1c74464c80c6 100644
--- a/include/linux/compiler-gcc.h
+++ b/include/linux/compiler-gcc.h
@@ -150,6 +150,12 @@
 #define __no_sanitize_thread
 #endif
 
+#if __has_attribute(__no_sanitize_undefined__)
+#define __no_sanitize_undefined __attribute__((no_sanitize_undefined))
+#else
+#define __no_sanitize_undefined
+#endif
+
 #if GCC_VERSION >= 50100
 #define COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW 1
 #endif
diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h
index 02becd21d456..89b8c1ae18a1 100644
--- a/include/linux/compiler_types.h
+++ b/include/linux/compiler_types.h
@@ -198,7 +198,8 @@ struct ftrace_likely_data {
 
 /* Section for code which can't be instrumented at all */
 #define noinstr								\
-	noinline notrace __attribute((__section__(".noinstr.text"))) __no_kcsan
+	noinline notrace __attribute((__section__(".noinstr.text")))	\
+	__no_kcsan __no_sanitize_address __no_sanitize_undefined
 
 #endif /* __KERNEL__ */
 
-- 
2.27.0.rc2.251.g90737beb825-goog




^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 6/8] x86/entry, cpumask: Provide non-instrumented variant of cpu_is_offline()
  2020-06-04 10:22 [PATCH 0/8] x86/entry: KCSAN/KASAN/UBSAN vs noinstr Peter Zijlstra
                   ` (4 preceding siblings ...)
  2020-06-04 10:22 ` [PATCH 5/8] compiler_types.h: Add __no_sanitize_{address,undefined} to noinstr Peter Zijlstra
@ 2020-06-04 10:22 ` Peter Zijlstra
  2020-06-04 10:22 ` [PATCH 7/8] x86/entry, ubsan, objtool: Whitelist __ubsan_handle_*() Peter Zijlstra
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 13+ messages in thread
From: Peter Zijlstra @ 2020-06-04 10:22 UTC (permalink / raw)
  To: tglx
  Cc: x86, elver, paulmck, kasan-dev, linux-kernel, peterz, will,
	dvyukov, glider, andreyknvl

vmlinux.o: warning: objtool: exc_nmi()+0x12: call to cpumask_test_cpu.constprop.0() leaves .noinstr.text section
vmlinux.o: warning: objtool: mce_check_crashing_cpu()+0x12: call to cpumask_test_cpu.constprop.0()leaves .noinstr.text section

  cpumask_test_cpu()
    test_bit()
      instrument_atomic_read()
      arch_test_bit()

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
 arch/x86/include/asm/cpumask.h |   18 ++++++++++++++++++
 arch/x86/kernel/cpu/mce/core.c |    2 +-
 arch/x86/kernel/nmi.c          |    2 +-
 3 files changed, 20 insertions(+), 2 deletions(-)

--- a/arch/x86/include/asm/cpumask.h
+++ b/arch/x86/include/asm/cpumask.h
@@ -11,5 +11,23 @@ extern cpumask_var_t cpu_sibling_setup_m
 
 extern void setup_cpu_local_masks(void);
 
+/*
+ * NMI and MCE exceptions need cpu_is_offline() _really_ early,
+ * provide an arch_ special for them to avoid instrumentation.
+ */
+#if NR_CPUS > 1
+static __always_inline bool arch_cpu_online(int cpu)
+{
+	return arch_test_bit(cpu, cpumask_bits(cpu_online_mask));
+}
+#else
+static __always_inline bool arch_cpu_online(int cpu)
+{
+	return cpu == 0;
+}
+#endif
+
+#define arch_cpu_is_offline(cpu)	unlikely(!arch_cpu_online(cpu))
+
 #endif /* __ASSEMBLY__ */
 #endif /* _ASM_X86_CPUMASK_H */
--- a/arch/x86/kernel/cpu/mce/core.c
+++ b/arch/x86/kernel/cpu/mce/core.c
@@ -1083,7 +1083,7 @@ static noinstr bool mce_check_crashing_c
 {
 	unsigned int cpu = smp_processor_id();
 
-	if (cpu_is_offline(cpu) ||
+	if (arch_cpu_is_offline(cpu) ||
 	    (crashing_cpu != -1 && crashing_cpu != cpu)) {
 		u64 mcgstatus;
 
--- a/arch/x86/kernel/nmi.c
+++ b/arch/x86/kernel/nmi.c
@@ -478,7 +478,7 @@ static DEFINE_PER_CPU(unsigned long, nmi
 
 DEFINE_IDTENTRY_NMI(exc_nmi)
 {
-	if (IS_ENABLED(CONFIG_SMP) && cpu_is_offline(smp_processor_id()))
+	if (IS_ENABLED(CONFIG_SMP) && arch_cpu_is_offline(smp_processor_id()))
 		return;
 
 	if (this_cpu_read(nmi_state) != NMI_NOT_RUNNING) {



^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 7/8] x86/entry, ubsan, objtool: Whitelist __ubsan_handle_*()
  2020-06-04 10:22 [PATCH 0/8] x86/entry: KCSAN/KASAN/UBSAN vs noinstr Peter Zijlstra
                   ` (5 preceding siblings ...)
  2020-06-04 10:22 ` [PATCH 6/8] x86/entry, cpumask: Provide non-instrumented variant of cpu_is_offline() Peter Zijlstra
@ 2020-06-04 10:22 ` Peter Zijlstra
  2020-06-04 10:22 ` [PATCH 8/8] x86/entry, bug: Comment the instrumentation_begin() usage for WARN() Peter Zijlstra
  2020-06-04 11:01 ` [PATCH 0/8] x86/entry: KCSAN/KASAN/UBSAN vs noinstr Marco Elver
  8 siblings, 0 replies; 13+ messages in thread
From: Peter Zijlstra @ 2020-06-04 10:22 UTC (permalink / raw)
  To: tglx
  Cc: x86, elver, paulmck, kasan-dev, linux-kernel, peterz, will,
	dvyukov, glider, andreyknvl

The UBSAN instrumentation only inserts external CALLs when things go
'BAD', much like WARN(). So treat them similar to WARN()s for noinstr,
that is: allow them, at the risk of taking the machine down, to get
their message out.

Suggested-by: Marco Elver <elver@google.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Marco Elver <elver@google.com>
---
 include/linux/compiler_types.h |    2 +-
 tools/objtool/check.c          |   28 +++++++++++++++++++++++++++-
 2 files changed, 28 insertions(+), 2 deletions(-)

--- a/include/linux/compiler_types.h
+++ b/include/linux/compiler_types.h
@@ -199,7 +199,7 @@ struct ftrace_likely_data {
 /* Section for code which can't be instrumented at all */
 #define noinstr								\
 	noinline notrace __attribute((__section__(".noinstr.text")))	\
-	__no_kcsan __no_sanitize_address __no_sanitize_undefined
+	__no_kcsan __no_sanitize_address
 
 #endif /* __KERNEL__ */
 
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -2190,10 +2190,36 @@ static inline const char *call_dest_name
 	return "{dynamic}";
 }
 
+static inline bool noinstr_call_dest(struct symbol *func)
+{
+	/*
+	 * We can't deal with indirect function calls at present;
+	 * assume they're instrumented.
+	 */
+	if (!func)
+		return false;
+
+	/*
+	 * If the symbol is from a noinstr section; we good.
+	 */
+	if (func->sec->noinstr)
+		return true;
+
+	/*
+	 * The __ubsan_handle_*() calls are like WARN(), they only happen when
+	 * something 'BAD' happened. At the risk of taking the machine down,
+	 * let them proceed to get the message out.
+	 */
+	if (!strncmp(func->name, "__ubsan_handle_", 15))
+		return true;
+
+	return false;
+}
+
 static int validate_call(struct instruction *insn, struct insn_state *state)
 {
 	if (state->noinstr && state->instr <= 0 &&
-	    (!insn->call_dest || !insn->call_dest->sec->noinstr)) {
+	    !noinstr_call_dest(insn->call_dest)) {
 		WARN_FUNC("call to %s() leaves .noinstr.text section",
 				insn->sec, insn->offset, call_dest_name(insn));
 		return 1;



^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 8/8] x86/entry, bug: Comment the instrumentation_begin() usage for WARN()
  2020-06-04 10:22 [PATCH 0/8] x86/entry: KCSAN/KASAN/UBSAN vs noinstr Peter Zijlstra
                   ` (6 preceding siblings ...)
  2020-06-04 10:22 ` [PATCH 7/8] x86/entry, ubsan, objtool: Whitelist __ubsan_handle_*() Peter Zijlstra
@ 2020-06-04 10:22 ` Peter Zijlstra
  2020-06-04 11:01 ` [PATCH 0/8] x86/entry: KCSAN/KASAN/UBSAN vs noinstr Marco Elver
  8 siblings, 0 replies; 13+ messages in thread
From: Peter Zijlstra @ 2020-06-04 10:22 UTC (permalink / raw)
  To: tglx
  Cc: x86, elver, paulmck, kasan-dev, linux-kernel, peterz, will,
	dvyukov, glider, andreyknvl

Explain the rationale for annotating WARN(), even though, strictly
speaking printk() and friends are very much not safe in many of the
places we put them.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
 arch/x86/include/asm/bug.h |    6 ++++++
 1 file changed, 6 insertions(+)

--- a/arch/x86/include/asm/bug.h
+++ b/arch/x86/include/asm/bug.h
@@ -76,6 +76,12 @@ do {								\
 	unreachable();						\
 } while (0)
 
+/*
+ * This instrumentation_begin() is strictly speaking incorrect; but it
+ * suppresses the complaints from WARN()s in noinstr code. If such a WARN()
+ * were to trigger, we'd rather wreck the machine in an attempt to get the
+ * message out than not know about it.
+ */
 #define __WARN_FLAGS(flags)					\
 do {								\
 	instrumentation_begin();				\



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 0/8] x86/entry: KCSAN/KASAN/UBSAN vs noinstr
  2020-06-04 10:22 [PATCH 0/8] x86/entry: KCSAN/KASAN/UBSAN vs noinstr Peter Zijlstra
                   ` (7 preceding siblings ...)
  2020-06-04 10:22 ` [PATCH 8/8] x86/entry, bug: Comment the instrumentation_begin() usage for WARN() Peter Zijlstra
@ 2020-06-04 11:01 ` Marco Elver
  2020-06-15 10:07   ` Marco Elver
  8 siblings, 1 reply; 13+ messages in thread
From: Marco Elver @ 2020-06-04 11:01 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: Thomas Gleixner, the arch/x86 maintainers, Paul E. McKenney,
	kasan-dev, LKML, Will Deacon, Dmitry Vyukov, Alexander Potapenko,
	Andrey Konovalov

On Thu, 4 Jun 2020 at 12:25, Peter Zijlstra <peterz@infradead.org> wrote:
>
> Hai,
>
> Here's the remaining few patches to make KCSAN/KASAN and UBSAN work with noinstr.

Thanks for assembling the series!

For where it's missing (1,2,3 and last one):

Acked-by: Marco Elver <elver@google.com>

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 0/8] x86/entry: KCSAN/KASAN/UBSAN vs noinstr
  2020-06-04 11:01 ` [PATCH 0/8] x86/entry: KCSAN/KASAN/UBSAN vs noinstr Marco Elver
@ 2020-06-15 10:07   ` Marco Elver
  2020-06-15 14:57     ` Qian Cai
  0 siblings, 1 reply; 13+ messages in thread
From: Marco Elver @ 2020-06-15 10:07 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: Thomas Gleixner, the arch/x86 maintainers, Paul E. McKenney,
	kasan-dev, LKML, Will Deacon, Dmitry Vyukov, Alexander Potapenko,
	Andrey Konovalov

On Thu, 4 Jun 2020 at 13:01, Marco Elver <elver@google.com> wrote:
>
> On Thu, 4 Jun 2020 at 12:25, Peter Zijlstra <peterz@infradead.org> wrote:
> >
> > Hai,
> >
> > Here's the remaining few patches to make KCSAN/KASAN and UBSAN work with noinstr.
>
> Thanks for assembling the series!
>
> For where it's missing (1,2,3 and last one):
>
> Acked-by: Marco Elver <elver@google.com>

Where was this series supposed to go? I can't find it on any tree yet.

How urgent is this? Boot-test seems fine without this, but likely
doesn't hit the corner cases. Syzbot will likely find them, and if we
noticeably end up breaking various sanitizers without this, I'd
consider this urgent.

Thanks,
-- Marco

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 0/8] x86/entry: KCSAN/KASAN/UBSAN vs noinstr
  2020-06-15 10:07   ` Marco Elver
@ 2020-06-15 14:57     ` Qian Cai
  2020-06-15 15:06       ` Peter Zijlstra
  0 siblings, 1 reply; 13+ messages in thread
From: Qian Cai @ 2020-06-15 14:57 UTC (permalink / raw)
  To: Marco Elver
  Cc: Peter Zijlstra, Thomas Gleixner, the arch/x86 maintainers,
	Paul E. McKenney, kasan-dev, LKML, Will Deacon, Dmitry Vyukov,
	Alexander Potapenko, Andrey Konovalov

On Mon, Jun 15, 2020 at 12:07:34PM +0200, 'Marco Elver' via kasan-dev wrote:
> On Thu, 4 Jun 2020 at 13:01, Marco Elver <elver@google.com> wrote:
> >
> > On Thu, 4 Jun 2020 at 12:25, Peter Zijlstra <peterz@infradead.org> wrote:
> > >
> > > Hai,
> > >
> > > Here's the remaining few patches to make KCSAN/KASAN and UBSAN work with noinstr.
> >
> > Thanks for assembling the series!
> >
> > For where it's missing (1,2,3 and last one):
> >
> > Acked-by: Marco Elver <elver@google.com>
> 
> Where was this series supposed to go? I can't find it on any tree yet.
> 
> How urgent is this? Boot-test seems fine without this, but likely
> doesn't hit the corner cases. Syzbot will likely find them, and if we
> noticeably end up breaking various sanitizers without this, I'd
> consider this urgent.

Today's linux-next had a lot of those with this .config,

https://raw.githubusercontent.com/cailca/linux-mm/master/x86.config

Wondering if this patchset will cure them all?

vmlinux.o: warning: objtool: exc_invalid_op()+0x337: call to __asan_report_load8_noabort() leaves .noinstr.text section
vmlinux.o: warning: objtool: exc_double_fault()+0x217: call to __asan_report_store4_noabort() leaves .noinstr.text section
vmlinux.o: warning: objtool: exc_int3()+0x376: call to __asan_report_load8_noabort() leaves .noinstr.text section
vmlinux.o: warning: objtool: sync_regs()+0xcd: call to __asan_report_store_n_noabort() leaves .noinstr.text section
vmlinux.o: warning: objtool: fixup_bad_iret()+0x13a: call to __asan_report_load8_noabort() leaves .noinstr.text section
vmlinux.o: warning: objtool: exc_debug()+0x280: call to __asan_report_load4_noabort() leaves .noinstr.text section
vmlinux.o: warning: objtool: default_do_nmi()+0x233: call to __asan_report_load8_noabort() leaves .noinstr.text section
vmlinux.o: warning: objtool: exc_nmi()+0x67: call to __kasan_check_read() leaves .noinstr.text section
vmlinux.o: warning: objtool: poke_int3_handler()+0x3d1: call to __asan_report_load8_noabort() leaves .noinstr.text section
vmlinux.o: warning: objtool: mce_check_crashing_cpu()+0x60: call to __kasan_check_read() leaves .noinstr.text section
vmlinux.o: warning: objtool: mce_setup()+0x1c: call to memset() leaves .noinstr.text section
vmlinux.o: warning: objtool: do_machine_check()+0xd3: call to mce_rdmsrl() leaves .noinstr.text section
vmlinux.o: warning: objtool: exc_machine_check()+0x2a1: call to __asan_report_store4_noabort() leaves .noinstr.text section
vmlinux.o: warning: objtool: exc_page_fault()+0xc4e: call to __asan_report_load8_noabort() leaves .noinstr.text section
vmlinux.o: warning: objtool: lockdep_hardirqs_on()+0x3a9: call to __asan_report_store8_noabort() leaves .noinstr.text section
vmlinux.o: warning: objtool: lockdep_hardirqs_off()+0x24a: call to __asan_report_store8_noabort() leaves .noinstr.text section
vmlinux.o: warning: objtool: match_held_lock()+0x4df: call to __asan_report_load8_noabort() leaves .noinstr.text section
vmlinux.o: warning: objtool: lock_is_held_type()+0x230: call to __asan_report_store4_noabort() leaves .noinstr.text section
vmlinux.o: warning: objtool: debug_lockdep_rcu_enabled()+0xcd: call to __asan_report_load4_noabort() leaves .noinstr.text section
vmlinux.o: warning: objtool: rcu_dynticks_eqs_enter()+0x1c: call to __kasan_check_write() leaves .noinstr.text section
vmlinux.o: warning: objtool: rcu_dynticks_eqs_exit()+0x20: call to __kasan_check_write() leaves .noinstr.text section
vmlinux.o: warning: objtool: rcu_eqs_exit.constprop.72()+0x24d: call to __asan_report_load8_noabort() leaves .noinstr.text section
vmlinux.o: warning: objtool: rcu_eqs_enter.constprop.73()+0x250: call to __asan_report_load8_noabort() leaves .noinstr.text section
vmlinux.o: warning: objtool: rcu_nmi_exit()+0x1f2: call to __asan_report_load8_noabort() leaves .noinstr.text section
vmlinux.o: warning: objtool: rcu_irq_exit()+0xd1: call to __ubsan_handle_load_invalid_value() leaves .noinstr.text section
vmlinux.o: warning: objtool: rcu_nmi_enter()+0x184: call to __asan_report_load8_noabort() leaves .noinstr.text section
vmlinux.o: warning: objtool: rcu_irq_enter()+0xd1: call to __ubsan_handle_load_invalid_value() leaves .noinstr.text section
vmlinux.o: warning: objtool: __rcu_is_watching()+0x20: call to __kasan_check_read() leaves .noinstr.text section
vmlinux.o: warning: objtool: debug_locks_off()+0x19: call to __kasan_check_write() leaves .noinstr.text section

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 0/8] x86/entry: KCSAN/KASAN/UBSAN vs noinstr
  2020-06-15 14:57     ` Qian Cai
@ 2020-06-15 15:06       ` Peter Zijlstra
  0 siblings, 0 replies; 13+ messages in thread
From: Peter Zijlstra @ 2020-06-15 15:06 UTC (permalink / raw)
  To: Qian Cai
  Cc: Marco Elver, Thomas Gleixner, the arch/x86 maintainers,
	Paul E. McKenney, kasan-dev, LKML, Will Deacon, Dmitry Vyukov,
	Alexander Potapenko, Andrey Konovalov

On Mon, Jun 15, 2020 at 10:57:18AM -0400, Qian Cai wrote:
> On Mon, Jun 15, 2020 at 12:07:34PM +0200, 'Marco Elver' via kasan-dev wrote:
> > On Thu, 4 Jun 2020 at 13:01, Marco Elver <elver@google.com> wrote:
> > >
> > > On Thu, 4 Jun 2020 at 12:25, Peter Zijlstra <peterz@infradead.org> wrote:
> > > >
> > > > Hai,
> > > >
> > > > Here's the remaining few patches to make KCSAN/KASAN and UBSAN work with noinstr.
> > >
> > > Thanks for assembling the series!
> > >
> > > For where it's missing (1,2,3 and last one):
> > >
> > > Acked-by: Marco Elver <elver@google.com>
> > 
> > Where was this series supposed to go? I can't find it on any tree yet.
> > 
> > How urgent is this? Boot-test seems fine without this, but likely
> > doesn't hit the corner cases. Syzbot will likely find them, and if we
> > noticeably end up breaking various sanitizers without this, I'd
> > consider this urgent.
> 
> Today's linux-next had a lot of those with this .config,
> 
> https://raw.githubusercontent.com/cailca/linux-mm/master/x86.config
> 
> Wondering if this patchset will cure them all?

Many, not all, you also need:

  https://lkml.kernel.org/r/20200603114051.896465666@infradead.org

and then I think you're down to only 1 kasan thing. But also read this
thread:

  https://lkml.kernel.org/r/20200611215812.GF4496@worktop.programming.kicks-ass.net

latest version of that actual patch here:

  https://lkml.kernel.org/r/20200612143034.933422660@infradead.org


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2020-06-15 15:06 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-04 10:22 [PATCH 0/8] x86/entry: KCSAN/KASAN/UBSAN vs noinstr Peter Zijlstra
2020-06-04 10:22 ` [PATCH 1/8] x86, kcsan: Remove __no_kcsan_or_inline usage Peter Zijlstra
2020-06-04 10:22 ` [PATCH 2/8] kcsan: Remove __no_kcsan_or_inline Peter Zijlstra
2020-06-04 10:22 ` [PATCH 3/8] x86, kcsan: Add __no_kcsan to noinstr Peter Zijlstra
2020-06-04 10:22 ` [PATCH 4/8] kasan: Bump required compiler version Peter Zijlstra
2020-06-04 10:22 ` [PATCH 5/8] compiler_types.h: Add __no_sanitize_{address,undefined} to noinstr Peter Zijlstra
2020-06-04 10:22 ` [PATCH 6/8] x86/entry, cpumask: Provide non-instrumented variant of cpu_is_offline() Peter Zijlstra
2020-06-04 10:22 ` [PATCH 7/8] x86/entry, ubsan, objtool: Whitelist __ubsan_handle_*() Peter Zijlstra
2020-06-04 10:22 ` [PATCH 8/8] x86/entry, bug: Comment the instrumentation_begin() usage for WARN() Peter Zijlstra
2020-06-04 11:01 ` [PATCH 0/8] x86/entry: KCSAN/KASAN/UBSAN vs noinstr Marco Elver
2020-06-15 10:07   ` Marco Elver
2020-06-15 14:57     ` Qian Cai
2020-06-15 15:06       ` Peter Zijlstra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).