Skip to content

Commit

Permalink
kasan: speed up match_all_mem_tag test for SW_TAGS
Browse files Browse the repository at this point in the history
Checking all 256 possible tag values in the match_all_mem_tag KASAN test
is slow and produces 256 reports.  Instead, just check the first 8 and the
last 8.

Link: https://lkml.kernel.org/r/6fe51262defd80cdc1150c42404977aafd1b6167.1703188911.git.andreyknvl@google.com
Signed-off-by: Andrey Konovalov <[email protected]>
Cc: Alexander Potapenko <[email protected]>
Cc: Andrey Ryabinin <[email protected]>
Cc: Dmitry Vyukov <[email protected]>
Cc: Marco Elver <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
  • Loading branch information
xairy authored and akpm00 committed Dec 29, 2023
1 parent 3ab9304 commit 4e39727
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions mm/kasan/kasan_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -1797,6 +1797,14 @@ static void match_all_mem_tag(struct kunit *test)

/* For each possible tag value not matching the pointer tag. */
for (tag = KASAN_TAG_MIN; tag <= KASAN_TAG_KERNEL; tag++) {
/*
* For Software Tag-Based KASAN, skip the majority of tag
* values to avoid the test printing too many reports.
*/
if (IS_ENABLED(CONFIG_KASAN_SW_TAGS) &&
tag >= KASAN_TAG_MIN + 8 && tag <= KASAN_TAG_KERNEL - 8)
continue;

if (tag == get_tag(ptr))
continue;

Expand Down

0 comments on commit 4e39727

Please sign in to comment.