All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH RFC 04/10] mm, kfence: insert KFENCE hooks for SLAB
@ 2020-09-08  1:45 kernel test robot
  0 siblings, 0 replies; 13+ messages in thread
From: kernel test robot @ 2020-09-08  1:45 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 7981 bytes --]

CC: kbuild-all(a)lists.01.org
In-Reply-To: <20200907134055.2878499-5-elver@google.com>
References: <20200907134055.2878499-5-elver@google.com>
TO: Marco Elver <elver@google.com>

Hi Marco,

[FYI, it's a private test report for your RFC patch.]
[auto build test WARNING on hnaz-linux-mm/master]
[also build test WARNING on arm64/for-next/core linus/master v5.9-rc4 next-20200903]
[cannot apply to tip/x86/core]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Marco-Elver/KFENCE-A-low-overhead-sampling-based-memory-safety-error-detector/20200907-214229
base:   https://github.com/hnaz/linux-mm master
:::::: branch date: 12 hours ago
:::::: commit date: 12 hours ago
compiler: powerpc-linux-gcc (GCC) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>


cppcheck warnings: (new ones prefixed by >>)

   mm/slab.c:906:6: warning: Variable 'ret' is reassigned a value before the old one has been used. [redundantAssignment]
    ret = init_cache_node(cachep, node, gfp);
        ^
   mm/slab.c:886:0: note: Variable 'ret' is reassigned a value before the old one has been used.
    int ret = -ENOMEM;
   ^
   mm/slab.c:906:6: note: Variable 'ret' is reassigned a value before the old one has been used.
    ret = init_cache_node(cachep, node, gfp);
        ^
   mm/slab.c:3316:7: warning: Redundant assignment of 'objp' to itself. [selfAssignment]
    objp = cache_alloc_debugcheck_after(cachep, flags, objp, caller);
         ^
   mm/slab.c:3454:7: warning: Redundant assignment of 'objp' to itself. [selfAssignment]
    objp = cache_free_debugcheck(cachep, objp, caller);
         ^
   mm/slab.c:3514:8: warning: Redundant assignment of 'p[i]' to itself. [selfAssignment]
     p[i] = cache_alloc_debugcheck_after(s, flags, p[i], caller);
          ^
   mm/slab.c:3342:16: warning: Local variable page shadows outer variable [shadowVar]
     struct page *page;
                  ^
   mm/slab.c:3336:15: note: Shadowed declaration
    struct page *page;
                 ^
   mm/slab.c:3342:16: note: Shadow variable
     struct page *page;
                  ^
>> mm/slab.c:3872:12: warning: Same expression on both sides of '&&' because 'limit' and 'shared' represent the same value. [knownConditionTrueFalse]
    if (limit && shared && batchcount)
              ^
   mm/slab.c:3864:14: note: 'limit' is assigned value '0' here.
    int limit = 0;
                ^
   mm/slab.c:3865:15: note: 'shared' is assigned value '0' here.
    int shared = 0;
                 ^
   mm/slab.c:3872:12: note: Same expression on both sides of '&&' because 'limit' and 'shared' represent the same value.
    if (limit && shared && batchcount)
              ^
>> mm/slab.c:3872:22: warning: Same expression on both sides of '&&' because 'batchcount' and 'shared' represent the same value. [knownConditionTrueFalse]
    if (limit && shared && batchcount)
                        ^
   mm/slab.c:3866:19: note: 'batchcount' is assigned value '0' here.
    int batchcount = 0;
                     ^
   mm/slab.c:3865:15: note: 'shared' is assigned value '0' here.
    int shared = 0;
                 ^
   mm/slab.c:3872:22: note: Same expression on both sides of '&&' because 'batchcount' and 'shared' represent the same value.
    if (limit && shared && batchcount)
                        ^

# https://github.com/0day-ci/linux/commit/62475f64212ac70b313ca25aeaf677151914ac00
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Marco-Elver/KFENCE-A-low-overhead-sampling-based-memory-safety-error-detector/20200907-214229
git checkout 62475f64212ac70b313ca25aeaf677151914ac00
vim +3872 mm/slab.c

^1da177e4c3f41 Linus Torvalds    2005-04-16  3859  
18004c5d4084d9 Christoph Lameter 2012-07-06  3860  /* Called with slab_mutex held always */
83b519e8b9572c Pekka Enberg      2009-06-10  3861  static int enable_cpucache(struct kmem_cache *cachep, gfp_t gfp)
^1da177e4c3f41 Linus Torvalds    2005-04-16  3862  {
^1da177e4c3f41 Linus Torvalds    2005-04-16  3863  	int err;
943a451a87d229 Glauber Costa     2012-12-18  3864  	int limit = 0;
943a451a87d229 Glauber Costa     2012-12-18  3865  	int shared = 0;
943a451a87d229 Glauber Costa     2012-12-18  3866  	int batchcount = 0;
943a451a87d229 Glauber Costa     2012-12-18  3867  
7c00fce98c3e15 Thomas Garnier    2016-07-26  3868  	err = cache_random_seq_create(cachep, cachep->num, gfp);
c7ce4f60ac199f Thomas Garnier    2016-05-19  3869  	if (err)
c7ce4f60ac199f Thomas Garnier    2016-05-19  3870  		goto end;
c7ce4f60ac199f Thomas Garnier    2016-05-19  3871  
943a451a87d229 Glauber Costa     2012-12-18 @3872  	if (limit && shared && batchcount)
943a451a87d229 Glauber Costa     2012-12-18  3873  		goto skip_setup;
a737b3e2fcf96f Andrew Morton     2006-03-22  3874  	/*
a737b3e2fcf96f Andrew Morton     2006-03-22  3875  	 * The head array serves three purposes:
^1da177e4c3f41 Linus Torvalds    2005-04-16  3876  	 * - create a LIFO ordering, i.e. return objects that are cache-warm
^1da177e4c3f41 Linus Torvalds    2005-04-16  3877  	 * - reduce the number of spinlock operations.
^1da177e4c3f41 Linus Torvalds    2005-04-16  3878  	 * - reduce the number of linked list operations on the slab and
^1da177e4c3f41 Linus Torvalds    2005-04-16  3879  	 *   bufctl chains: array operations are cheaper.
^1da177e4c3f41 Linus Torvalds    2005-04-16  3880  	 * The numbers are guessed, we should auto-tune as described by
^1da177e4c3f41 Linus Torvalds    2005-04-16  3881  	 * Bonwick.
^1da177e4c3f41 Linus Torvalds    2005-04-16  3882  	 */
3b0efdfa1e7193 Christoph Lameter 2012-06-13  3883  	if (cachep->size > 131072)
^1da177e4c3f41 Linus Torvalds    2005-04-16  3884  		limit = 1;
3b0efdfa1e7193 Christoph Lameter 2012-06-13  3885  	else if (cachep->size > PAGE_SIZE)
^1da177e4c3f41 Linus Torvalds    2005-04-16  3886  		limit = 8;
3b0efdfa1e7193 Christoph Lameter 2012-06-13  3887  	else if (cachep->size > 1024)
^1da177e4c3f41 Linus Torvalds    2005-04-16  3888  		limit = 24;
3b0efdfa1e7193 Christoph Lameter 2012-06-13  3889  	else if (cachep->size > 256)
^1da177e4c3f41 Linus Torvalds    2005-04-16  3890  		limit = 54;
^1da177e4c3f41 Linus Torvalds    2005-04-16  3891  	else
^1da177e4c3f41 Linus Torvalds    2005-04-16  3892  		limit = 120;
^1da177e4c3f41 Linus Torvalds    2005-04-16  3893  
a737b3e2fcf96f Andrew Morton     2006-03-22  3894  	/*
a737b3e2fcf96f Andrew Morton     2006-03-22  3895  	 * CPU bound tasks (e.g. network routing) can exhibit cpu bound
^1da177e4c3f41 Linus Torvalds    2005-04-16  3896  	 * allocation behaviour: Most allocs on one cpu, most free operations
^1da177e4c3f41 Linus Torvalds    2005-04-16  3897  	 * on another cpu. For these cases, an efficient object passing between
^1da177e4c3f41 Linus Torvalds    2005-04-16  3898  	 * cpus is necessary. This is provided by a shared array. The array
^1da177e4c3f41 Linus Torvalds    2005-04-16  3899  	 * replaces Bonwick's magazine layer.
^1da177e4c3f41 Linus Torvalds    2005-04-16  3900  	 * On uniprocessor, it's functionally equivalent (but less efficient)
^1da177e4c3f41 Linus Torvalds    2005-04-16  3901  	 * to a larger limit. Thus disabled by default.
^1da177e4c3f41 Linus Torvalds    2005-04-16  3902  	 */
^1da177e4c3f41 Linus Torvalds    2005-04-16  3903  	shared = 0;
3b0efdfa1e7193 Christoph Lameter 2012-06-13  3904  	if (cachep->size <= PAGE_SIZE && num_possible_cpus() > 1)
^1da177e4c3f41 Linus Torvalds    2005-04-16  3905  		shared = 8;
^1da177e4c3f41 Linus Torvalds    2005-04-16  3906  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

^ permalink raw reply	[flat|nested] 13+ messages in thread
* [PATCH RFC 00/10] KFENCE: A low-overhead sampling-based memory safety error detector
@ 2020-09-07 13:40 Marco Elver
  2020-09-07 13:40   ` Marco Elver
  0 siblings, 1 reply; 13+ messages in thread
From: Marco Elver @ 2020-09-07 13:40 UTC (permalink / raw)
  To: elver, glider, akpm, catalin.marinas, cl, rientjes,
	iamjoonsoo.kim, mark.rutland, penberg
  Cc: hpa, paulmck, andreyknvl, aryabinin, luto, bp, dave.hansen,
	dvyukov, edumazet, gregkh, mingo, jannh, corbet, keescook,
	peterz, cai, tglx, will, x86, linux-doc, linux-kernel, kasan-dev,
	linux-arm-kernel, linux-mm

This adds the Kernel Electric-Fence (KFENCE) infrastructure. KFENCE is a
low-overhead sampling-based memory safety error detector of heap
use-after-free, invalid-free, and out-of-bounds access errors.  This
series enables KFENCE for the x86 and arm64 architectures, and adds
KFENCE hooks to the SLAB and SLUB allocators.

KFENCE is designed to be enabled in production kernels, and has near
zero performance overhead. Compared to KASAN, KFENCE trades performance
for precision. The main motivation behind KFENCE's design, is that with
enough total uptime KFENCE will detect bugs in code paths not typically
exercised by non-production test workloads. One way to quickly achieve a
large enough total uptime is when the tool is deployed across a large
fleet of machines.

KFENCE objects each reside on a dedicated page, at either the left or
right page boundaries. The pages to the left and right of the object
page are "guard pages", whose attributes are changed to a protected
state, and cause page faults on any attempted access to them. Such page
faults are then intercepted by KFENCE, which handles the fault
gracefully by reporting a memory access error.

Guarded allocations are set up based on a sample interval (can be set
via kfence.sample_interval). After expiration of the sample interval, a
guarded allocation from the KFENCE object pool is returned to the main
allocator (SLAB or SLUB). At this point, the timer is reset, and the
next allocation is set up after the expiration of the interval.

To enable/disable a KFENCE allocation through the main allocator's
fast-path without overhead, KFENCE relies on static branches via the
static keys infrastructure. The static branch is toggled to redirect the
allocation to KFENCE.

We have verified by running synthetic benchmarks (sysbench I/O,
hackbench) that a kernel with KFENCE is performance-neutral compared to
a non-KFENCE baseline kernel.

KFENCE is inspired by GWP-ASan [1], a userspace tool with similar
properties. The name "KFENCE" is a homage to the Electric Fence Malloc
Debugger [2].

For more details, see Documentation/dev-tools/kfence.rst added in the
series -- also viewable here:

	https://raw.githubusercontent.com/google/kasan/kfence/Documentation/dev-tools/kfence.rst

[1] http://llvm.org/docs/GwpAsan.html
[2] https://linux.die.net/man/3/efence

Alexander Potapenko (6):
  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, kfence: enable KFENCE for ARM64
  kfence, lockdep: make KFENCE compatible with lockdep
  kfence, Documentation: add KFENCE documentation
  kfence: add test suite

 Documentation/dev-tools/index.rst  |   1 +
 Documentation/dev-tools/kfence.rst | 285 +++++++++++
 MAINTAINERS                        |  11 +
 arch/arm64/Kconfig                 |   1 +
 arch/arm64/include/asm/kfence.h    |  39 ++
 arch/arm64/mm/fault.c              |   4 +
 arch/x86/Kconfig                   |   2 +
 arch/x86/include/asm/kfence.h      |  60 +++
 arch/x86/mm/fault.c                |   4 +
 include/linux/kfence.h             | 174 +++++++
 init/main.c                        |   2 +
 kernel/locking/lockdep.c           |   8 +
 lib/Kconfig.debug                  |   1 +
 lib/Kconfig.kfence                 |  70 +++
 mm/Makefile                        |   1 +
 mm/kasan/common.c                  |   7 +
 mm/kfence/Makefile                 |   6 +
 mm/kfence/core.c                   | 730 +++++++++++++++++++++++++++
 mm/kfence/kfence-test.c            | 777 +++++++++++++++++++++++++++++
 mm/kfence/kfence.h                 | 104 ++++
 mm/kfence/report.c                 | 201 ++++++++
 mm/kmemleak.c                      |  11 +
 mm/slab.c                          |  46 +-
 mm/slab_common.c                   |   6 +-
 mm/slub.c                          |  72 ++-
 25 files changed, 2591 insertions(+), 32 deletions(-)
 create mode 100644 Documentation/dev-tools/kfence.rst
 create mode 100644 arch/arm64/include/asm/kfence.h
 create mode 100644 arch/x86/include/asm/kfence.h
 create mode 100644 include/linux/kfence.h
 create mode 100644 lib/Kconfig.kfence
 create mode 100644 mm/kfence/Makefile
 create mode 100644 mm/kfence/core.c
 create mode 100644 mm/kfence/kfence-test.c
 create mode 100644 mm/kfence/kfence.h
 create mode 100644 mm/kfence/report.c

-- 
2.28.0.526.ge36021eeef-goog


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

end of thread, other threads:[~2020-09-11 14:44 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-08  1:45 [PATCH RFC 04/10] mm, kfence: insert KFENCE hooks for SLAB kernel test robot
  -- strict thread matches above, loose matches on Subject: below --
2020-09-07 13:40 [PATCH RFC 00/10] KFENCE: A low-overhead sampling-based memory safety error detector Marco Elver
2020-09-07 13:40 ` [PATCH RFC 04/10] mm, kfence: insert KFENCE hooks for SLAB Marco Elver
2020-09-07 13:40   ` Marco Elver
2020-09-07 13:40   ` Marco Elver
2020-09-11  7:17   ` Dmitry Vyukov
2020-09-11  7:17     ` Dmitry Vyukov
2020-09-11  7:17     ` Dmitry Vyukov
2020-09-11 12:24     ` Marco Elver
2020-09-11 12:24       ` Marco Elver
2020-09-11 12:24       ` Marco Elver
2020-09-11 13:03       ` Dmitry Vyukov
2020-09-11 13:03         ` Dmitry Vyukov
2020-09-11 13:03         ` Dmitry Vyukov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.