Skip to content

kasan: cleanups for kasan_enabled() checks

Sabyrzhan Tasbolatov linux-mm lkml 1 version Applied

Status from this message: [merged mm-stable] kasan-cleanup-of-kasan_enabled-checks.patch removed from -mm tree

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 2 repliesApplied 2/2

Patches in v1 All 2 applied

#Subject and filesSizeRepliesApplied
1/2kasan: remove __kasan_save_free_info wrappermm/kasan/generic.c mm/kasan/kasan.h mm/kasan/tags.c+3 -81 replyApplied
2/2kasan: cleanup of kasan_enabled() checksinclude/linux/kasan.h mm/kasan/common.c mm/kasan/generic.c +1 more+22 -241 replyApplied

Reviews trailers per patch

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

PatchAndrey Konovalov
1/2R-b
2/2R-b

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

Read the v1 thread

Cover letter [PATCH 0/2] kasan: cleanups for kasan_enabled() checks

This patch series is the continuation of [1] the previous discussion related to the KASAN internal refactoring.

Here we remove kasan_enabled() checks which are duplicated by higher callers. These checks deduplication are also related to the separate patch series [2].

[1] https://lore.kernel.org/all/CA+fCnZce3AR+pUesbDkKMtMJ+iR8eDrcjFTbVpAcwjBoZ=gJnQ@mail.gmail.com/
[2] https://lore.kernel.org/all/aNTfPjS2buXMI46D@MiWiFi-R3L-srv/

* Altered functions:

check_page_allocation
Delete the check because callers have it already in __wrappers in include/linux/kasan.h:
__kasan_kfree_large __kasan_mempool_poison_pages __kasan_mempool_poison_object

kasan_populate_vmalloc, kasan_release_vmalloc
Add __wrappers in include/linux/kasan.h. They are called externally in mm/vmalloc.c.

__kasan_unpoison_vmalloc, __kasan_poison_vmalloc
Delete checks because there're already kasan_enabled() checks in respective __wrappers in include/linux/kasan.h.

release_free_meta -- Delete the check because the higher caller path
has it already. See the stack trace:

__kasan_slab_free -- has the check already __kasan_mempool_poison_object -- has the check already
poison_slab_object
kasan_save_free_info
release_free_meta
kasan_enabled() -- Delete here

* Other mm/kasan/* functions with kasan_enabled() where callers are defined in internal mm/kasan/kasan.h:

mm/kasan/generic.c:
kasan_check_range
check_region_inline
kasan_byte_accessible

mm/kasan/shadow.c:
kasan_poison
kasan_poison_last_granule

mm/kasan/kasan_test_c.c:
kasan_suite_init

== Tests:

* ARCH=um defconfig (-e KASAN, selects ARCH_DEFER_KASAN) Compiled and run ./linux with no issue

* ARCH=powerpc ppc64le_defconfig (-e KASAN, selects ARCH_DEFER_KASAN) Compiled and run qemu-system-ppc64 with no issue

* ARCH=arm64 defconfig (-e KASAN_GENERIC) and KUnit tests:

[    4.065375] # kasan: pass:61 fail:1 skip:14 total:76
[    4.065529] # Totals: pass:61 fail:1 skip:14 total:76
[    4.065682] not ok 1 kasan

1 test is failing:

[    3.772739]     # kasan_strings: EXPECTATION FAILED at mm/kasan/kasan_test_c.c:1700
[    3.772739]     KASAN failure expected in "strscpy(ptr, src + KASAN_GRANULE_SIZE, KASAN_GRANULE_SIZE)", but none occurred

which is also reproducable in the main tree.

Sabyrzhan Tasbolatov (2):
kasan: remove __kasan_save_free_info wrapper
kasan: cleanup of kasan_enabled() checks

 include/linux/kasan.h | 20 ++++++++++++++++++--
 mm/kasan/common.c     |  3 ---
 mm/kasan/generic.c    |  5 +----
 mm/kasan/kasan.h      |  7 +------
 mm/kasan/shadow.c     | 20 ++++----------------
 mm/kasan/tags.c       |  2 +-
 6 files changed, 25 insertions(+), 32 deletions(-)
Signature · 1 line
2.34.1