Skip to content

kasan: optimizations and fixes for HW_TAGS

Andrey Konovalov linux-arm-kernel linux-mm lkml 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest13 patches 4 repliesIn review 11 of 13 applied
  2. v212 patches 4 repliesSuperseded
  3. v112 patches 22 repliesSuperseded

Changes in v3 from the cover letter

- Rebased onto mm.
- Add documentation update patch.

Patches in v3 11 of 13 applied

#Subject and filesSizeRepliesApplied
1/13kasan, mm: don't save alloc stacks twiceinclude/linux/kasan.h mm/kasan/common.c mm/slab_common.c+24 -40 replies
2/13kasan, mm: optimize kmalloc poisoningmm/kasan/common.c mm/kasan/kasan.h mm/kasan/shadow.c +1 more+119 -480 repliesApplied
3/13kasan: optimize large kmalloc poisoningmm/kasan/common.c+15 -50 repliesApplied
4/13kasan: clean up setting free info in kasan_slab_freemm/kasan/common.c+2 -40 repliesApplied
5/13kasan: unify large kfree checksinclude/linux/kasan.h mm/kasan/common.c+34 -180 repliesApplied
6/13kasan: rework krealloc testslib/test_kasan.c+81 -100 repliesApplied
7/13kasan, mm: fail krealloc on freed objectslib/test_kasan.c mm/slab_common.c+23 -00 repliesApplied
8/13kasan, mm: optimize krealloc poisoningmm/kasan/common.c mm/slab_common.c+24 -82 repliesApplied
9/13kasan: ensure poisoning size alignmentmm/kasan/common.c mm/kasan/kasan.h mm/kasan/shadow.c+48 -310 repliesApplied
10/13arm64: kasan: simplify and inline MTE functionsarch/arm64/include/asm/cache.h arch/arm64/include/asm/kasan.h arch/arm64/include/asm/mte-def.h +4 more+60 -730 repliesApplied
11/13kasan: inline HW_TAGS helper functionsmm/kasan/common.c+7 -61 replyApplied
12/13arm64: kasan: export MTE symbols for KASAN testsarch/arm64/kernel/mte.c+2 -00 replies
13/13kasan: clarify that only first bug is reported in HW_TAGSDocumentation/dev-tools/kasan.rst mm/kasan/hw_tags.c+7 -31 replyApplied

Reviews trailers per patch

All 13 patches have a Reviewed-by or Acked-by.

PatchMarco ElverCatalin Marinas
1/13R-b
2/13R-b
3/13R-b
4/13R-b
5/13R-b
6/13R-b
7/13R-b
8/13R-b
9/13R-b
10/13R-b
11/13R-b
12/13R-b
13/13R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v3 thread

Cover letter [PATCH v3 mm 00/13] kasan: optimizations and fixes for HW_TAGS

This patchset makes the HW_TAGS mode more efficient, mostly by reworking poisoning approaches and simplifying/inlining some internal helpers.

With this change, the overhead of HW_TAGS annotations excluding setting and checking memory tags is ~3%. The performance impact caused by tags will be unknown until we have hardware that supports MTE.

As a side-effect, this patchset speeds up generic KASAN by ~15%.

Changes v2->v3:
- Rebased onto mm.
- Add documentation update patch.

Changes v1->v2:
- Use EXPORT_SYMBOL_GPL() for arm64 symbols.
- Rename kmalloc bool flag argument to is_kmalloc.
- Make empty mte_set_mem_tag_range() return void.
- Fix build warning in 32-bit systems by using unsigned long instead of u64 in WARN_ON() checks.
- Minor changes in comments and commit descriptions.
- Use kfence_ksize() before __ksize() to avoid crashes with KFENCE.
- Use inline instead of __always_inline.

Andrey Konovalov (13):
kasan, mm: don't save alloc stacks twice
kasan, mm: optimize kmalloc poisoning
kasan: optimize large kmalloc poisoning
kasan: clean up setting free info in kasan_slab_free
kasan: unify large kfree checks
kasan: rework krealloc tests
kasan, mm: fail krealloc on freed objects
kasan, mm: optimize krealloc poisoning
kasan: ensure poisoning size alignment
arm64: kasan: simplify and inline MTE functions
kasan: inline HW_TAGS helper functions
arm64: kasan: export MTE symbols for KASAN tests
kasan: clarify that only first bug is reported in HW_TAGS

 Documentation/dev-tools/kasan.rst  |   8 +-
 arch/arm64/include/asm/cache.h     |   1 -
 arch/arm64/include/asm/kasan.h     |   1 +
 arch/arm64/include/asm/mte-def.h   |   2 +
 arch/arm64/include/asm/mte-kasan.h |  65 ++++++++--
 arch/arm64/include/asm/mte.h       |   2 -
 arch/arm64/kernel/mte.c            |  48 +-------
 arch/arm64/lib/mte.S               |  16 ---
 include/linux/kasan.h              |  25 ++--
 lib/test_kasan.c                   | 111 +++++++++++++++--
 mm/kasan/common.c                  | 187 ++++++++++++++++++++---------
 mm/kasan/hw_tags.c                 |   2 +-
 mm/kasan/kasan.h                   |  72 +++++++++--
 mm/kasan/shadow.c                  |  53 ++++----
 mm/slab_common.c                   |  18 ++-
 mm/slub.c                          |   3 +-
 16 files changed, 425 insertions(+), 189 deletions(-)
Signature · 1 line
2.30.0.365.g02bc693789-goog