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

2020-05-15 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 01/10] ubsan, kcsan: don't combine sanitizer with kcov on clang

2020-05-15 Thread Marco Elver
lore.kernel.org/lkml/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 |

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

2020-05-15 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 c02662b30a7c..ea4a6301633e 100644 --- a/scripts/Makefile.kcsan +++ b/scripts/Makefile.kcsan @@ -13,6 +13,7 @@ endif # if the absence of

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

2020-05-15 Thread Marco Elver
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/compiler.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include

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

2020-05-15 Thread Marco Elver
entry,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(-) dif

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

2020-05-15 Thread Marco Elver
.@mail.gmail.com 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/comp

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

2020-05-15 Thread Marco Elver
mbine sanitizer with kcov on clang Marco Elver (9): 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_or_inline kcsan

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

2020-05-15 Thread Marco Elver
d #7. Link: https://lkml.kernel.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 1

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

2020-05-15 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

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

2020-06-08 Thread Marco Elver
On Sun, 7 Jun 2020 at 11:37, Dmitry Vyukov wrote: > > On Fri, Jun 5, 2020 at 3:25 PM 'Andrey Konovalov' via kasan-dev > wrote: > > > On Fri, Jun 05, 2020 at 12:57:15PM +0200, Dmitry Vyukov wrote: > > > > On Fri, Jun 5, 2020 at 10:28 AM Marco Elver wr

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

2020-06-08 Thread Marco Elver
On Mon, 8 Jun 2020 at 19:32, Martin Liška wrote: > > On 6/3/20 9:23 PM, Marco Elver wrote: > > > > > > On Wed, 03 Jun 2020, Borislav Petkov wrote: > > > >> On Thu, May 14, 2020 at 12:05:38PM +0100, Will Deacon wrote: > >>> Talking off-list, Cla

Re: [PATCH] lib: kunit: add list_sort test conversion to KUnit

2020-08-27 Thread Marco Elver
On Wed, Jul 29, 2020 at 04:23PM -0300, Vitor Massaru Iha wrote: > This adds the conversion of the runtime tests of test_list_sort, > from `lib/test_list_sort.c` to KUnit tests. > > Please apply this commit first (linux-kselftest/kunit-fixes): > 3f37d14b8a3152441f36b6bc74000996679f0998 kunit: kunit

Re: [PATCH] Documentation: kunit: Add naming guidelines

2020-08-27 Thread Marco Elver
On Thu, Jul 02, 2020 at 12:14AM -0700, David Gow wrote: > As discussed in [1], KUnit tests have hitherto not had a particularly > consistent naming scheme. This adds documentation outlining how tests > and test suites should be named, including how those names should be > used in Kconfig entries an

Re: [PATCH] Documentation: kunit: Add naming guidelines

2020-08-27 Thread Marco Elver
On Thu, 27 Aug 2020 at 18:17, David Gow wrote: [...] > > First of all, thanks for the talk yesterday! I only looked at this > > because somebody pasted the LKML link. :-) > > No worries! Clearly this document needed linking -- even I was > starting to suspect the reason no-one was complaining abou

Re: [PATCH] compiler-clang: add build check for clang 10.0.1

2020-08-27 Thread Marco Elver
erence. If we are not going to clean up behind us, this > should be a warning and not an error. There are also some other documentation that would go stale. We probably have to change KASAN docs to look something like the below. I wish we could also remove the "but detection of out-of-bo

Re: [PATCH 35/35] kasan: add documentation for hardware tag-based mode

2020-08-28 Thread Marco Elver
On Fri, Aug 14, 2020 at 07:27PM +0200, Andrey Konovalov wrote: > Add documentation for hardware tag-based KASAN mode and also add some > clarifications for software tag-based mode. > > Signed-off-by: Andrey Konovalov > --- > Documentation/dev-tools/kasan.rst | 73 +--

Re: [PATCH v2 6/6] kasan: update documentation for generic kasan

2020-08-24 Thread Marco Elver
On Mon, 24 Aug 2020 at 10:14, Walter Wu wrote: > > Generic KASAN support to record the last two timer and workqueue > stacks and print them in KASAN report. So that need to update > documentation. > > Signed-off-by: Walter Wu > Cc: Andrey Ryabinin > Cc: Dmitry Vyukov > Cc: Alexander Potapenko

Re: [PATCH v2 5/6] kasan: add tests for workqueue stack recording

2020-08-24 Thread Marco Elver
On Mon, 24 Aug 2020 at 10:14, Walter Wu wrote: > > Adds a test to verify workqueue stack recording and print it in > KASAN report. > > The KASAN report was as follows(cleaned up slightly): > > BUG: KASAN: use-after-free in kasan_workqueue_uaf > > Freed by task 54: > kasan_save_stack+0x24/0x50

Re: [PATCH v2 0/6] kasan: add workqueue and timer stack for generic KASAN

2020-08-24 Thread Marco Elver
orkqueue stack. > - change the aux stack title for common name. Much cleaner. In general, Acked-by: Marco Elver but I left some more comments. I'm a bit worried about the tests, because of KASAN-test KUnit rework, but probably not much we can do until these are added to -mm tree. Thanks, -- Marco

Re: [PATCH v3 0/6] kasan: add workqueue and timer stack for generic KASAN

2020-08-25 Thread Marco Elver
c: add workqueue test case > kasan: update documentation for generic kasan Acked-by: Marco Elver > --- > > Changes since v2: > - modify kasan document to be more readable. > Thanks for Marco suggestion. > > Changes since v1: > - Thanks for Marco and Thomas sugges

Re: [PATCH] Documentation: kunit: Add naming guidelines

2020-09-01 Thread Marco Elver
On Tue, 1 Sep 2020 at 07:31, David Gow wrote: > On Tue, Sep 1, 2020 at 7:47 AM Kees Cook wrote: > > On Fri, Aug 28, 2020 at 12:17:05AM +0800, David Gow wrote: > > > On Thu, Aug 27, 2020 at 9:14 PM Marco Elver wrote: [...] > > I guess there are two audiences to cater for

Re: [PATCH kcsan 18/19] bitops, kcsan: Partially revert instrumentation for non-atomic bitops

2020-09-01 Thread Marco Elver
On Wed, Sep 02, 2020 at 11:30AM +0800, Boqun Feng wrote: > Hi Paul and Marco, > > The whole update patchset looks good to me, just one question out of > curiosity fo this one, please see below: > > On Mon, Aug 31, 2020 at 11:18:04AM -0700, paul...@kernel.org wrote: >

Re: [PATCH] Documentation: kunit: Add naming guidelines

2020-09-07 Thread Marco Elver
On Fri, Sep 04, 2020 at 12:22PM +0800, David Gow wrote: [...] > > This is a good point -- renaming files is definitely a pain. It's > obviously my hope that KUnit sticks around long enough that it's not > being added/removed as a dependency too often, particularly for the > unit tests, so "_kunit"

[PATCH RFC 07/10] kfence, kmemleak: make KFENCE compatible with KMEMLEAK

2020-09-07 Thread Marco Elver
From: Alexander Potapenko Add compatibility with KMEMLEAK, by making KMEMLEAK aware of the KFENCE memory pool. This allows building debug kernels with both enabled, which also helped in debugging KFENCE. Co-developed-by: Marco Elver Signed-off-by: Marco Elver Signed-off-by: Alexander

Re: [PATCH RFC 01/10] mm: add Kernel Electric-Fence infrastructure

2020-09-07 Thread Marco Elver
On Mon, 7 Sep 2020 at 17:43, Jonathan Cameron wrote: ... > Interesting bit of work. A few trivial things inline I spotted whilst having > a first read through. > > Thanks, > > Jonathan Thank you for having a look! We'll address these for v2. Thanks, -- Marco

Re: [PATCH] kcsan: Treat runtime as NMI-like with interrupt tracing

2020-08-17 Thread Marco Elver
On Tue, 11 Aug 2020 at 08:56, Marco Elver wrote: > On Mon, 10 Aug 2020 at 22:18, Thomas Gleixner wrote: > > Marco Elver writes: > > > Since KCSAN instrumentation is everywhere, we need to treat the hooks > > > NMI-like for interrupt tracing. In order to present an as

Re: Odd-sized kmem_cache_alloc and slub_debug=Z

2020-08-17 Thread Marco Elver
On Fri, 7 Aug 2020 at 21:06, Pekka Enberg wrote: ... > Yeah, it reproduces with defconfig too, as long as you remember to > pass "slub_debug=Z"... :-/ > > The following seems to be the culprit: > > commit 3202fa62fb43087387c65bfa9c100feffac74aa6 > Author: Kees Cook > Date: Wed Apr 1 21:04:27 20

Re: [GIT pull] sched/urgent for v5.9-rc2

2020-08-30 Thread Marco Elver
On Sun, 30 Aug 2020 at 20:54, Linus Torvalds wrote: > On Sun, Aug 30, 2020 at 11:04 AM Thomas Gleixner wrote: > > > > - Make is_idle_task() __always_inline to prevent the compiler from putting > >it out of line into the wrong section because it's used inside noinstr > >sections. > > What

Re: [GIT pull] sched/urgent for v5.9-rc2

2020-08-31 Thread Marco Elver
On Mon, 31 Aug 2020 at 09:24, wrote: > > On Sun, Aug 30, 2020 at 11:54:19AM -0700, Linus Torvalds wrote: > > On Sun, Aug 30, 2020 at 11:04 AM Thomas Gleixner wrote: > > > > > > - Make is_idle_task() __always_inline to prevent the compiler from > > > putting > > >it out of line into the wron

Re: [RFC v8 01/10] mm/damon/debugfs: Allow users to set initial monitoring target regions

2020-08-31 Thread Marco Elver
On Mon, Aug 31, 2020 at 12:47PM +0200, SeongJae Park wrote: [...] > diff --git a/mm/damon.c b/mm/damon.c > index 7e3c8c82a010..9815d22fc4de 100644 > --- a/mm/damon.c > +++ b/mm/damon.c > @@ -2001,6 +2001,147 @@ static ssize_t debugfs_record_write(struct file *file, > return ret; > } > > +s

Re: [PATCH RFC 09/10] kfence, Documentation: add KFENCE documentation

2020-09-07 Thread Marco Elver
On Mon, 7 Sep 2020 at 17:34, Andrey Konovalov wrote: > > On Mon, Sep 7, 2020 at 3:41 PM Marco Elver wrote: > > > > Add KFENCE documentation in dev-tools/kfence.rst, and add to index. > > > > Co-developed-by: Alexander Potapenko > > Signed-off-by: Alexander

[PATCH RFC 10/10] kfence: add test suite

2020-09-07 Thread Marco Elver
d-off-by: Alexander Potapenko Signed-off-by: Marco Elver --- lib/Kconfig.kfence | 12 + mm/kfence/Makefile | 3 + mm/kfence/kfence-test.c | 777 3 files changed, 792 insertions(+) create mode 100644 mm/kfence/kfence-test.c diff --git

[PATCH RFC 09/10] kfence, Documentation: add KFENCE documentation

2020-09-07 Thread Marco Elver
Add KFENCE documentation in dev-tools/kfence.rst, and add to index. Co-developed-by: Alexander Potapenko Signed-off-by: Alexander Potapenko Signed-off-by: Marco Elver --- Documentation/dev-tools/index.rst | 1 + Documentation/dev-tools/kfence.rst | 285 + 2

[PATCH RFC 08/10] kfence, lockdep: make KFENCE compatible with lockdep

2020-09-07 Thread Marco Elver
KFENCE-allocated objects in static_obj(). Co-developed-by: Alexander Potapenko Signed-off-by: Alexander Potapenko Signed-off-by: Marco Elver --- kernel/locking/lockdep.c | 8 1 file changed, 8 insertions(+) diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c index

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

2020-09-07 Thread Marco Elver
is_kfence_address(). Co-developed-by: Alexander Potapenko Signed-off-by: Alexander Potapenko Signed-off-by: Marco Elver --- For ARM64, we would like to solicit feedback on what the best option is to obtain a constant address for __kfence_pool. One option is to declare a memory range in the memory layout to

[PATCH RFC 04/10] mm, kfence: insert KFENCE hooks for SLAB

2020-09-07 Thread Marco Elver
ctions are __always_inline. Co-developed-by: Marco Elver Signed-off-by: Marco Elver Signed-off-by: Alexander Potapenko --- mm/slab.c| 46 ++ mm/slab_common.c | 6 +- 2 files changed, 39 insertions(+), 13 deletions(-) diff --git a/mm/s

[PATCH RFC 05/10] mm, kfence: insert KFENCE hooks for SLUB

2020-09-07 Thread Marco Elver
ctions are __always_inline. Co-developed-by: Marco Elver Signed-off-by: Marco Elver Signed-off-by: Alexander Potapenko --- mm/slub.c | 72 --- 1 file changed, 53 insertions(+), 19 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index d4

[PATCH RFC 02/10] x86, kfence: enable KFENCE for x86

2020-09-07 Thread Marco Elver
need to ensure that the pool uses 4K pages, which is done using the set_memory_4k() helper function. Co-developed-by: Marco Elver Signed-off-by: Marco Elver Signed-off-by: Alexander Potapenko --- arch/x86/Kconfig | 2 ++ arch/x86/include/asm/kfence.h | 60

[PATCH RFC 06/10] kfence, kasan: make KFENCE compatible with KASAN

2020-09-07 Thread Marco Elver
of the two is generally discouraged, CONFIG_EXPERT=y should be set. It also gives us the nice property that KFENCE will be build-tested by allyesconfig builds. Co-developed-by: Marco Elver Signed-off-by: Marco Elver Signed-off-by: Alexander Potapenko --- lib/Kconfig.kfence | 2 +- mm/kasan

[PATCH RFC 01/10] mm: add Kernel Electric-Fence infrastructure

2020-09-07 Thread Marco Elver
-neutral compared to the non-KFENCE baseline. For more details, see Documentation/dev-tools/kfence.rst (added later in the series). Co-developed-by: Marco Elver Signed-off-by: Marco Elver Signed-off-by: Alexander Potapenko --- MAINTAINERS| 11 + include/linux/kfence.h | 174 +++

[PATCH RFC 00/10] KFENCE: A low-overhead sampling-based memory safety error detector

2020-09-07 Thread Marco Elver
mm: add Kernel Electric-Fence infrastructure x86, kfence: enable KFENCE for x86 mm, kfence: insert KFENCE hooks for SLAB mm, kfence: insert KFENCE hooks for SLUB kfence, kasan: make KFENCE compatible with KASAN kfence, kmemleak: make KFENCE compatible with KMEMLEAK Marco Elver (4): arm64, k

Re: [PATCH RFC 09/10] kfence, Documentation: add KFENCE documentation

2020-09-07 Thread Marco Elver
On Mon, 7 Sep 2020 at 19:55, Andrey Konovalov wrote: > On Mon, Sep 7, 2020 at 6:33 PM Marco Elver wrote: [...] > > > > +Guarded allocations are set up based on the sample interval. After > > > > expiration > > > > +of the sample interval, a gu

Re: [RFC PATCH 1/2] lib/string: Disable instrumentation

2020-09-08 Thread Marco Elver
On Sun, 6 Sep 2020 at 00:23, Arvind Sankar wrote: > > String functions can be useful in early boot, but using instrumented > versions can be problematic: eg on x86, some of the early boot code is > executing out of an identity mapping rather than the kernel virtual > addresses. Accessing any globa

Re: [PATCH RFC 00/10] KFENCE: A low-overhead sampling-based memory safety error detector

2020-09-08 Thread Marco Elver
On Tue, Sep 08, 2020 at 05:36PM +0200, Vlastimil Babka wrote: > On 9/8/20 5:31 PM, Marco Elver wrote: > >> > >> How much memory overhead does this end up having? I know it depends on > >> the object size and so forth. But, could you give some real-world >

Re: [PATCH RFC 09/10] kfence, Documentation: add KFENCE documentation

2020-09-08 Thread Marco Elver
On Tue, Sep 08, 2020 at 08:54AM -0700, Dave Hansen wrote: > On 9/7/20 6:40 AM, Marco Elver wrote: > > +The most important parameter is KFENCE's sample interval, which can be set > > via > > +the kernel boot parameter ``kfence.sample_interval`` in milliseconds. The >

Re: [PATCH RFC 00/10] KFENCE: A low-overhead sampling-based memory safety error detector

2020-09-08 Thread Marco Elver
On Tue, Sep 08, 2020 at 07:52AM -0700, Dave Hansen wrote: > On 9/7/20 6:40 AM, Marco Elver wrote: > > KFENCE is designed to be enabled in production kernels, and has near > > zero performance overhead. Compared to KASAN, KFENCE trades performance > > for precision. > &

Re: [PATCH RFC 00/10] KFENCE: A low-overhead sampling-based memory safety error detector

2020-09-08 Thread Marco Elver
On Tue, Sep 08, 2020 at 04:40PM +0200, Vlastimil Babka wrote: > On 9/8/20 2:16 PM, Alexander Potapenko wrote: > >> Toggling a static branch is AFAIK quite disruptive (PeterZ will probably > >> tell > >> you better), and with the default 100ms sample interval, I'd think it's > >> not good > >> to

[PATCH] bitops, kcsan: Partially revert instrumentation for non-atomic bitops

2020-08-13 Thread Marco Elver
ke sense to introduce yet another special case to KCSAN's runtime, only to cater to the case here. Signed-off-by: Marco Elver Cc: Dmitry Vyukov Cc: Paul E. McKenney Cc: Will Deacon --- As discussed, partially reverting behaviour for non-atomic bitops when KCSAN_ASSUME_PLAIN_WRITES_ATOMIC is sel

Re: [PATCH 8/8] locking/atomics: Use read-write instrumentation for atomic RMWs

2020-08-14 Thread Marco Elver
On Fri, 14 Aug 2020 at 13:31, Mark Rutland wrote: > On Fri, Aug 14, 2020 at 12:28:26PM +0100, Mark Rutland wrote: > > Hi, > > > > Sorry to come to this rather late -- this comment equally applies to v2 > > so I'm replying here to have context. > > ... and now I see that was already applied, so ple

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

2020-10-14 Thread Marco Elver
On Thu, 8 Oct 2020 at 12:45, Mark Rutland wrote: > On Thu, Oct 08, 2020 at 11:40:52AM +0200, Marco Elver wrote: > > On Thu, 1 Oct 2020 at 19:58, Mark Rutland wrote: > > [...] > > > > > If you need virt_to_page() to work, the address has to be part of t

Re: [PATCH RFC 5/8] kasan: mark kasan_init_tags as __init

2020-10-15 Thread Marco Elver
On Wed, 14 Oct 2020 at 22:44, Andrey Konovalov wrote: > > Similarly to kasan_init() mark kasan_init_tags() as __init. > > Signed-off-by: Andrey Konovalov > Link: > https://linux-review.googlesource.com/id/I8792e22f1ca5a703c5e979969147968a99312558 > --- > include/linux/kasan.h | 4 ++-- > mm/kas

Re: [PATCH RFC 8/8] kasan: add and integrate kasan_mode boot param

2020-10-15 Thread Marco Elver
On Wed, 14 Oct 2020 at 22:45, Andrey Konovalov wrote: > > TODO: no meaningful description here yet, please see the cover letter > for this RFC series. > > Signed-off-by: Andrey Konovalov > Link: > https://linux-review.googlesource.com/id/If7d37003875b2ed3e0935702c8015c223d6416a4 > --- > m

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

2020-10-15 Thread Marco Elver
On Thu, 15 Oct 2020 at 15:39, Mark Rutland wrote: > On Wed, Oct 14, 2020 at 09:12:37PM +0200, Marco Elver wrote: > > On Thu, 8 Oct 2020 at 12:45, Mark Rutland wrote: > > > On Thu, Oct 08, 2020 at 11:40:52AM +0200, Marco Elver wrote: > > > > On Thu, 1 Oct 2020

Re: [PATCH RFC 0/8] kasan: hardware tag-based mode for production use on arm64

2020-10-15 Thread Marco Elver
On Wed, 14 Oct 2020 at 22:44, Andrey Konovalov wrote: > This patchset is not complete (see particular TODOs in the last patch), > and I haven't performed any benchmarking yet, but I would like to start the > discussion now and hear people's opinions regarding the questions mentioned > below. > > =

Re: [PATCH v3 1/2] kunit: Support for Parameterized Testing

2020-10-27 Thread Marco Elver
On Tue, 27 Oct 2020 at 06:14, Arpitha Raghunandan <98.a...@gmail.com> wrote: [...] > >> diff --git a/include/kunit/test.h b/include/kunit/test.h > >> index a423fffefea0..16bf9f334e2c 100644 > >> --- a/include/kunit/test.h > >> +++ b/include/kunit/test.h > >> @@ -142,6 +142,12 @@ struct kunit_case {

Re: [PATCH v3 1/2] kunit: Support for Parameterized Testing

2020-10-27 Thread Marco Elver
On Mon, 26 Oct 2020 at 19:36, Arpitha Raghunandan <98.a...@gmail.com> wrote: [...] > * success starts as true, and may only be set to false during a > * test case; thus, it is safe to update this across multiple > @@ -1742,4 +1760,18 @@ do {

Re: [PATCH v3 1/2] kunit: Support for Parameterized Testing

2020-10-27 Thread Marco Elver
I just tried to give this a spin on some of my tests and noticed some more things (apologies for the multiple rounds of comments): On Mon, 26 Oct 2020 at 19:36, Arpitha Raghunandan <98.a...@gmail.com> wrote: [...] > /** > * struct kunit_suite - describes a related collection of &struct kunit_ca

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

2020-10-27 Thread Marco Elver
ways_inline. Reviewed-by: Dmitry Vyukov Co-developed-by: Marco Elver Signed-off-by: Marco Elver Signed-off-by: Alexander Potapenko --- v5: * Fix obj_to_index for kfence objects. v3: * Rewrite patch description to clarify need for 'orig_size' [reported by Christopher Lameter]. --- i

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

2020-10-27 Thread Marco Elver
k Co-developed-by: Marco Elver Signed-off-by: Marco Elver Signed-off-by: Alexander Potapenko --- v5: * MAJOR CHANGE: Removal of HAVE_ARCH_KFENCE_STATIC_POOL and static pool support in favor of memblock_alloc'd pool only, as it avoids all issues with virt_to translations.

Re: [PATCH -next] treewide: Remove stringification from __alias macro definition

2020-10-21 Thread Marco Elver
++-- > mm/kasan/generic.c | 8 ++++ > 8 files changed, 19 insertions(+), 19 deletions(-) Reviewed-by: Marco Elver for KCSAN and KASAN. Thank you! > diff --git a/arch/x86/boot/compressed/string.c > b/arch/x86/boot/compressed/string.c > index 81fc1eaa3

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

2020-10-27 Thread Marco Elver
LEAK compatibility patch. RFC/v1: https://lkml.kernel.org/r/20200907134055.2878499-1-el...@google.com Alexander Potapenko (5): mm: add Kernel Electric-Fence infrastructure x86, kfence: enable KFENCE for x86 mm, kfence: insert KFENCE hooks for SLAB mm, kfence: insert KFENCE hooks for SLUB kfence, kasan:

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

2020-10-27 Thread Marco Elver
-by: Alexander Potapenko Signed-off-by: Alexander Potapenko Signed-off-by: Marco Elver --- v5: * Move generic page allocation code to core.c [suggested by Jann Horn]. * Remove comment about HAVE_ARCH_KFENCE_STATIC_POOL, since we no longer support static pools. * Force page granularity for the

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

2020-10-27 Thread Marco Elver
ed-by: Alexander Potapenko Signed-off-by: Alexander Potapenko Signed-off-by: Marco Elver --- 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 size to avoid warnings of using more than 1024

[PATCH v5 9/9] MAINTAINERS: Add entry for KFENCE

2020-10-27 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 --- v4: * Split out from first patch. --- MAINTAINERS | 11 +++ 1 file changed, 11 insertions

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

2020-10-27 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 --- v5: * MAJOR CHANGE: Switch to the memblock_alloc'd pool. Ru

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

2020-10-27 Thread Marco Elver
ways_inline. Reviewed-by: Dmitry Vyukov Co-developed-by: Marco Elver Signed-off-by: Marco Elver Signed-off-by: Alexander Potapenko --- v5: * New kfence_shutdown_cache(): we need to defer kfence_shutdown_cache() to before the cache is actually freed. In case of SLAB_TYPESAFE_BY_RCU, the obj

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

2020-10-27 Thread Marco Elver
of the two is generally discouraged, CONFIG_EXPERT=y should be set. It also gives us the nice property that KFENCE will be build-tested by allyesconfig builds. Reviewed-by: Dmitry Vyukov Co-developed-by: Marco Elver Signed-off-by: Marco Elver Signed-off-by: Alexander Potapenko --- v5: * Also

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

2020-10-27 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 --- v3: * Re-introduce reference to Documentation/dev-tools/kfence.rst. v2: * Many clarifications

Re: [PATCH v4 1/2] kunit: Support for Parameterized Testing

2020-10-27 Thread Marco Elver
. > This generator function should return the next parameter given the > previous parameter in parameterized tests. It also provides > a macro to generate common-case generators. > > Signed-off-by: Arpitha Raghunandan <98.a...@gmail.com> > Co-developed-by: Marco Elver > Signe

Re: Recording allocation location for blocks of memory?

2020-10-27 Thread Marco Elver
Hi Paul, Let me add another option below, as an alternative to KASAN that Dmitry mentioned. On Tue, 27 Oct 2020 at 19:40, Dmitry Vyukov wrote: > On Tue, Oct 27, 2020 at 6:58 PM Paul E. McKenney wrote: > > > > Hello! > > > > I have vague memories of some facility some time some where that record

Re: [PATCH v4 2/2] fs: ext4: Modify inode-test.c to use KUnit parameterized testing feature

2020-10-28 Thread Marco Elver
On Wed, 28 Oct 2020 at 00:50, kernel test robot wrote: > > Hi Arpitha, > > Thank you for the patch! Perhaps something to improve: > > [auto build test WARNING on ext4/dev] > [also build test WARNING on linus/master v5.10-rc1 next-20201027] > [If your patch is applied to the wrong git tree, kindly

[PATCH] kcsan: Never set up watchpoints on NULL pointers

2020-10-22 Thread Marco Elver
Avoid setting up watchpoints on NULL pointers, as otherwise we would crash inside the KCSAN runtime (when checking for value changes) instead of the instrumented code. Because that may be confusing, skip any address less than PAGE_SIZE. Signed-off-by: Marco Elver --- kernel/kcsan/encoding.h

[PATCH v2 1/2] kcsan: selftest: Ensure that address is at least PAGE_SIZE

2020-10-22 Thread Marco Elver
In preparation of supporting only addresses not within the NULL page, change the selftest to never use addresses that are less than PAGE_SIZE. Signed-off-by: Marco Elver --- v2: * Introduce patch to series. --- kernel/kcsan/selftest.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a

[PATCH v2 2/2] kcsan: Never set up watchpoints on NULL pointers

2020-10-22 Thread Marco Elver
Avoid setting up watchpoints on NULL pointers, as otherwise we would crash inside the KCSAN runtime (when checking for value changes) instead of the instrumented code. Because that may be confusing, skip any address less than PAGE_SIZE. Signed-off-by: Marco Elver --- kernel/kcsan/encoding.h

Re: [PATCH] kcsan: Never set up watchpoints on NULL pointers

2020-10-22 Thread Marco Elver
On Thu, 22 Oct 2020 at 13:30, Marco Elver wrote: > > Avoid setting up watchpoints on NULL pointers, as otherwise we would > crash inside the KCSAN runtime (when checking for value changes) instead > of the instrumented code. > > Because that may be confusing, skip any address l

Re: [PATCH RFC v2 14/21] kasan: add and integrate kasan boot parameters

2020-10-22 Thread Marco Elver
On Thu, 22 Oct 2020 at 15:19, Andrey Konovalov wrote: > > TODO: no meaningful description here yet, please see the cover letter > for this RFC series. > > Signed-off-by: Andrey Konovalov > Link: > https://linux-review.googlesource.com/id/If7d37003875b2ed3e0935702c8015c223d6416a4 > --- > m

[PATCH] kcsan: Fix encoding masks and regain address bit

2020-10-23 Thread Marco Elver
expected, since that extra address bit is insignificant for enabled architectures. Signed-off-by: Marco Elver --- kernel/kcsan/encoding.h | 14 ++ 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/kernel/kcsan/encoding.h b/kernel/kcsan/encoding.h index 64b3c0f2a685..fc5154dd2475

Re: [PATCH v2 1/2] kunit: Support for Parameterized Testing

2020-10-23 Thread Marco Elver
struct kunit *test, void *prev) \ + { \ + typeof((array)[0]) *__next = prev ? ((typeof(__next)) prev) + 1 : (array); \ + return __next - (array) < ARR

Re: [PATCH v2 1/2] kunit: Support for Parameterized Testing

2020-10-23 Thread Marco Elver
On Fri, 23 Oct 2020 at 20:48, Marco Elver wrote: [...] > > + */ > > +static inline void *kunit_param_generator_helper(struct kunit *test, > > I don't think this needs to be inline, but see my other suggestion > below, which might make this function obsolete. Ah sor

Re: [PATCH v3 1/2] kunit: Support for Parameterized Testing

2020-10-26 Thread Marco Elver
. > This generator function should return the next parameter given the > previous parameter in parameterized tests. It also provides > a macro to generate common-case generators. > > Signed-off-by: Arpitha Raghunandan <98.a...@gmail.com> > Co-developed-by: Marco Elver > Signe

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

2020-10-29 Thread Marco Elver
k Co-developed-by: Marco Elver Signed-off-by: Marco Elver Signed-off-by: Alexander Potapenko --- v6: * Record allocation and free task pids, and show them in reports. This information helps more easily identify e.g. racy use-after-frees. v5: * MAJOR CHANGE: Removal of HAVE_ARCH_KFENCE_ST

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

2020-10-29 Thread Marco Elver
om Alexander Potapenko (5): mm: add Kernel Electric-Fence infrastructure x86, kfence: enable KFENCE for x86 mm, kfence: insert 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 ARM6

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

2020-10-29 Thread Marco Elver
ed-by: Alexander Potapenko Signed-off-by: Alexander Potapenko Signed-off-by: Marco Elver --- 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 size to avoid warnings of using more than 1024

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

2020-10-29 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 --- v5: * MAJOR CHANGE: Switch to the memblock_alloc'd pool. Ru

[PATCH v6 9/9] MAINTAINERS: Add entry for KFENCE

2020-10-29 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 --- v4: * Split out from first patch. --- MAINTAINERS | 11 +++ 1 file changed, 11 insertions

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

2020-10-29 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 --- v3: * Re-introduce reference to Documentation/dev-tools/kfence.rst. v2: * Many clarifications

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

2020-10-29 Thread Marco Elver
ways_inline. Reviewed-by: Dmitry Vyukov Co-developed-by: Marco Elver Signed-off-by: Marco Elver Signed-off-by: Alexander Potapenko --- v5: * Fix obj_to_index for kfence objects. v3: * Rewrite patch description to clarify need for 'orig_size' [reported by Christopher Lameter]. --- i

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

2020-10-29 Thread Marco Elver
of the two is generally discouraged, CONFIG_EXPERT=y should be set. It also gives us the nice property that KFENCE will be build-tested by allyesconfig builds. Reviewed-by: Dmitry Vyukov Co-developed-by: Marco Elver Signed-off-by: Marco Elver Signed-off-by: Alexander Potapenko --- v5: * Also

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

2020-10-29 Thread Marco Elver
ways_inline. Reviewed-by: Dmitry Vyukov Co-developed-by: Marco Elver Signed-off-by: Marco Elver Signed-off-by: Alexander Potapenko --- v5: * New kfence_shutdown_cache(): we need to defer kfence_shutdown_cache() to before the cache is actually freed. In case of SLAB_TYPESAFE_BY_RCU, the obj

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

2020-10-29 Thread Marco Elver
-by: Alexander Potapenko Signed-off-by: Alexander Potapenko Signed-off-by: Marco Elver --- v5: * Move generic page allocation code to core.c [suggested by Jann Horn]. * Remove comment about HAVE_ARCH_KFENCE_STATIC_POOL, since we no longer support static pools. * Force page granularity for the

Re: [PATCH v5 3/3] mac80211: add KCOV remote annotations to incoming frame processing

2020-10-29 Thread Marco Elver
On Thu, 29 Oct 2020 at 18:44, Johannes Berg wrote: > On Thu, 2020-10-29 at 17:36 +, Aleksandr Nogikh wrote: > > From: Aleksandr Nogikh > > > > Add KCOV remote annotations to ieee80211_iface_work() and > > ieee80211_rx_list(). This will enable coverage-guided fuzzing of > > mac80211 code that

Re: [PATCH v6 8/9] kfence: add test suite

2020-10-30 Thread Marco Elver
On Fri, 30 Oct 2020 at 03:50, Jann Horn wrote: > > On Thu, Oct 29, 2020 at 2:17 PM Marco Elver wrote: > > Add KFENCE test suite, testing various error detection scenarios. Makes > > use of KUnit for test organization. Since KFENCE's interface to obtain > > error re

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

2020-10-30 Thread Marco Elver
On Fri, 30 Oct 2020 at 03:49, Jann Horn wrote: > On Thu, Oct 29, 2020 at 2:16 PM Marco Elver wrote: > > This adds the Kernel Electric-Fence (KFENCE) infrastructure. KFENCE is a > > low-overhead sampling-based memory safety error detector of heap > > use-after-free, inv

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

2020-10-30 Thread Marco Elver
On Fri, 30 Oct 2020 at 03:49, Jann Horn wrote: > On Thu, Oct 29, 2020 at 2:17 PM Marco Elver wrote: > > Add architecture specific implementation details for KFENCE and enable > > KFENCE for the x86 architecture. In particular, this implements the > > required interface i

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

2020-10-30 Thread Marco Elver
On Fri, 30 Oct 2020 at 03:50, Jann Horn wrote: > > On Thu, Oct 29, 2020 at 2:17 PM Marco Elver wrote: > > We make KFENCE compatible with KASAN for testing KFENCE itself. In > > particular, KASAN helps to catch any potential corruptions to KFENCE > > state, or other c

Re: [PATCH RFC v2 14/21] kasan: add and integrate kasan boot parameters

2020-10-30 Thread Marco Elver
On Thu, 22 Oct 2020 at 15:19, Andrey Konovalov wrote: > > TODO: no meaningful description here yet, please see the cover letter > for this RFC series. > > Signed-off-by: Andrey Konovalov > Link: > https://linux-review.googlesource.com/id/If7d37003875b2ed3e0935702c8015c223d6416a4 > --- > m

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

2020-10-30 Thread Marco Elver
On Fri, 30 Oct 2020 at 16:09, Jann Horn wrote: > > On Fri, Oct 30, 2020 at 2:46 PM Marco Elver wrote: > > On Fri, 30 Oct 2020 at 03:50, Jann Horn wrote: > > > On Thu, Oct 29, 2020 at 2:17 PM Marco Elver wrote: > > > > We make KFENCE compatible with KA

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

2020-10-30 Thread Marco Elver
On Fri, 30 Oct 2020 at 03:49, Jann Horn wrote: > On Thu, Oct 29, 2020 at 2:17 PM Marco Elver wrote: > > Inserts KFENCE hooks into the SLAB allocator. > [...] > > diff --git a/mm/slab.c b/mm/slab.c > [...] > > @@ -3416,6 +3427,11 @@ static void cache_flusharray(str

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

2020-10-30 Thread Marco Elver
On Fri, 30 Oct 2020 at 16:47, Mark Rutland wrote: > > On Thu, Oct 29, 2020 at 02:16:43PM +0100, Marco Elver wrote: > > Add architecture specific implementation details for KFENCE and enable > > KFENCE for the arm64 architecture. In particular, this implements the > &g

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

2020-10-30 Thread Marco Elver
On Fri, 30 Oct 2020 at 03:49, Jann Horn wrote: > On Thu, Oct 29, 2020 at 2:17 PM Marco Elver wrote: > > This adds the Kernel Electric-Fence (KFENCE) infrastructure. KFENCE is a > > low-overhead sampling-based memory safety error detector of heap > > use-after-free, inv

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