linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] kasan: cleanups for kasan_enabled() checks
@ 2025-10-09 15:54 Sabyrzhan Tasbolatov
  2025-10-09 15:54 ` [PATCH 1/2] kasan: remove __kasan_save_free_info wrapper Sabyrzhan Tasbolatov
  2025-10-09 15:54 ` [PATCH 2/2] kasan: cleanup of kasan_enabled() checks Sabyrzhan Tasbolatov
  0 siblings, 2 replies; 5+ messages in thread
From: Sabyrzhan Tasbolatov @ 2025-10-09 15:54 UTC (permalink / raw)
  To: andreyknvl, ryabinin.a.a, glider, dvyukov, vincenzo.frascino, akpm, bhe
  Cc: christophe.leroy, ritesh.list, snovitoll, kasan-dev,
	linux-kernel, linux-mm

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(-)

-- 
2.34.1



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

end of thread, other threads:[~2025-10-21 23:08 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-10-09 15:54 [PATCH 0/2] kasan: cleanups for kasan_enabled() checks Sabyrzhan Tasbolatov
2025-10-09 15:54 ` [PATCH 1/2] kasan: remove __kasan_save_free_info wrapper Sabyrzhan Tasbolatov
2025-10-21 23:07   ` Andrey Konovalov
2025-10-09 15:54 ` [PATCH 2/2] kasan: cleanup of kasan_enabled() checks Sabyrzhan Tasbolatov
2025-10-21 23:07   ` Andrey Konovalov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox