Re: [PATCH v5 00/18] Rework READ_ONCE() to improve codegen

2020-05-12 Thread Marco Elver
On Tue, 12 May 2020 at 10:18, Peter Zijlstra wrote: > > On Mon, May 11, 2020 at 09:41:32PM +0100, Will Deacon wrote: > > Hi folks, > > > > (trimmed CC list since v4 since this is largely just a rebase) > > > > This is version five of the READ_ONCE() codegen improvement series that > > I've

[PATCH] READ_ONCE, WRITE_ONCE, kcsan: Perform checks in __*_ONCE variants

2020-05-12 Thread Marco Elver
Signed-off-by: Marco Elver --- A proposal to fix the problem with __READ_ONCE/__WRITE_ONCE and KCSAN false positives. Will, please feel free to take this patch and fiddle with it until it looks like what you want if this is completely off. Note: Currently __WRITE_ONCE_SCALAR seems to serve

Re: [PATCH v5 00/18] Rework READ_ONCE() to improve codegen

2020-05-12 Thread Marco Elver
On Tue, 12 May 2020 at 19:53, Marco Elver wrote: > > On Tue, 12 May 2020 at 10:18, Peter Zijlstra wrote: > > > > On Mon, May 11, 2020 at 09:41:32PM +0100, Will Deacon wrote: > > > Hi folks, > > > > > > (trimmed CC list since v4 since this is large

Re: [PATCH v5 00/18] Rework READ_ONCE() to improve codegen

2020-05-12 Thread Marco Elver
On Tue, 12 May 2020 at 21:08, Peter Zijlstra wrote: > > On Tue, May 12, 2020 at 07:53:00PM +0200, Marco Elver wrote: > > I just ran a bunch of KCSAN tests. While this series alone would have > > passed the tests, there appears to be a problem with > > __READ_ONCE/__WRITE_O

Re: [PATCH v5 00/18] Rework READ_ONCE() to improve codegen

2020-05-12 Thread Marco Elver
On Tue, 12 May 2020 at 23:15, Will Deacon wrote: > > On Tue, May 12, 2020 at 09:07:55PM +0200, Peter Zijlstra wrote: > > On Tue, May 12, 2020 at 07:53:00PM +0200, Marco Elver wrote: > > > I just ran a bunch of KCSAN tests. While this series alone would have > > > p

Re: [PATCH] [v2] ubsan, kcsan: don't combine sanitizer with kcov on clang

2020-05-07 Thread Marco Elver
. > > Let's wait for replies on that bug report before this gets applied, > in case the feedback there changes the conclusion. Waiting makes sense, if this is not very urgent. Acked-by: Marco Elver Thank you! > --- > lib/Kconfig.kcsan | 11 +++ > lib/Kconfig.ubsan |

Re: [rcu] 2f08469563: BUG:kernel_reboot-without-warning_in_boot_stage

2020-05-18 Thread Marco Elver
table checksum verification disabled > > BUG: kernel reboot-without-warning in boot stage > > I am having some difficulty believing that this commit is at fault given > that the .config does not list CONFIG_KCSAN=y, but CCing Marco Elver > for his thoughts. Especially given that I have

Re: [rcu] 2f08469563: BUG:kernel_reboot-without-warning_in_boot_stage

2020-05-18 Thread Marco Elver
[+Cc clang-built-linux FYI] On Mon, 18 May 2020 at 12:11, Marco Elver wrote: > > On Sun, 17 May 2020 at 05:47, Paul E. McKenney wrote: > > > > On Sun, May 17, 2020 at 09:17:32AM +0800, kernel test robot wrote: > > > Greeting, > > > > > > FYI, we noti

Re: [rcu] 2f08469563: BUG:kernel_reboot-without-warning_in_boot_stage

2020-05-18 Thread Marco Elver
On Mon, 18 May 2020 at 14:44, Marco Elver wrote: > > [+Cc clang-built-linux FYI] > > On Mon, 18 May 2020 at 12:11, Marco Elver wrote: > > > > On Sun, 17 May 2020 at 05:47, Paul E. McKenney wrote: > > > > > > On Sun, May 17, 2020 at 09:17:32AM +0800,

Re: [rcu] 2f08469563: BUG:kernel_reboot-without-warning_in_boot_stage

2020-05-18 Thread Marco Elver
On Mon, 18 May 2020, 'Nick Desaulniers' via kasan-dev wrote: > On Mon, May 18, 2020 at 7:34 AM Marco Elver wrote: > > > > On Mon, 18 May 2020 at 14:44, Marco Elver wrote: > > > > > > [+Cc clang-built-linux FYI] > > > > > > On Mon, 18 May 2020 a

Re: [PATCH v3 4/9] x86/build: Warn on orphan section placement

2020-06-29 Thread Marco Elver
t_array.0) is > > being placed in '.init_array.0' > > As far as I can tell, this is a Clang bug. But I don't know the > internals here, so I've opened: > https://bugs.llvm.org/show_bug.cgi?id=46478 > > and created a work-around patch for the kernel: Thanks, minor comments below

[PATCH 2/2] kasan: Update required compiler versions in documentation

2020-06-29 Thread Marco Elver
r version") Signed-off-by: Marco Elver --- Documentation/dev-tools/kasan.rst | 7 ++- lib/Kconfig.kasan | 24 +++- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/Documentation/dev-tools/kasan.rst b/Documentation/dev-tools/kasan

[PATCH 1/2] kasan: Improve and simplify Kconfig.kasan

2020-06-29 Thread Marco Elver
Turn 'KASAN' into a menuconfig, to avoid cluttering its parent menu with the suboptions if enabled. Use 'if KASAN ... endif' instead of having to 'depend on KASAN' for each entry. Signed-off-by: Marco Elver --- lib/Kconfig.kasan | 15 --- 1 file changed, 8 insertions(+), 7 deletions

Re: [PATCH v5 00/18] Rework READ_ONCE() to improve codegen

2020-06-09 Thread Marco Elver
On Tue, 9 Jun 2020 at 14:36, Martin Liška wrote: > > On 6/9/20 1:55 PM, Martin Liška wrote: > > Works for me and I've just sent patch for that: > > https://gcc.gnu.org/pipermail/gcc-patches/2020-June/547618.html > > The patch has landed into master. Great, thank you for turning this around so

[PATCH 1/3] kcsan: Add support for atomic builtins

2020-07-03 Thread Marco Elver
builtins with a call into the runtime, and the runtime's job is to also execute the desired atomic operation. We rely on the __atomic_* compiler builtins, available with all KCSAN-supported compilers, to implement each TSAN atomic instrumentation function. Signed-off-by: Marco Elver --- kernel

[PATCH 3/3] kcsan: Add atomic builtin test case

2020-07-03 Thread Marco Elver
Adds test case to kcsan-test module, to test atomic builtin instrumentation works. Signed-off-by: Marco Elver --- kernel/kcsan/kcsan-test.c | 63 +++ 1 file changed, 63 insertions(+) diff --git a/kernel/kcsan/kcsan-test.c b/kernel/kcsan/kcsan-test.c index

[PATCH 2/3] objtool: Add atomic builtin TSAN instrumentation to uaccess whitelist

2020-07-03 Thread Marco Elver
Adds the new TSAN functions that may be emitted for atomic builtins to objtool's uaccess whitelist. Signed-off-by: Marco Elver --- tools/objtool/check.c | 50 +++ 1 file changed, 50 insertions(+) diff --git a/tools/objtool/check.c b/tools/objtool/check.c

Re: [PATCH 18/18] arm64: lto: Strengthen READ_ONCE() to acquire when CLANG_LTO=y

2020-07-08 Thread Marco Elver
On Wed, 8 Jul 2020 at 01:01, Nick Desaulniers wrote: > > I'm trying to put together a Micro Conference for Linux Plumbers > conference focused on "make LLVM slightly less shitty." Do you all > plan on attending the conference? Would it be worthwhile to hold a > session focused on discussing this

Re: [PATCH 00/22] add support for Clang LTO

2020-06-30 Thread Marco Elver
I was asked for input on this, and after a few days digging through some history, thought I'd comment. Hope you don't mind. On Thu, Jun 25, 2020 at 10:57AM +0200, Peter Zijlstra wrote: > On Thu, Jun 25, 2020 at 10:24:33AM +0200, Peter Zijlstra wrote: > > On Thu, Jun 25, 2020 at 10:03:13AM +0200,

Re: [PATCH 18/18] arm64: lto: Strengthen READ_ONCE() to acquire when CLANG_LTO=y

2020-06-30 Thread Marco Elver
On Tue, 30 Jun 2020 at 19:39, Will Deacon wrote: > > When building with LTO, there is an increased risk of the compiler > converting an address dependency headed by a READ_ONCE() invocation > into a control dependency and consequently allowing for harmful > reordering by the CPU. > > Ensure that

Re: linux-next: manual merge of the rcu tree with the kbuild tree

2020-06-30 Thread Marco Elver
On Wed, 1 Jul 2020 at 03:34, Stephen Rothwell wrote: > > Hi all, > > Today's linux-next merge of the rcu tree got a conflict in: > > kernel/kcsan/Makefile > > between commit: > > f7c28e224da6 ("kbuild: remove cc-option test of -fno-stack-protector") Is it possible that this patch drops the

Re: [PATCH 1/2] kbuild: remove cc-option test of -fno-stack-protector

2020-07-01 Thread Marco Elver
On Sat, Jun 27, 2020 at 03:59AM +0900, Masahiro Yamada wrote: > Some Makefiles already pass -fno-stack-protector unconditionally. > For example, arch/arm64/kernel/vdso/Makefile, arch/x86/xen/Makefile. > No problem report so far about hard-coding this option. So, we can > assume all supported

Re: [PATCH 00/22] add support for Clang LTO

2020-07-01 Thread Marco Elver
On Tue, 30 Jun 2020 at 22:30, Paul E. McKenney wrote: > On Tue, Jun 30, 2020 at 10:12:43PM +0200, Peter Zijlstra wrote: > > On Tue, Jun 30, 2020 at 09:19:31PM +0200, Marco Elver wrote: > > > First of all, I agree with the concerns, but not because of LTO. > > > &g

Re: [PATCH 18/18] arm64: lto: Strengthen READ_ONCE() to acquire when CLANG_LTO=y

2020-07-06 Thread Marco Elver
On Mon, 6 Jul 2020 at 20:35, Will Deacon wrote: > On Mon, Jul 06, 2020 at 05:00:23PM +0100, Dave Martin wrote: > > On Thu, Jul 02, 2020 at 08:23:02AM +0100, Will Deacon wrote: > > > On Wed, Jul 01, 2020 at 06:07:25PM +0100, Dave P Martin wrote: > > > > Also, can you illustrate code that can only

[PATCH 3/3] kcsan: Disable branch tracing in core runtime

2020-06-18 Thread Marco Elver
/lkml/CANpmjNOeXmD5E3O50Z3MjkiuCYaYOPyi+1rq=gzvekwbvlr...@mail.gmail.com/ Signed-off-by: Marco Elver --- kernel/kcsan/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/kcsan/Makefile b/kernel/kcsan/Makefile index fea064afc4f7..65ca5539c470 100644 --- a/kernel/kcsan

[PATCH 2/3] kcsan: Simplify compiler flags

2020-06-18 Thread Marco Elver
Simplify the set of compiler flags for the runtime by removing cc-option from -fno-stack-protector, because all supported compilers support it. This saves us one compiler invocation during build. Signed-off-by: Marco Elver --- kernel/kcsan/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2

[PATCH 1/3] kcsan: Re-add GCC as a supported compiler

2020-06-18 Thread Marco Elver
-by: Marco Elver Cc: Martin Liska --- For anyone interested to try it out before GCC 11 is released, I'd recommend building a stable GCC 10 with the patches applied: git clone git://gcc.gnu.org/git/gcc.git && cd gcc git checkout -b gcc-10-for-kcsan releases/gcc-10.1.0 gi

[PATCH 0/3] kcsan: Re-add GCC support, and compiler flags improvements

2020-06-18 Thread Marco Elver
j$(nproc) && make install Marco Elver (3): kcsan: Re-add GCC as a supported compiler kcsan: Simplify compiler flags kcsan: Disable branch tracing in core runtime Documentation/dev-tools/kcsan.rst | 3 ++- kernel/kcsan/Makefile | 4 ++-- lib/Kconfig.kcsan

Re: [PATCH 4/7] x86/entry: Increase entry_stack size to a full page

2020-06-18 Thread Marco Elver
On Thu, 18 Jun 2020 at 16:50, Peter Zijlstra wrote: > > Marco crashed in bad_iret with a Clang11/KCSAN build due to > overflowing the stack. Now that we run C code on it, expand it to a > full page. > > Suggested-by: Andy Lutomirski > Reported-by: Marco Elver > Signe

Re: [PATCH 3/7] x86/entry: Fixup bad_iret vs noinstr

2020-06-18 Thread Marco Elver
bly implementation. > > Reported-by: Marco Elver > Suggested-by: Marco Elver > Signed-off-by: Peter Zijlstra (Intel) KASAN no longer crashes, although the stack size increase appears to be sufficient for the particular case I ran into. Tested-by: Marco Elver Thanks! > --- &

Re: linux-next build error (9)

2020-06-22 Thread Marco Elver
On Mon, 22 Jun 2020 at 11:49, Peter Zijlstra wrote: > > On Mon, Jun 22, 2020 at 02:37:12AM -0700, syzbot wrote: > > Hello, > > > > syzbot found the following crash on: > > > > HEAD commit:27f11fea Add linux-next specific files for 20200622 > > git tree: linux-next > > console output:

Re: linux-next build error (9)

2020-06-22 Thread Marco Elver
On Mon, 22 Jun 2020 at 13:06, Marco Elver wrote: > > On Mon, 22 Jun 2020 at 11:49, Peter Zijlstra wrote: > > > > On Mon, Jun 22, 2020 at 02:37:12AM -0700, syzbot wrote: > > > Hello, > > > > > > syzbot found the following crash on: > > >

Re: [PATCH] sparse: use the _Generic() version of __unqual_scalar_typeof()

2020-06-19 Thread Marco Elver
gt; b398ace5d2ea ("compiler_types.h: Use unoptimized __unqual_scalar_typeof for > sparse") > > Note: a recent version of sparse will be needed (minimum v0.6.2-rc2 >or later than 2020-05-28). > > Cc: Marco Elver > Cc: Borislav Petkov > Cc: Will Deacon >

Re: [PATCH] kcsan: Improve small stylistic detail in compiler-clang.h

2020-06-19 Thread Marco Elver
On Fri, Jun 19, 2020 at 02:57PM +0200, Sedat Dilek wrote: > Commit 5cbaefe9743bf14c9d3106db0cc19f8cb0a3ca22 > ("kcsan: Improve various small stylistic details") > > ...forgot to improve a stylistic detail that was already done at > another place in compiler-clang.h file. > > Fixes: 5cbaefe9743b

Re: [PATCH -tip v3 1/2] kcov: Make runtime functions noinstr-compatible

2020-06-12 Thread Marco Elver
On Fri, 12 Jun 2020, Dmitry Vyukov wrote: > On Thu, Jun 11, 2020 at 11:55 PM Peter Zijlstra wrote: > > > > On Mon, Jun 08, 2020 at 01:01:08PM +0200, Peter Zijlstra wrote: > > > On Mon, Jun 08, 2020 at 09:57:39AM +0200, Dmitry Vyukov wrote: > > > > > > > As a crazy idea: is it possible to

Re: [tip: locking/kcsan] READ_ONCE: Use data_race() to avoid KCSAN instrumentation

2020-05-20 Thread Marco Elver
11:04:17 +02:00 > > > > READ_ONCE: Use data_race() to avoid KCSAN instrumentation > > > > Rather then open-code the disabling/enabling of KCSAN across the guts of > > {READ,WRITE}_ONCE(), defer to the data_race() macro instead. > > > > Signed-off-by: Will Dea

Re: [tip: locking/kcsan] READ_ONCE: Use data_race() to avoid KCSAN instrumentation

2020-05-21 Thread Marco Elver
On Thu, 21 May 2020 at 09:26, Borislav Petkov wrote: > > On Thu, May 21, 2020 at 12:30:39AM +0200, Marco Elver wrote: > > This should be fixed when the series that includes this commit is applied: > > https://lore.kernel.org/lkml/20200515150338.190344-9-el...@google.com/ &

Re: [PATCH -tip 08/10] READ_ONCE, WRITE_ONCE: Remove data_race() wrapping

2020-05-21 Thread Marco Elver
On Fri, 15 May 2020 at 17:04, Marco Elver wrote: > > The volatile access no longer needs to be wrapped in data_race(), > because we require compilers that emit instrumentation distinguishing > volatile accesses. > > Signed-off-by: Marco Elver > --- > include/linux/compi

Re: [PATCH -tip 08/10] READ_ONCE, WRITE_ONCE: Remove data_race() wrapping

2020-05-21 Thread Marco Elver
On Thu, 21 May 2020 at 11:47, Marco Elver wrote: > > On Fri, 15 May 2020 at 17:04, Marco Elver wrote: > > > > The volatile access no longer needs to be wrapped in data_race(), > > because we require compilers that emit instrumentation distinguishing > > volatil

[PATCH -tip v2 00/11] Fix KCSAN for new ONCE (require Clang 11)

2020-05-21 Thread Marco Elver
expression in response to apparent issues that compilers are having with nested statement expressions. Arnd Bergmann (1): ubsan, kcsan: don't combine sanitizer with kcov on clang Marco Elver (10): kcsan: Avoid inserting __tsan_func_entry/exit if possible kcsan: Support distinguishing volatil

[PATCH -tip v2 01/11] ubsan, kcsan: don't combine sanitizer with kcov on clang

2020-05-21 Thread Marco Elver
/20200505142341.1096942-1-a...@arndb.de Acked-by: Marco Elver Signed-off-by: Arnd Bergmann Signed-off-by: Marco Elver --- This patch is already in -rcu tree, but since since the series is based on -tip, to avoid conflict it is required for the subsequent patches. --- lib/Kconfig.kcsan | 11 +++ lib

[PATCH -tip v2 05/11] kcsan: Remove 'noinline' from __no_kcsan_or_inline

2020-05-21 Thread Marco Elver
-by: Marco Elver --- include/linux/compiler.h | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/include/linux/compiler.h b/include/linux/compiler.h index e24cc3a2bc3e..17c98b215572 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h @@ -276,11 +276,9 @@ do

[PATCH -tip v2 03/11] kcsan: Support distinguishing volatile accesses

2020-05-21 Thread Marco Elver
). [1] https://github.com/llvm/llvm-project/commit/5a2c31116f412c3b6888be361137efd705e05814 [2] https://gcc.gnu.org/pipermail/gcc-patches/2020-April/544452.html This patch allows removing any explicit checks in primitives such as READ_ONCE() and WRITE_ONCE(). Signed-off-by: Marco Elver --- v2

[PATCH -tip v2 09/11] data_race: Avoid nested statement expression

2020-05-21 Thread Marco Elver
-off-by: Marco Elver --- v2: * Add patch to series in response to above linked discussion. --- include/linux/compiler.h | 9 - 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/include/linux/compiler.h b/include/linux/compiler.h index 7444f026eead..1f9bd9f35368 100644

[PATCH -tip v2 04/11] kcsan: Pass option tsan-instrument-read-before-write to Clang

2020-05-21 Thread Marco Elver
Signed-off-by: Marco Elver --- scripts/Makefile.kcsan | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/Makefile.kcsan b/scripts/Makefile.kcsan index 75d2942b9437..bd4da1af5953 100644 --- a/scripts/Makefile.kcsan +++ b/scripts/Makefile.kcsan @@ -13,6 +13,7 @@ endif # of some options does

[PATCH -tip v2 08/11] READ_ONCE, WRITE_ONCE: Remove data_race() and unnecessary checks

2020-05-21 Thread Marco Elver
the volatile accesses. Finally, simplify __READ_ONCE_SCALAR and remove __WRITE_ONCE_SCALAR. Signed-off-by: Marco Elver --- v2: * Remove unnecessary kcsan_check_atomic*() in *_ONCE. * Simplify __READ_ONCE_SCALAR and remove __WRITE_ONCE_SCALAR. This effectively restores Will Deacon's pre-KCSAN version

[PATCH -tip v2 07/11] kcsan: Update Documentation to change supported compilers

2020-05-21 Thread Marco Elver
Signed-off-by: Marco Elver --- Documentation/dev-tools/kcsan.rst | 9 + 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/Documentation/dev-tools/kcsan.rst b/Documentation/dev-tools/kcsan.rst index f4b5766f12cc..ce4bbd918648 100644 --- a/Documentation/dev-tools/kcsan.rst

[PATCH -tip v2 02/11] kcsan: Avoid inserting __tsan_func_entry/exit if possible

2020-05-21 Thread Marco Elver
,exit}() insertion effectively disabled tail-call optimization, there should be no observable change. [This was caught and confirmed with kcsan-test & UNWINDER_ORC.] Signed-off-by: Marco Elver --- scripts/Makefile.kcsan | 11 ++- 1 file changed, 10 insertions(+), 1 deletion(-) diff -

[PATCH -tip v2 06/11] kcsan: Restrict supported compilers

2020-05-21 Thread Marco Elver
nel.org/r/CANpmjNMTsY_8241bS7=xafqvzhflrvekv_um4aduwe_kh3r...@mail.gmail.com Signed-off-by: Marco Elver --- lib/Kconfig.kcsan | 9 - 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/Kconfig.kcsan b/lib/Kconfig.kcsan index a7276035ca0d..3f3b5bca7a8f 100644 --- a/lib/Kconfig.kcsan

[PATCH -tip v2 11/11] compiler_types.h, kasan: Use __SANITIZE_ADDRESS__ instead of CONFIG_KASAN to decide inlining

2020-05-21 Thread Marco Elver
Like is done for KCSAN, for KASAN we should also use __always_inline in compilation units that have instrumentation disabled (KASAN_SANITIZE_foo.o := n). Adds common documentation for KASAN and KCSAN explaining the attribute. Signed-off-by: Marco Elver --- include/linux/compiler_types.h | 13

[PATCH -tip v2 10/11] compiler.h: Move function attributes to compiler_types.h

2020-05-21 Thread Marco Elver
Cleanup and move the KASAN and KCSAN related function attributes to compiler_types.h, where the rest of the same kind live. No functional change intended. Signed-off-by: Marco Elver --- include/linux/compiler.h | 29 - include/linux/compiler_types.h | 29

Re: [PATCH -tip 00/10] Fix KCSAN for new ONCE (require Clang 11)

2020-05-21 Thread Marco Elver
On Fri, 15 May 2020 at 17:03, Marco Elver wrote: > > This patch series is the conclusion to [1], where we determined that due > to various interactions with no_sanitize attributes and the new > {READ,WRITE}_ONCE(), KCSAN will require Clang 11 or later. Other > sanitizers are la

Re: [PATCH -tip v2 03/11] kcsan: Support distinguishing volatile accesses

2020-05-21 Thread Marco Elver
On Thu, 21 May 2020 at 15:18, Will Deacon wrote: > > On Thu, May 21, 2020 at 01:08:46PM +0200, Marco Elver wrote: > > In the kernel, volatile is used in various concurrent context, whether > > in low-level synchronization primitives or for legacy reasons. If > > suppo

Re: [PATCH -tip v2 07/11] kcsan: Update Documentation to change supported compilers

2020-05-21 Thread Marco Elver
On Thu, 21 May 2020 at 15:33, Will Deacon wrote: > > On Thu, May 21, 2020 at 01:08:50PM +0200, Marco Elver wrote: > > Signed-off-by: Marco Elver > > --- > > Documentation/dev-tools/kcsan.rst | 9 + > > 1 file changed, 1 insertion(+), 8 deletions(

Re: [PATCH -tip v2 09/11] data_race: Avoid nested statement expression

2020-05-21 Thread Marco Elver
On Thu, 21 May 2020 at 15:31, Will Deacon wrote: > > On Thu, May 21, 2020 at 01:08:52PM +0200, Marco Elver wrote: > > It appears that compilers have trouble with nested statements > > expressions, as such make the data_race() macro be only a single > > statement expre

Re: [PATCH -tip v2 00/11] Fix KCSAN for new ONCE (require Clang 11)

2020-05-21 Thread Marco Elver
On Thu, 21 May 2020 at 15:36, Will Deacon wrote: > > On Thu, May 21, 2020 at 01:08:43PM +0200, Marco Elver wrote: > > This patch series is the conclusion to [1], where we determined that due > > to various interactions with no_sanitize attributes and the new > > {R

[PATCH -tip v3 06/11] kcsan: Restrict supported compilers

2020-05-21 Thread Marco Elver
nel.org/r/CANpmjNMTsY_8241bS7=xafqvzhflrvekv_um4aduwe_kh3r...@mail.gmail.com Acked-by: Will Deacon Signed-off-by: Marco Elver --- lib/Kconfig.kcsan | 9 - 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/Kconfig.kcsan b/lib/Kconfig.kcsan index a7276035ca0d..3f3b5bca7a8f 100644

[PATCH -tip v3 01/11] ubsan, kcsan: don't combine sanitizer with kcov on clang

2020-05-21 Thread Marco Elver
/20200505142341.1096942-1-a...@arndb.de Acked-by: Marco Elver Signed-off-by: Arnd Bergmann Signed-off-by: Marco Elver --- This patch is already in -rcu tree, but since since the series is based on -tip, to avoid conflict it is required for the subsequent patches. --- lib/Kconfig.kcsan | 11 +++ lib

[PATCH -tip v3 05/11] kcsan: Remove 'noinline' from __no_kcsan_or_inline

2020-05-21 Thread Marco Elver
-by: Will Deacon Signed-off-by: Marco Elver --- include/linux/compiler.h | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/include/linux/compiler.h b/include/linux/compiler.h index e24cc3a2bc3e..17c98b215572 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h

[PATCH -tip v3 00/11] Fix KCSAN for new ONCE (require Clang 11)

2020-05-21 Thread Marco Elver
): ubsan, kcsan: don't combine sanitizer with kcov on clang Marco Elver (10): kcsan: Avoid inserting __tsan_func_entry/exit if possible kcsan: Support distinguishing volatile accesses kcsan: Pass option tsan-instrument-read-before-write to Clang kcsan: Remove 'noinline' from __no_kcsan

[PATCH -tip v3 03/11] kcsan: Support distinguishing volatile accesses

2020-05-21 Thread Marco Elver
-by: Marco Elver --- v2: * Reword Makefile comment. --- kernel/kcsan/core.c| 43 ++ scripts/Makefile.kcsan | 5 - 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/kernel/kcsan/core.c b/kernel/kcsan/core.c index a73a66cf79df..15f67949d11e

[PATCH -tip v3 11/11] compiler_types.h, kasan: Use __SANITIZE_ADDRESS__ instead of CONFIG_KASAN to decide inlining

2020-05-21 Thread Marco Elver
Like is done for KCSAN, for KASAN we should also use __always_inline in compilation units that have instrumentation disabled (KASAN_SANITIZE_foo.o := n). Adds common documentation for KASAN and KCSAN explaining the attribute. Acked-by: Will Deacon Signed-off-by: Marco Elver --- include/linux

[PATCH -tip v3 08/11] READ_ONCE, WRITE_ONCE: Remove data_race() and unnecessary checks

2020-05-21 Thread Marco Elver
the volatile accesses. Finally, simplify __READ_ONCE_SCALAR and remove __WRITE_ONCE_SCALAR. Acked-by: Will Deacon Signed-off-by: Marco Elver --- v2: * Remove unnecessary kcsan_check_atomic*() in *_ONCE. * Simplify __READ_ONCE_SCALAR and remove __WRITE_ONCE_SCALAR. This effectively restores Will Deacon's

[PATCH -tip v3 07/11] kcsan: Update Documentation to change supported compilers

2020-05-21 Thread Marco Elver
Document change in required compiler version for KCSAN, and remove the now redundant note about __no_kcsan and inlining problems with older compilers. Acked-by: Will Deacon Signed-off-by: Marco Elver --- v3: * Add missing commit message. --- Documentation/dev-tools/kcsan.rst | 9 + 1

[PATCH -tip v3 09/11] data_race: Avoid nested statement expression

2020-05-21 Thread Marco Elver
...@zn.tnic Acked-by: Will Deacon Signed-off-by: Marco Elver --- v3: * Fix for 'const' non-scalar expressions. v2: * Add patch to series in response to above linked discussion. --- include/linux/compiler.h | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/include/linux

[PATCH -tip v3 10/11] compiler.h: Move function attributes to compiler_types.h

2020-05-21 Thread Marco Elver
Cleanup and move the KASAN and KCSAN related function attributes to compiler_types.h, where the rest of the same kind live. No functional change intended. Acked-by: Will Deacon Signed-off-by: Marco Elver --- include/linux/compiler.h | 29 - include/linux

[PATCH -tip v3 04/11] kcsan: Pass option tsan-instrument-read-before-write to Clang

2020-05-21 Thread Marco Elver
Acked-by: Will Deacon Signed-off-by: Marco Elver --- scripts/Makefile.kcsan | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/Makefile.kcsan b/scripts/Makefile.kcsan index 75d2942b9437..bd4da1af5953 100644 --- a/scripts/Makefile.kcsan +++ b/scripts/Makefile.kcsan @@ -13,6 +13,7 @@ endif

[PATCH -tip v3 02/11] kcsan: Avoid inserting __tsan_func_entry/exit if possible

2020-05-21 Thread Marco Elver
,exit}() insertion effectively disabled tail-call optimization, there should be no observable change. [This was caught and confirmed with kcsan-test & UNWINDER_ORC.] Acked-by: Will Deacon Signed-off-by: Marco Elver --- scripts/Makefile.kcsan | 11 ++- 1 file changed, 10 insertions(+

[PATCH v2] kasan: Disable branch tracing for core runtime

2020-05-22 Thread Marco Elver
may recurse deep enough to cause kernel reboots without warning. To prevent similar issues in future, we should disable branch tracing for the core runtime. Link: https://lore.kernel.org/lkml/20200517011732.GE24705@shao2-debian/ Reported-by: kernel test robot Signed-off-by: Marco Elver --- v2

Re: [PATCH] kasan: Disable branch tracing for core runtime

2020-05-22 Thread Marco Elver
On Fri, 22 May 2020 at 00:11, Qian Cai wrote: > > On Tue, May 19, 2020 at 08:24:59PM +0200, 'Marco Elver' via kasan-dev wrote: > > During early boot, while KASAN is not yet initialized, it is possible to > > enter reporting code-path and end up in kasan_report(). While

Re: [PATCH -tip v3 03/11] kcsan: Support distinguishing volatile accesses

2020-05-22 Thread Marco Elver
On Fri, 22 May 2020 at 12:26, Borislav Petkov wrote: > > On Thu, May 21, 2020 at 04:20:39PM +0200, Marco Elver wrote: > > diff --git a/scripts/Makefile.kcsan b/scripts/Makefile.kcsan > > index 20337a7ecf54..75d2942b9437 100644 > > --- a/scripts/Makefile.kcsan > >

Re: PANIC: double fault in fixup_bad_iret

2020-06-02 Thread Marco Elver
You were a bit faster with the other patches ;-) I was still experimenting the the patches, but let me briefly respond here. On Tue, 2 Jun 2020 at 11:41, Peter Zijlstra wrote: > > On Mon, Jun 01, 2020 at 02:40:31PM +0200, Marco Elver wrote: > > I think Peter wanted to send a

[PATCH -tip 1/2] Kconfig: Bump required compiler version of KASAN and UBSAN

2020-06-02 Thread Marco Elver
tps://lkml.kernel.org/r/20200602175859.gc2...@hirez.programming.kicks-ass.net Suggested-by: Peter Zijlstra Signed-off-by: Marco Elver --- Apply after: https://lkml.kernel.org/r/20200602173103.931412...@infradead.org --- init/Kconfig | 3 +++ lib/Kconfig.kasan | 1 + lib/Kconfig.kcsan | 1 +

[PATCH -tip 2/2] compiler_types.h: Add __no_sanitize_{address,undefined} to noinstr

2020-06-02 Thread Marco Elver
+dc1fa714cb070b184...@syzkaller.appspotmail.com Signed-off-by: Marco Elver --- 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

Re: [PATCH 0/3] KCSAN cleanups and noinstr

2020-06-02 Thread Marco Elver
On Tue, 2 Jun 2020 at 19:34, Peter Zijlstra wrote: > > Hi all, > > Here's two KCSAN cleanups and the required noinstr change for x86. Thank you! Reviewed-by: Marco Elver As promised, here are the patches that would take care of KASAN and UBSAN, rebased on the patches

Re: [PATCH -tip 2/2] compiler_types.h: Add __no_sanitize_{address,undefined} to noinstr

2020-06-02 Thread Marco Elver
On Tue, 2 Jun 2020 at 20:49, 'Nick Desaulniers' via kasan-dev wrote: > > On Tue, Jun 2, 2020 at 11:44 AM 'Marco Elver' via Clang Built Linux > wrote: > > > > Adds the portable definitions for __no_sanitize_address, and > > __no_sanitize_undefined, and subseque

Re: [PATCH -tip 1/2] Kconfig: Bump required compiler version of KASAN and UBSAN

2020-06-02 Thread Marco Elver
On Tue, 2 Jun 2020 at 20:57, Nick Desaulniers wrote: > > On Tue, Jun 2, 2020 at 11:44 AM 'Marco Elver' via Clang Built Linux > wrote: > > > > Adds config variable CC_HAS_WORKING_NOSANITIZE, which will be true if we > > have a compiler that does not fail builds d

Re: [PATCH -tip 1/2] Kconfig: Bump required compiler version of KASAN and UBSAN

2020-06-02 Thread Marco Elver
On Tue, 2 Jun 2020 at 20:53, Andrey Konovalov wrote: > > On Tue, Jun 2, 2020 at 8:44 PM Marco Elver wrote: > > > > Adds config variable CC_HAS_WORKING_NOSANITIZE, which will be true if we > > have a compiler that does not fail builds due to no_sanitize functions. &g

Re: [PATCH -tip 1/2] Kconfig: Bump required compiler version of KASAN and UBSAN

2020-06-02 Thread Marco Elver
On Tue, 2 Jun 2020 at 21:19, Peter Zijlstra wrote: > > On Tue, Jun 02, 2020 at 11:57:15AM -0700, Nick Desaulniers wrote: > > On Tue, Jun 2, 2020 at 11:44 AM 'Marco Elver' via Clang Built Linux > > wrote: > > > > > > Adds config variable CC_HAS_WORKING_

Re: [PATCH] kcsan: Prefer '__no_kcsan inline' in test

2020-06-03 Thread Marco Elver
On Tue, 2 Jun 2020 at 22:48, Paul E. McKenney wrote: > > On Tue, Jun 02, 2020 at 04:36:33PM +0200, Marco Elver wrote: > > Instead of __no_kcsan_or_inline, prefer '__no_kcsan inline' in test -- > > this is in case we decide to remove __no_kcsan_or_inline. > > > >

Re: [PATCH 0/9] x86/entry fixes

2020-06-03 Thread Marco Elver
On Wed, 3 Jun 2020 at 14:08, Peter Zijlstra wrote: > > On Wed, Jun 03, 2020 at 02:00:37PM +0200, Peter Zijlstra wrote: > > On Wed, Jun 03, 2020 at 01:40:14PM +0200, Peter Zijlstra wrote: > > > The first patch is a fix for x86/entry, I'm quicky runing out of brown > > > paper bags again :/ > > >

Re: [PATCH 0/9] x86/entry fixes

2020-06-03 Thread Marco Elver
On Wed, 3 Jun 2020 at 14:18, Peter Zijlstra wrote: > > On Wed, Jun 03, 2020 at 02:08:57PM +0200, Marco Elver wrote: > > > What is the .config you used? I somehow can't reproduce. I've applied > > the patches on top of -tip/master. > > So tip/master, my patches

Re: [PATCH 0/9] x86/entry fixes

2020-06-03 Thread Marco Elver
On Wed, 3 Jun 2020 at 15:32, Marco Elver wrote: > > On Wed, 3 Jun 2020 at 14:18, Peter Zijlstra wrote: > > > > On Wed, Jun 03, 2020 at 02:08:57PM +0200, Marco Elver wrote: > > > > > What is the .config you used? I somehow can't reproduce. I've applied > &

Re: [PATCH 0/9] x86/entry fixes

2020-06-03 Thread Marco Elver
On Wed, 3 Jun 2020 at 18:07, Peter Zijlstra wrote: > > On Wed, Jun 03, 2020 at 04:47:54PM +0200, Marco Elver wrote: > > > This is fun: __always_inline functions inlined into > > __no_sanitize_undefined *do* get instrumented because apparently UBSan > > passes must run b

Re: [PATCH 0/9] x86/entry fixes

2020-06-03 Thread Marco Elver
On Wed, 3 Jun 2020 at 20:16, Peter Zijlstra wrote: > > On Wed, Jun 03, 2020 at 06:07:22PM +0200, Peter Zijlstra wrote: > > On Wed, Jun 03, 2020 at 04:47:54PM +0200, Marco Elver wrote: > > > > With that in mind, you could whitelist "__ubsan_handle"-prefixed

Re: [PATCH v5 00/18] Rework READ_ONCE() to improve codegen

2020-06-03 Thread Marco Elver
On Wed, 03 Jun 2020, Borislav Petkov wrote: > On Thu, May 14, 2020 at 12:05:38PM +0100, Will Deacon wrote: > > Talking off-list, Clang >= 7 is pretty reasonable wrt inlining decisions > > and the behaviour for __always_inline is: > > > > * An __always_inline function inlined into a

[PATCH -tip v2 1/2] kasan: Bump required compiler version

2020-06-03 Thread Marco Elver
ter Zijlstra Acked-by: Andrey Konovalov Reviewed-by: Nick Desaulniers Signed-off-by: Marco Elver --- Apply after: https://lkml.kernel.org/r/20200602173103.931412...@infradead.org v2: * No longer restrict UBSAN (and KCSAN), since the attributes behave differently for different sanitizers. For UB

[PATCH -tip v2 2/2] compiler_types.h: Add __no_sanitize_{address,undefined} to noinstr

2020-06-03 Thread Marco Elver
+dc1fa714cb070b184...@syzkaller.appspotmail.com Acked-by: Miguel Ojeda Signed-off-by: Marco Elver --- 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

Re: [PATCH -tip 1/2] Kconfig: Bump required compiler version of KASAN and UBSAN

2020-06-04 Thread Marco Elver
On Wed, 3 Jun 2020 at 15:35, 'Andrey Konovalov' via kasan-dev wrote: > > On Tue, Jun 2, 2020 at 8:44 PM Marco Elver wrote: > > > > Adds config variable CC_HAS_WORKING_NOSANITIZE, which will be true if we > > have a compiler that does not fail builds due to no_sanitize

Re: [PATCH 0/9] x86/entry fixes

2020-06-04 Thread Marco Elver
On Wed, 3 Jun 2020 at 21:10, Marco Elver wrote: > > On Wed, 3 Jun 2020 at 20:16, Peter Zijlstra wrote: > > > > On Wed, Jun 03, 2020 at 06:07:22PM +0200, Peter Zijlstra wrote: > > > On Wed, Jun 03, 2020 at 04:47:54PM +0200, Marco Elver wrote: > > > > >

Re: [PATCH 2/9] rcu: Fixup noinstr warnings

2020-06-04 Thread Marco Elver
On Thu, 4 Jun 2020 at 05:34, Paul E. McKenney wrote: > > On Wed, Jun 03, 2020 at 07:13:20PM +0200, Peter Zijlstra wrote: > > On Wed, Jun 03, 2020 at 09:46:00AM -0700, Paul E. McKenney wrote: > > > > > > --- a/kernel/rcu/tree.c > > > > +++ b/kernel/rcu/tree.c > > > > @@ -250,7 +250,7 @@ static

[PATCH -tip] kcov: Make runtime functions noinstr-compatible

2020-06-04 Thread Marco Elver
GCC and Clang. Signed-off-by: Marco Elver --- Note: There are a set of KCOV patches from Andrey in -next: https://lkml.kernel.org/r/cover.1585233617.git.andreyk...@google.com -- Git cleanly merges this patch with those patches, and no merge conflict is expected. --- kernel/Makefile | 2

Re: [PATCH 0/9] x86/entry fixes

2020-06-04 Thread Marco Elver
On Thu, 4 Jun 2020 at 08:00, Marco Elver wrote: > > On Wed, 3 Jun 2020 at 21:10, Marco Elver wrote: > > > > On Wed, 3 Jun 2020 at 20:16, Peter Zijlstra wrote: > > > > > > On Wed, Jun 03, 2020 at 06:07:22PM +0200, Peter Zijlstra wrote: > > > >

Re: [PATCH 0/8] x86/entry: KCSAN/KASAN/UBSAN vs noinstr

2020-06-04 Thread Marco Elver
On Thu, 4 Jun 2020 at 12:25, Peter Zijlstra 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

Re: [PATCH -tip] kcov: Make runtime functions noinstr-compatible

2020-06-04 Thread Marco Elver
On Thu, 4 Jun 2020 at 13:09, Peter Zijlstra wrote: > > On Thu, Jun 04, 2020 at 11:50:57AM +0200, Marco Elver wrote: > > The KCOV runtime is very minimal, only updating a field in 'current', > > and none of __sanitizer_cov-functions generates reports nor calls any > >

[PATCH 1/4] kcsan: Silence -Wmissing-prototypes warning with W=1

2020-06-16 Thread Marco Elver
/202006060103.jscpnv1g%...@intel.com Reported-by: kernel test robot Signed-off-by: Marco Elver --- kernel/kcsan/core.c | 9 + 1 file changed, 9 insertions(+) diff --git a/kernel/kcsan/core.c b/kernel/kcsan/core.c index 15f67949d11e..1866bafda4fd 100644 --- a/kernel/kcsan/core.c +++ b

[PATCH 2/4] kcsan: Rename test.c to selftest.c

2020-06-16 Thread Marco Elver
Rename 'test.c' to 'selftest.c' to better reflect its purpose (Kconfig variable and code inside already match this). This is to avoid confusion with the test suite module in 'kcsan-test.c'. No functional change. Signed-off-by: Marco Elver --- kernel/kcsan/Makefile | 2 +- kernel

[PATCH 0/4] kcsan: Minor cleanups

2020-06-16 Thread Marco Elver
Minor KCSAN cleanups, none of which should affect functionality. Marco Elver (4): kcsan: Silence -Wmissing-prototypes warning with W=1 kcsan: Rename test.c to selftest.c kcsan: Remove existing special atomic rules kcsan: Add jiffies test to test suite kernel/kcsan/Makefile

[PATCH 3/4] kcsan: Remove existing special atomic rules

2020-06-16 Thread Marco Elver
place to add special rules should the need arise in future. Signed-off-by: Marco Elver --- kernel/kcsan/atomic.h | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/kernel/kcsan/atomic.h b/kernel/kcsan/atomic.h index be9e625227f3..75fe701f4127 100644 --- a/kernel/kcsan

[PATCH 4/4] kcsan: Add jiffies test to test suite

2020-06-16 Thread Marco Elver
Add a test that KCSAN nor the compiler gets confused about accesses to jiffies on different architectures. Signed-off-by: Marco Elver --- kernel/kcsan/kcsan-test.c | 23 +++ 1 file changed, 23 insertions(+) diff --git a/kernel/kcsan/kcsan-test.c b/kernel/kcsan/kcsan-test.c

<    2   3   4   5   6   7   8   9   10   11   >