Re: [PATCH v3 03/10] arm64, kfence: enable KFENCE for ARM64

2020-09-28 Thread Marco Elver
On Mon, 21 Sep 2020 at 16:31, Will Deacon wrote: > On Mon, Sep 21, 2020 at 03:26:04PM +0200, Marco Elver wrote: > > Add architecture specific implementation details for KFENCE and enable > > KFENCE for the arm64 architecture. In particular, this implements the > &g

[PATCH v7 3/9] arm64, kfence: enable KFENCE for ARM64

2020-11-03 Thread Marco Elver
-by: Alexander Potapenko Signed-off-by: Alexander Potapenko Signed-off-by: Marco Elver --- v7: * Remove dependency on page size [reported by Mark Rutland]. * fault normally on permission faults [reported by Jann Horn]. v5: * Move generic page allocation code to core.c [suggested by Jann Horn

[PATCH v7 1/9] mm: add Kernel Electric-Fence infrastructure

2020-11-03 Thread Marco Elver
-developed-by: Marco Elver Signed-off-by: Marco Elver Signed-off-by: Alexander Potapenko --- v7: * Reports by Jann Horn: * Comment about is_kfence_address() performance. * Cleaner CONFIG_KFENCE_STRESS_TEST_FAULTS, using "if EXPERT". * Fix comment in metadata_to_pageaddr().

[PATCH v7 2/9] x86, kfence: enable KFENCE for x86

2020-11-03 Thread Marco Elver
need to ensure that the pool uses 4K pages, which is done using the set_memory_4k() helper function. Reviewed-by: Dmitry Vyukov Co-developed-by: Marco Elver Signed-off-by: Marco Elver Signed-off-by: Alexander Potapenko --- v7: * Only not-present faults should be handled by kfence [reported

[PATCH v7 0/9] KFENCE: A low-overhead sampling-based memory safety error detector

2020-11-03 Thread Marco Elver
nsert KFENCE hooks for SLAB mm, kfence: insert KFENCE hooks for SLUB kfence, kasan: make KFENCE compatible with KASAN Marco Elver (4): arm64, kfence: enable KFENCE for ARM64 kfence, Documentation: add KFENCE documentation kfence: add test suite MAINTAINERS: add entry for KFENCE

[PATCH v7 8/9] kfence: add test suite

2020-11-03 Thread Marco Elver
-by: Alexander Potapenko Signed-off-by: Alexander Potapenko Signed-off-by: Marco Elver --- v7: * Reword comments per Jann Horn's suggestions. v5: * Add better memory corruption test. * Test sl*b_def.h primitives. v4: * Clarify RCU test comment [reported by Paul E. McKenney]. v3: * Lower line buffer

[PATCH v7 6/9] kfence, kasan: make KFENCE compatible with KASAN

2020-11-03 Thread Marco Elver
-by: Jann Horn Co-developed-by: Marco Elver Signed-off-by: Marco Elver Signed-off-by: Alexander Potapenko --- v7: * Remove EXPERT restriction for enabling KASAN+KFENCE. In future, MTE-based KASAN without stack traces will benefit from having KFENCE (which has stack traces). Removing EXPERT

[PATCH v7 9/9] MAINTAINERS: add entry for KFENCE

2020-11-03 Thread Marco Elver
Add entry for KFENCE maintainers. Reviewed-by: Dmitry Vyukov Reviewed-by: SeongJae Park Co-developed-by: Alexander Potapenko Signed-off-by: Alexander Potapenko Signed-off-by: Marco Elver --- v7: * Add asm/kfence.h [reported by Jann Horn]. v4: * Split out from first patch. --- MAINTAINERS

[PATCH v7 5/9] mm, kfence: insert KFENCE hooks for SLUB

2020-11-03 Thread Marco Elver
-by: Dmitry Vyukov Reviewed-by: Jann Horn Co-developed-by: Marco Elver Signed-off-by: Marco Elver Signed-off-by: Alexander Potapenko --- v7: * Revert unused orig_size [reported by Jann Horn]. * Add Jann's Reviewed-by. * Use __kfence_free() where we know is_kfence_address() is true. * Re-add SLUB

[PATCH v7 7/9] kfence, Documentation: add KFENCE documentation

2020-11-03 Thread Marco Elver
Add KFENCE documentation in dev-tools/kfence.rst, and add to index. Reviewed-by: Dmitry Vyukov Co-developed-by: Alexander Potapenko Signed-off-by: Alexander Potapenko Signed-off-by: Marco Elver --- v7: * Suggestions by Jann Horn: * Add a note about huge tables. * Note about graceful

[PATCH v7 4/9] mm, kfence: insert KFENCE hooks for SLAB

2020-11-03 Thread Marco Elver
-by: Dmitry Vyukov Co-developed-by: Marco Elver Signed-off-by: Marco Elver Signed-off-by: Alexander Potapenko --- v7: * Move kmemleak_free_recursive() before kfence_free() for KFENCE objects. kmemleak_free_recursive() should be before releasing the object, to avoid a potential race where

Re: [PATCH v3 1/2] security: add fault injection capability

2020-11-02 Thread Marco Elver
ed). > > Signed-off-by: Aleksandr Nogikh Reviewed-by: Marco Elver > --- > v2: > * Renamed should_fail_lsm_hook() to lsm_hooks_inject_fail(). > --- > lib/Kconfig.debug | 6 + > security/security.c | 53 ++--- > 2 files ch

[PATCH 1/2] kcsan: Make test follow KUnit style recommendations

2021-01-13 Thread Marco Elver
to CONFIG_KCSAN_KUNIT_TEST and default to KUNIT_ALL_TESTS. Cc: David Gow Signed-off-by: Marco Elver --- kernel/kcsan/Makefile | 4 ++-- kernel/kcsan/{kcsan-test.c => kcsan_test.c} | 2 +- lib/Kconfig.kcsan | 5 +++-- 3 files changed, 6 insertions(+)

[PATCH 2/2] kcsan: Switch to KUNIT_CASE_PARAM for parameterized tests

2021-01-13 Thread Marco Elver
reads used, because on systems with too few CPUs, KUnit allows us to now stop at the maximum useful threads and not unnecessarily execute redundant test cases with (the same) limited threads as had been the case before. Cc: David Gow Signed-off-by: Marco Elver --- kernel/kcsan/kcsan_te

[PATCH net-next] net: fix up truesize of cloned skb in skb_prepare_for_shift()

2021-02-01 Thread Marco Elver
+7b99aafdcc2eedea6...@syzkaller.appspotmail.com Suggested-by: Eric Dumazet Signed-off-by: Marco Elver --- net/core/skbuff.c | 14 +- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 2af12f7e170c..3787093239f5 100644 --- a/net/core

Re: [PATCH mm] kasan: untag addresses for KFENCE

2021-02-01 Thread Marco Elver
On Fri, 29 Jan 2021 at 19:50, Andrey Konovalov wrote: > > KFENCE annotations operate on untagged addresses. > > Untag addresses in KASAN runtime where they might be tagged. > > Signed-off-by: Andrey Konovalov Reviewed-by: Marco Elver Thank you! > --- > > This can b

Re: [PATCH 1/2] kcsan: Make test follow KUnit style recommendations

2021-01-26 Thread Marco Elver
On Tue, 26 Jan 2021 at 05:35, David Gow wrote: > > On Thu, Jan 14, 2021 at 12:06 AM Marco Elver wrote: > > > > Per recently added KUnit style recommendations at > > Documentation/dev-tools/kunit/style.rst, make the following changes to > > the KCSAN test: > >

Re: [PATCH 04/12] kasan: clean up setting free info in kasan_slab_free

2021-02-02 Thread Marco Elver
lection_enabled() is always > true for generic KASAN. The confusion that this brings outweights saving > a few instructions. > > Signed-off-by: Andrey Konovalov Reviewed-by: Marco Elver > --- > mm/kasan/common.c | 6 ++ > 1 file changed, 2 insertions(+), 4 deletions(-)

Re: [PATCH 01/12] kasan, mm: don't save alloc stacks twice

2021-02-02 Thread Marco Elver
alloc caches > via a new kasan_cache_create_kmalloc() annotation. > > Signed-off-by: Andrey Konovalov Reviewed-by: Marco Elver > --- > include/linux/kasan.h | 9 + > mm/kasan/common.c | 18 ++ > mm/slab_common.c | 1 + > 3 files changed, 24 insertions(+)

Re: [PATCH 03/12] kasan: optimize large kmalloc poisoning

2021-02-02 Thread Marco Elver
to only poison the redzone. > > Signed-off-by: Andrey Konovalov Reviewed-by: Marco Elver > --- > mm/kasan/common.c | 20 +++- > 1 file changed, 15 insertions(+), 5 deletions(-) > > diff --git a/mm/kasan/common.c b/mm/kasan/common.c > index 128cb330ca7

Re: [PATCH 02/12] kasan, mm: optimize kmalloc poisoning

2021-02-02 Thread Marco Elver
On Mon, Feb 01, 2021 at 08:43PM +0100, Andrey Konovalov wrote: > For allocations from kmalloc caches, kasan_kmalloc() always follows > kasan_slab_alloc(). Currenly, both of them unpoison the whole object, > which is unnecessary. > > This patch provides separate implementations for both

Re: WARNING in sk_stream_kill_queues (5)

2021-02-03 Thread Marco Elver
On Mon, 14 Dec 2020 at 11:09, Marco Elver wrote: > On Thu, 10 Dec 2020 at 20:01, Marco Elver wrote: > > On Thu, 10 Dec 2020 at 18:14, Eric Dumazet wrote: > > > On Thu, Dec 10, 2020 at 5:51 PM Marco Elver wrote: > > [...] > > > > So I started put

Re: [PATCH 05/12] kasan: unify large kfree checks

2021-02-03 Thread Marco Elver
> first byte of the memory that's being freed is accessible. > > Signed-off-by: Andrey Konovalov Reviewed-by: Marco Elver > --- > include/linux/kasan.h | 16 > mm/kasan/common.c | 36 ++-- > 2 files changed, 34 insertions(+)

Re: [PATCH 02/12] kasan, mm: optimize kmalloc poisoning

2021-02-02 Thread Marco Elver
On Tue, 2 Feb 2021 at 18:16, Andrey Konovalov wrote: > > On Tue, Feb 2, 2021 at 5:25 PM Marco Elver wrote: > > > > > +#ifdef CONFIG_KASAN_GENERIC > > > + > > > +/** > > > + * kasan_poison_last_granule - mark the last granule of the memory range

Re: [PATCH net-next] net: fix up truesize of cloned skb in skb_prepare_for_shift()

2021-02-02 Thread Marco Elver
On Tue, 2 Feb 2021 at 18:59, Eric Dumazet wrote: > > On Mon, Feb 1, 2021 at 5:04 PM Marco Elver wrote: > > > > Avoid the assumption that ksize(kmalloc(S)) == ksize(kmalloc(S)): when > > cloning an skb, save and restore truesize after pskb_expand_head(). This > &

Re: [PATCH 01/12] kasan, mm: don't save alloc stacks twice

2021-02-02 Thread Marco Elver
On Tue, 2 Feb 2021 at 19:01, 'Andrey Konovalov' via kasan-dev wrote: [...] > > > @@ -83,6 +83,7 @@ static inline void kasan_disable_current(void) {} > > > struct kasan_cache { > > > int alloc_meta_offset; > > > int free_meta_offset; > > > + bool is_kmalloc; [...] > > > if

Re: [PATCH 08/12] kasan, mm: optimize krealloc poisoning

2021-02-03 Thread Marco Elver
On Mon, Feb 01, 2021 at 08:43PM +0100, Andrey Konovalov wrote: > Currently, krealloc() always calls ksize(), which unpoisons the whole > object including the redzone. This is inefficient, as kasan_krealloc() > repoisons the redzone for objects that fit into the same buffer. > > This patch changes

Re: [PATCH 06/12] kasan: rework krealloc tests

2021-02-03 Thread Marco Elver
each KASAN mode, and check accesses to that granule accordingly. > > Signed-off-by: Andrey Konovalov Reviewed-by: Marco Elver > --- > lib/test_kasan.c | 91 ++-- > 1 file changed, 81 insertions(+), 10 deletions(-) > > diff --git a/lib/tes

Re: [PATCH 07/12] kasan, mm: remove krealloc side-effect

2021-02-03 Thread Marco Elver
uous, because either way behaviour of krealloc differs from a kernel with KASAN disabled. Something like "kasan, mm: fail krealloc on already freed object" perhaps? > This patch also adds a KASAN-KUnit test to check krealloc() behaviour > when it's called on a freed object. > &

Re: [PATCH 11/12] kasan: always inline HW_TAGS helper functions

2021-02-03 Thread Marco Elver
On Mon, Feb 01, 2021 at 08:43PM +0100, Andrey Konovalov wrote: > Mark all static functions in common.c and kasan.h that are used for > hardware tag-based KASAN as __always_inline to avoid unnecessary > function calls. > > Signed-off-by: Andrey Konovalov Does objtool complain about any of these?

Re: [PATCH 09/12] kasan: ensure poisoning size alignment

2021-02-03 Thread Marco Elver
gt; kasan_unpoison(). > > Signed-off-by: Andrey Konovalov Reviewed-by: Marco Elver > --- > mm/kasan/common.c | 9 ++--- > mm/kasan/kasan.h | 33 - > mm/kasan/shadow.c | 37 ++--- > 3 files changed, 48

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

2020-05-19 Thread Marco Elver
On Mon, 18 May 2020 at 20:05, Marco Elver wrote: > > 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: > >

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

2020-05-19 Thread Marco Elver
On Tue, 19 May 2020 at 12:16, Marco Elver wrote: > > On Mon, 18 May 2020 at 20:05, Marco Elver wrote: > > > > On Mon, 18 May 2020, 'Nick Desaulniers' via kasan-dev wrote: > > > > > On Mon, May 18, 2020 at 7:34 AM Marco Elver wrote: > > > > >

[PATCH] kasan: Disable branch tracing for core runtime

2020-05-19 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 --- mm

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

2020-05-19 Thread Marco Elver
On Tue, 19 May 2020 at 15:40, Marco Elver wrote: > > On Tue, 19 May 2020 at 12:16, Marco Elver wrote: > > > > On Mon, 18 May 2020 at 20:05, Marco Elver wrote: > > > > > > On Mon, 18 May 2020, 'Nick Desaulniers' via kasan-dev wrote: > > > > &

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

2020-05-19 Thread Marco Elver
On Tue, 19 May 2020 at 23:10, Qian Cai wrote: > > On Tue, May 12, 2020 at 3:09 PM Peter Zijlstra wrote: > > > > On Tue, May 12, 2020 at 08:38:39PM +0200, Marco Elver wrote: > > > diff --git a/include/linux/compiler.h b/include/linux/compiler.h > > > ind

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

2020-05-20 Thread Marco Elver
On Wed, 20 May 2020 at 05:44, Nathan Chancellor wrote: > > On Tue, May 19, 2020 at 11:16:24PM -0400, Qian Cai wrote: > > On Tue, May 19, 2020 at 10:47 PM Nathan Chancellor > > wrote: > > > > > > On Tue, May 19, 2020 at 10:28:41PM -0400, Qian Cai wrote: > > > > > > > > > > > > > On May 19, 2020,

Re: [PATCH -tip] compiler_types.h: Optimize __unqual_scalar_typeof compilation time

2020-05-27 Thread Marco Elver
at 1:36 PM Sedat Dilek > > > > wrote: > > > > > On Wed, May 27, 2020 at 1:27 PM Arnd Bergmann wrote: > > > > > > On Wed, May 27, 2020 at 12:33 PM Marco Elver > > > > > > wrote: > > > > > > > > > > >

Re: [PATCH -tip] compiler_types.h: Optimize __unqual_scalar_typeof compilation time

2020-05-27 Thread Marco Elver
On Wed, 27 May 2020 at 15:37, Sedat Dilek wrote: > > On Wed, May 27, 2020 at 3:30 PM Marco Elver wrote: > > > > On Wed, 27 May 2020 at 15:11, Sedat Dilek wrote: > > > > > > On Wed, May 27, 2020 at 2:50 PM Arnd Bergmann wrote: > > > > >

Re: [PATCH -tip] compiler_types.h: Optimize __unqual_scalar_typeof compilation time

2020-05-27 Thread Marco Elver
On Wed, 27 May 2020 at 21:11, Sedat Dilek wrote: > > On Wed, May 27, 2020 at 3:57 PM Marco Elver wrote: > > > > On Wed, 27 May 2020 at 15:37, Sedat Dilek wrote: > > > > > > On Wed, May 27, 2020 at 3:30 PM Marco Elver wrote: > > > > > >

Re: [tip:locking/kcsan 12/12] /bin/bash: line 1: 61526 Segmentation fault sparse ...

2020-05-28 Thread Marco Elver
ot too. :-) > > /me trims it. > > Looks like we need __CHECKER__ ifdeffery somewhere but it is too late > for me to think straight so tomorrow... Ouch. The below should be all we need, assuming it's the best we can do for sparse right now. Thanks, -- Marco -- >8 -- Fr

Re: [PATCH -tip] compiler_types.h: Optimize __unqual_scalar_typeof compilation time

2020-05-28 Thread Marco Elver
On Thu, 28 May 2020 at 04:12, Sedat Dilek wrote: > [...] > > > > > > > > In general, CONFIG_KCSAN=y and the defaults for the other KCSAN > > > > options should be good. Depending on the size of your system, you > > > > could also tweak KCSAN runtime performance: > > > >

Re: [tip:locking/kcsan 12/12] /bin/bash: line 1: 61526 Segmentation fault sparse ...

2020-05-28 Thread Marco Elver
On Thu, 28 May 2020 at 17:22, Luc Van Oostenryck wrote: > > On Thu, May 28, 2020 at 09:59:00AM +0200, Marco Elver wrote: > > > > Ouch. The below should be all we need, assuming it's the best we can do > > for sparse right now. > > Upstream sparse should be OK with

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

2020-05-23 Thread Marco Elver
On Sat, 23 May 2020 at 01:42, Andrew Morton wrote: > > On Fri, 22 May 2020 09:52:07 +0200 Marco Elver 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: linux-next: build failure after merge of the tip tree

2020-05-25 Thread Marco Elver
On Mon, 25 May 2020 at 02:37, Paul E. McKenney wrote: > > On Sat, May 23, 2020 at 02:23:45PM -0700, Paul E. McKenney wrote: > > On Sat, May 23, 2020 at 09:05:24PM +0200, Thomas Gleixner wrote: > > > "Paul E. McKenney" writes: > > > > On Sat, May 23, 2020 at 11:54:26AM +0200, Thomas Gleixner

Re: PANIC: double fault in fixup_bad_iret

2020-06-01 Thread Marco Elver
On Sun, 31 May 2020 at 11:32, Dmitry Vyukov wrote: > > On Fri, May 29, 2020 at 7:11 PM Peter Zijlstra wrote: > > > Like with KCSAN, we should blanket kill KASAN/UBSAN and friends (at the > > > very least in arch/x86/) until they get that function attribute stuff > > > sorted. > > > > Something

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

2020-06-02 Thread Marco Elver
Instead of __no_kcsan_or_inline, prefer '__no_kcsan inline' in test -- this is in case we decide to remove __no_kcsan_or_inline. Suggested-by: Peter Zijlstra Signed-off-by: Marco Elver --- Hi Paul, This is to prepare eventual removal of __no_kcsan_or_inline, and avoid a series that doesn't

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

2020-05-26 Thread Marco Elver
On Tue, 26 May 2020 at 14:19, Arnd Bergmann wrote: > > On Tue, May 26, 2020 at 2:02 PM Will Deacon wrote: > > On Tue, May 26, 2020 at 12:42:16PM +0200, Arnd Bergmann wrote: > > > > > > I find this patch only solves half the problem: it's much faster than > > > without the > > > patch, but still

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

2020-05-26 Thread Marco Elver
On Tue, 26 May 2020, Marco Elver wrote: > On Tue, 26 May 2020 at 14:19, Arnd Bergmann wrote: > > > > On Tue, May 26, 2020 at 2:02 PM Will Deacon wrote: > > > On Tue, May 26, 2020 at 12:42:16PM +0200, Arnd Bergmann wrote: > > > > > > > > I find th

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

2020-05-27 Thread Marco Elver
On Wed, 27 May 2020 at 09:22, Will Deacon wrote: > > On Wed, May 27, 2020 at 01:10:00AM +0200, Arnd Bergmann wrote: > > On Tue, May 26, 2020 at 9:00 PM Arnd Bergmann wrote: > > > > > > On Tue, May 26, 2020 at 7:33 PM 'Marco Elver' via Clang Built Linux > > &

[PATCH -tip] compiler_types.h: Optimize __unqual_scalar_typeof compilation time

2020-05-27 Thread Marco Elver
jcoeqy...@mail.gmail.com Further compile-testing done with: gcc 4.8, 4.9, 5.5, 6.4, 7.5, 8.4; clang 9, 10. Reported-by: Arnd Bergmann Signed-off-by: Marco Elver Cc: Borislav Petkov Cc: Ingo Molnar Cc: Nick Desaulniers Cc: Paul E. McKenney Cc: Peter Zijlstra Cc: Stephen Rothwell Cc:

Re: [PATCH] kasan: fix clang compilation warning due to stack protector

2020-05-29 Thread Marco Elver
send an almost identical patch, as I encountered this when using clang. Reviewed-by: Marco Elver > mm/kasan/Makefile | 21 + > 1 file changed, 13 insertions(+), 8 deletions(-) > > diff --git a/mm/kasan/Makefile b/mm/kasan/Makefile > index de3121848ddf..bf6f7b1f6b1

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

2020-05-29 Thread Marco Elver
On Fri, 29 May 2020 at 19:08, Peter Zijlstra wrote: [...] > > Doesn't this mean we can do the below? If nobody complains about the lack of __no_kcsan_or_inline, let's do it. See comments below. > --- > Documentation/dev-tools/kcsan.rst | 6 -- > arch/x86/include/asm/bitops.h | 6

Re: [PATCH v2] kasan: fix clang compilation warning due to stack protector

2020-05-29 Thread Marco Elver
C_FLAGS_KASAN_CONFLICT to CC_FLAGS_KASAN_RUNTIME. Reviewed-by: Marco Elver Thanks! > --- > mm/kasan/Makefile | 21 + > 1 file changed, 13 insertions(+), 8 deletions(-) > > diff --git a/mm/kasan/Makefile b/mm/kasan/Makefile > index de3121848ddf..d532c2587731 1006

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

2020-06-04 Thread Marco Elver
On Thu, 4 Jun 2020 at 16:03, Andrey Konovalov wrote: > > On Thu, Jun 4, 2020 at 1:09 PM 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', > &

[PATCH v2 1/2] kcov, objtool: Make runtime functions noinstr-compatible

2020-06-04 Thread Marco Elver
to noinstr, and the checks added in this patch can be guarded by an #ifdef checking if the compiler has such an attribute or not. Signed-off-by: Marco Elver --- Apply after: https://lkml.kernel.org/r/20200604102241.466509...@infradead.org v2: * Rewrite based on Peter's and Andrey's feedback -- v1

[PATCH v2 2/2] kcov: Pass -fno-stack-protector with Clang

2020-06-04 Thread Marco Elver
For Clang, correctly pass -fno-stack-protector via a separate cc-option, as -fno-conserve-stack does not exist with Clang. Signed-off-by: Marco Elver --- kernel/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/Makefile b/kernel/Makefile index ce8716a04d0e

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

2020-06-05 Thread Marco Elver
extra call from the fast-path. In future, our compilers may provide an attribute to implement __no_sanitize_coverage, which can then be added to noinstr, and the checks added in this patch can be guarded by an #ifdef checking if the compiler has such an attribute or not. Signed-off-by: Marco Elver

[PATCH -tip v3 2/2] kcov: Unconditionally add -fno-stack-protector to compiler options

2020-06-05 Thread Marco Elver
-option, we were missing -fno-stack-protector with Clang. Unconditionally adding this option fixes this for Clang. Suggested-by: Nick Desaulniers Signed-off-by: Marco Elver --- v3: * Do not wrap -fno-stack-protector in cc-option, since all KCOV-supported compilers support the option as pointed out

[PATCH v2] mm/kasan: Print frame description for stack bugs

2019-05-20 Thread Marco Elver
] [ 17.928206] this frame has 2 objects: [ 17.928783] [32, 36) 'i' [ 17.928784] [96, 106) 'stack_array' [ 17.929216] [ 17.930031] Memory state around the buggy address: Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=198435 Signed-off-by: Marco Elver --- Changes since V1: - Fix types

Re: [PATCH v2] mm/kasan: Print frame description for stack bugs

2019-05-21 Thread Marco Elver
On Tue, 21 May 2019 at 17:53, Alexander Potapenko wrote: > > On Tue, May 21, 2019 at 5:43 PM Andrey Ryabinin > wrote: > > > > On 5/20/19 6:47 PM, Marco Elver wrote: > > > > > +static void print_decoded_frame_descr(const char *frame_descr) > > > +{ &

[PATCH v3] mm/kasan: Print frame description for stack bugs

2019-05-22 Thread Marco Elver
] [ 17.928206] this frame has 2 objects: [ 17.928783] [32, 36) 'i' [ 17.928784] [96, 106) 'stack_array' [ 17.929216] [ 17.930031] Memory state around the buggy address: Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=198435 Signed-off-by: Marco Elver --- Changes since v2: - Comment about why

Re: [PATCH] mm/kasan: Print frame description for stack bugs

2019-05-22 Thread Marco Elver
you for the patch! Perhaps something to improve: > > > > [auto build test WARNING on linus/master] > > [also build test WARNING on v5.1 next-20190517] > > [if your patch is applied to the wrong git tree, please drop us a note to > > help improve the system] > >

[PATCH] EDAC, ie31200: Add Intel Coffee Lake CPU support

2019-06-09 Thread Marco Elver
Coffee Lake seems to work like Skylake and Kaby Lake. This patch adds all device IDs for Coffee Lake-S CPUs according to datasheet. Cc: Jason Baron Cc: Borislav Petkov Cc: Mauro Carvalho Chehab Cc: Tony Luck Cc: linux-edac --- Tested with a Xeon E-2124G. --- drivers/edac/ie31200_edac.c |

Re: [PATCH] EDAC, ie31200: Add Intel Coffee Lake CPU support

2019-06-10 Thread Marco Elver
On Mon, 10 Jun 2019 at 20:01, Luck, Tony wrote: > > On Sun, Jun 09, 2019 at 05:16:13PM +0200, Marco Elver wrote: > > Marco, > > Thanks for the patch. One comment below. > > > - { > > - PCI_VEND_DEV(INTEL, IE31200_HB_1), PCI_ANY_ID, PCI_ANY_ID, 0,

[PATCH v2 2/2] EDAC, ie31200: Reformat PCI device table

2019-06-10 Thread Marco Elver
Reformat device table after Coffee Lake additions to be more readable. No functional change. Signed-off-by: Marco Elver Cc: Jason Baron Cc: Borislav Petkov Cc: Mauro Carvalho Chehab Cc: Tony Luck Cc: linux-edac --- drivers/edac/ie31200_edac.c | 80 ++--- 1

[PATCH v2 1/2] EDAC, ie31200: Add Intel Coffee Lake CPU support

2019-06-10 Thread Marco Elver
Coffee Lake seems to work like Skylake and Kaby Lake. This patch adds all device IDs for Coffee Lake-S CPUs according to datasheet. Signed-off-by: Marco Elver Cc: Jason Baron Cc: Borislav Petkov Cc: Mauro Carvalho Chehab Cc: Tony Luck Cc: linux-edac --- v2: - Reverted formatting existing

[PATCH v2 0/4] mm/kasan: Add object validation in ksize()

2019-06-26 Thread Marco Elver
__kasan_check_read() is chosen to check validity of an object inside ksize(). Previous version: http://lkml.kernel.org/r/20190624110532.41065-1-el...@google.com v2: * Complete rewrite of patch, refactoring ksize() and relying on kasan_check_read for validation. Marco Elver (4): mm/kasan

[PATCH v2 3/4] mm/slab: Refactor common ksize KASAN logic into slab_common.c

2019-06-26 Thread Marco Elver
This refactors common code of ksize() between the various allocators into slab_common.c: __ksize() is the allocator-specific implementation without instrumentation, whereas ksize() includes the required KASAN logic. Signed-off-by: Marco Elver Cc: Andrey Ryabinin Cc: Dmitry Vyukov Cc: Alexander

[PATCH v2 1/4] mm/kasan: Introduce __kasan_check_{read,write}

2019-06-26 Thread Marco Elver
. This change eliminates the need for the __KASAN_INTERNAL definition. Signed-off-by: Marco Elver Cc: Andrey Ryabinin Cc: Dmitry Vyukov Cc: Alexander Potapenko Cc: Andrey Konovalov Cc: Christoph Lameter Cc: Pekka Enberg Cc: David Rientjes Cc: Joonsoo Kim Cc: Andrew Morton Cc: kasan

[PATCH v2 4/4] mm/kasan: Add object validation in ksize()

2019-06-26 Thread Marco Elver
://bugzilla.kernel.org/show_bug.cgi?id=199359 Signed-off-by: Marco Elver Cc: Andrey Ryabinin Cc: Dmitry Vyukov Cc: Alexander Potapenko Cc: Andrey Konovalov Cc: Christoph Lameter Cc: Pekka Enberg Cc: David Rientjes Cc: Joonsoo Kim Cc: Andrew Morton Cc: kasan-...@googlegroups.com Cc: linux-kernel

[PATCH v2 2/4] lib/test_kasan: Add test for double-kzfree detection

2019-06-26 Thread Marco Elver
Adds a simple test that checks if double-kzfree is being detected correctly. Signed-off-by: Marco Elver Cc: Andrey Ryabinin Cc: Dmitry Vyukov Cc: Alexander Potapenko Cc: Andrey Konovalov Cc: Christoph Lameter Cc: Pekka Enberg Cc: David Rientjes Cc: Joonsoo Kim Cc: Andrew Morton Cc

[PATCH v3 0/5] mm/kasan: Add object validation in ksize()

2019-06-26 Thread Marco Elver
This version addresses formatting in kasan-checks.h and splits introduction of __kasan_check and returning boolean into 2 patches. Previous version: http://lkml.kernel.org/r/20190626122018.171606-1-el...@google.com Marco Elver (5): mm/kasan: Introduce __kasan_check_{read,write} mm/kasan

[PATCH v3 1/5] mm/kasan: Introduce __kasan_check_{read,write}

2019-06-26 Thread Marco Elver
This introduces __kasan_check_{read,write}. __kasan_check functions may be used from anywhere, even compilation units that disable instrumentation selectively. This change eliminates the need for the __KASAN_INTERNAL definition. Signed-off-by: Marco Elver Cc: Andrey Ryabinin Cc: Dmitry Vyukov

[PATCH v3 2/5] mm/kasan: Change kasan_check_{read,write} to return boolean

2019-06-26 Thread Marco Elver
This changes {,__}kasan_check_{read,write} functions to return a boolean denoting if the access was valid or not. Signed-off-by: Marco Elver Cc: Andrey Ryabinin Cc: Dmitry Vyukov Cc: Alexander Potapenko Cc: Andrey Konovalov Cc: Christoph Lameter Cc: Pekka Enberg Cc: David Rientjes Cc

[PATCH v3 3/5] lib/test_kasan: Add test for double-kzfree detection

2019-06-26 Thread Marco Elver
Adds a simple test that checks if double-kzfree is being detected correctly. Signed-off-by: Marco Elver Cc: Andrey Ryabinin Cc: Dmitry Vyukov Cc: Alexander Potapenko Cc: Andrey Konovalov Cc: Christoph Lameter Cc: Pekka Enberg Cc: David Rientjes Cc: Joonsoo Kim Cc: Andrew Morton Cc: Mark

[PATCH v3 4/5] mm/slab: Refactor common ksize KASAN logic into slab_common.c

2019-06-26 Thread Marco Elver
This refactors common code of ksize() between the various allocators into slab_common.c: __ksize() is the allocator-specific implementation without instrumentation, whereas ksize() includes the required KASAN logic. Signed-off-by: Marco Elver Cc: Andrey Ryabinin Cc: Dmitry Vyukov Cc: Alexander

[PATCH v3 5/5] mm/kasan: Add object validation in ksize()

2019-06-26 Thread Marco Elver
://bugzilla.kernel.org/show_bug.cgi?id=199359 Signed-off-by: Marco Elver Cc: Andrey Ryabinin Cc: Dmitry Vyukov Cc: Alexander Potapenko Cc: Andrey Konovalov Cc: Christoph Lameter Cc: Pekka Enberg Cc: David Rientjes Cc: Joonsoo Kim Cc: Andrew Morton Cc: Mark Rutland Cc: kasan-...@googlegroups.com Cc

Re: [PATCH 3/3] asm-generic, x86: Add bitops instrumentation for KASAN

2019-05-29 Thread Marco Elver
On Wed, 29 May 2019 at 12:01, Peter Zijlstra wrote: > > On Wed, May 29, 2019 at 11:20:17AM +0200, Marco Elver wrote: > > For the default, we decided to err on the conservative side for now, > > since it seems that e.g. x86 operates only on the byte the bit is on. > >

[PATCH 2/2] lib/test_kasan: Add stack overflow test

2019-07-19 Thread Marco Elver
Adds a simple stack overflow test, to check the error being reported on an overflow. Without CONFIG_STACK_GUARD_PAGE, the result is typically some seemingly unrelated KASAN error message due to accessing random other memory. Signed-off-by: Marco Elver Cc: Thomas Gleixner Cc: Ingo Molnar Cc

[PATCH 1/2] kernel/fork: Add support for stack-end guard page

2019-07-19 Thread Marco Elver
considered -- any comments on better alternatives or improvements are welcome. Signed-off-by: Marco Elver Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Borislav Petkov Cc: "H. Peter Anvin" Cc: Andrey Ryabinin Cc: Alexander Potapenko Cc: Dmitry Vyukov Cc: Andrey Konovalov Cc: Mark Rutland

Re: Kernel Concurrency Sanitizer (KCSAN)

2019-10-02 Thread Marco Elver
Hi Daniel, On Tue, 1 Oct 2019 at 16:50, Daniel Axtens wrote: > > Hi Marco, > > > We would like to share a new data-race detector for the Linux kernel: > > Kernel Concurrency Sanitizer (KCSAN) -- > > https://github.com/google/ktsan/wiki/KCSAN (Details: > >

Re: Kernel Concurrency Sanitizer (KCSAN)

2019-10-02 Thread Marco Elver
Hi Joel, On Tue, 1 Oct 2019 at 23:19, Joel Fernandes wrote: > > On Fri, Sep 20, 2019 at 04:18:57PM +0200, Marco Elver wrote: > > Hi all, > > > > We would like to share a new data-race detector for the Linux kernel: > > Kernel Concurrency Sanitizer (KCSAN) -- >

Kernel Concurrency Sanitizer (KCSAN)

2019-09-20 Thread Marco Elver
Hi all, We would like to share a new data-race detector for the Linux kernel: Kernel Concurrency Sanitizer (KCSAN) -- https://github.com/google/ktsan/wiki/KCSAN (Details: https://github.com/google/ktsan/blob/kcsan/Documentation/dev-tools/kcsan.rst) To those of you who we mentioned at LPC that

Re: Kernel Concurrency Sanitizer (KCSAN)

2019-09-20 Thread Marco Elver
On Fri, 20 Sep 2019 at 18:47, Dmitry Vyukov wrote: > > On Fri, Sep 20, 2019 at 6:31 PM Mark Rutland wrote: > > > > On Fri, Sep 20, 2019 at 04:18:57PM +0200, Marco Elver wrote: > > > We would like to share a new data-race detector for the Linux kernel: > > >

Re: Kernel Concurrency Sanitizer (KCSAN)

2019-09-20 Thread Marco Elver
On Fri, 20 Sep 2019 at 17:54, Will Deacon wrote: > > Hi Marco, > > On Fri, Sep 20, 2019 at 04:18:57PM +0200, Marco Elver wrote: > > We would like to share a new data-race detector for the Linux kernel: > > Kernel Concurrency Sanitizer (KCSAN) -- > > https://gith

Re: Kernel Concurrency Sanitizer (KCSAN)

2019-10-03 Thread Marco Elver
On Thu, 3 Oct 2019 at 18:12, Mark Rutland wrote: > > On Fri, Sep 20, 2019 at 07:51:04PM +0200, Marco Elver wrote: > > On Fri, 20 Sep 2019 at 18:47, Dmitry Vyukov wrote: > > > > > > On Fri, Sep 20, 2019 at 6:31 PM Mark Rutland wrote: > > > > > &

Re: [PATCH] taskstats: fix data-race

2019-10-05 Thread Marco Elver
On Sat, 5 Oct 2019 at 13:28, Christian Brauner wrote: > > When assiging and testing taskstats in taskstats > taskstats_exit() there's a race around writing and reading sig->stats. > > cpu0: > task calls exit() > do_exit() > -> taskstats_exit() > -> taskstats_tgid_alloc() >

Re: [PATCH] taskstats: fix data-race

2019-10-05 Thread Marco Elver
On Sat, 5 Oct 2019 at 16:15, Christian Brauner wrote: > > On Sat, Oct 05, 2019 at 03:33:07PM +0200, Marco Elver wrote: > > On Sat, 5 Oct 2019 at 13:28, Christian Brauner > > wrote: > > > > > > When assiging and testing taskstats in taskstats > > > t

Re: [PATCH] stop_machine: avoid potential race behaviour

2019-10-07 Thread Marco Elver
kernel/stop_machine.c:516 > | smpboot_thread_fn+0x1a8/0x300 kernel/smpboot.c:165 > | kthread+0x1b5/0x200 kernel/kthread.c:255 > | ret_from_fork+0x35/0x40 arch/x86/entry/entry_64.S:352 > | > | Reported by Kernel Concurrency Sanitizer on: > | CPU: 7 PID: 44 Comm: migration/7 Not t

Re: [PATCH] rcu: Avoid to modify mask_ofl_ipi in sync_rcu_exp_select_node_cpus()

2019-10-08 Thread Marco Elver
using "mask_ofl_test" for recording and > > "mask_ofl_ipi" for iteration. This would improve the readibility of the > > IPI sending loop in sync_rcu_exp_select_node_cpus(). > > > > Signed-off-by: Boqun Feng > > --- > > Reviewed-by: Joel Fernandes

Re: [PATCH] taskstats: fix data-race

2019-10-09 Thread Marco Elver
taskstats: cleanup ->signal->stats allocation") > Cc: sta...@vger.kernel.org > Signed-off-by: Christian Brauner > Reviewed-by: Dmitry Vyukov > --- > /* v1 */ > Link: > https://lore.kernel.org/r/20191005112806.13960-1-christian.brau...@ubuntu.com > > /* v2 */ >

[PATCH] rcu: Fix data-race due to atomic_t copy-by-value

2019-10-09 Thread Marco Elver
), BIOS 1.12.0-1 04/01/2014 Workqueue: kblockd blk_mq_run_work_fn == Signed-off-by: Marco Elver Cc: Paul E. McKenney Cc: Josh Triplett Cc: Steven Rostedt Cc: Mathieu Desnoyers Cc: Lai Jiangshan Cc: Joel Fernandes Cc: Ingo Molnar Cc

Re: KCSAN: data-race in task_dump_owner / task_dump_owner

2019-10-17 Thread Marco Elver
Hi, On Thu, 17 Oct 2019 at 14:36, syzbot wrote: > > Hello, > > syzbot found the following crash on: > > HEAD commit:d724f94f x86, kcsan: Enable KCSAN for x86 > git tree: https://github.com/google/ktsan.git kcsan > console output: https://syzkaller.appspot.com/x/log.txt?x=17884db360

Re: KCSAN: data-race in task_dump_owner / task_dump_owner

2019-10-17 Thread Marco Elver
On Thu, 17 Oct 2019 at 20:17, Alexey Dobriyan wrote: > > On Thu, Oct 17, 2019 at 02:56:47PM +0200, Marco Elver wrote: > > Hi, > > > > On Thu, 17 Oct 2019 at 14:36, syzbot > > wrote: > > > > > > Hello, > > > > > > syzbot foun

Re: [PATCH] kunit: Kconfig: enable a KUNIT_RUN_ALL fragment

2020-05-01 Thread Marco Elver
On Fri, 1 May 2020 at 10:35, Anders Roxell wrote: > > Make it easier to enable all KUnit fragments. This is needed for kernel > test-systems, so its easy to get all KUnit tests enabled and if new gets > added they will be enabled as well. Fragments that has to be builtin > will be missed if

Re: [PATCH v2 1/8] kcsan: Add Kernel Concurrency Sanitizer infrastructure

2019-10-22 Thread Marco Elver
Hi Mark, Thanks for you comments; see inline comments below. On Tue, 22 Oct 2019 at 16:11, Mark Rutland wrote: > > Hi Marco, > > On Thu, Oct 17, 2019 at 04:12:58PM +0200, Marco Elver wrote: > > Kernel Concurrency Sanitizer (KCSAN) is a dynamic data-race detector for >

Re: KCSAN Support on ARM64 Kernel

2019-10-14 Thread Marco Elver
On Mon, 14 Oct 2019 at 10:40, Dmitry Vyukov wrote: > > On Mon, Oct 14, 2019 at 7:11 AM wrote: > > > > Hi Dmitry, > > > > I am from Qualcomm Linux Security Team, just going through KCSAN and found > > that there was a thread for arm64 support > > (https://lkml.org/lkml/2019/9/20/804). > > > >

Re: KCSAN Support on ARM64 Kernel

2019-10-14 Thread Marco Elver
Hi Sachin, My plan was to send patches upstream within the month. Thanks, -- Marco On Mon, 14 Oct 2019 at 11:30, wrote: > > Hi Marco, > > When can we expect upstream of KCSAN on kernel mainline. Any timeline? > > Regards, > Sachin Grover > > -Original Messa

Re: [PATCH] rcu: Fix data-race due to atomic_t copy-by-value

2019-10-14 Thread Marco Elver
On Mon, 14 Oct 2019 at 20:00, Joel Fernandes wrote: > > On Wed, Oct 09, 2019 at 05:57:43PM +0200, Marco Elver wrote: > > This fixes a data-race where `atomic_t dynticks` is copied by value. The > > copy is performed non-atomically, resulting in a data-race if `dyntic

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