public inbox for linux-mm@kvack.org
 help / color / mirror / Atom feed
From: Sabyrzhan Tasbolatov <snovitoll@gmail.com>
To: andreyknvl@gmail.com, ryabinin.a.a@gmail.com, glider@google.com,
	dvyukov@google.com, vincenzo.frascino@arm.com,
	akpm@linux-foundation.org, bhe@redhat.com
Cc: christophe.leroy@csgroup.eu, ritesh.list@gmail.com,
	snovitoll@gmail.com, kasan-dev@googlegroups.com,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: [PATCH 0/2] kasan: cleanups for kasan_enabled() checks
Date: Thu,  9 Oct 2025 20:54:01 +0500	[thread overview]
Message-ID: <20251009155403.1379150-1-snovitoll@gmail.com> (raw)

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



             reply	other threads:[~2025-10-09 15:54 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-09 15:54 Sabyrzhan Tasbolatov [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251009155403.1379150-1-snovitoll@gmail.com \
    --to=snovitoll@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=andreyknvl@gmail.com \
    --cc=bhe@redhat.com \
    --cc=christophe.leroy@csgroup.eu \
    --cc=dvyukov@google.com \
    --cc=glider@google.com \
    --cc=kasan-dev@googlegroups.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ritesh.list@gmail.com \
    --cc=ryabinin.a.a@gmail.com \
    --cc=vincenzo.frascino@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox