path: root/lib
diff options
authorAndrey Konovalov <>2021-04-29 22:59:59 -0700
committerLinus Torvalds <>2021-04-30 11:20:41 -0700
commitaa5c219c60ccb75b50c16329885b65c275172e4a (patch)
treeaee5e3a5523e9908ab347da46ebbb5eafd1616c0 /lib
parentd9b6f90794ba2a2f47d1646cda343924b092b3c2 (diff)
kasan: init memory in kasan_(un)poison for HW_TAGS
This change adds an argument to kasan_poison() and kasan_unpoison() that allows initializing memory along with setting the tags for HW_TAGS. Combining setting allocation tags with memory initialization will improve HW_TAGS KASAN performance when init_on_alloc/free is enabled. This change doesn't integrate memory initialization with KASAN, this is done is subsequent patches in this series. Link: Signed-off-by: Andrey Konovalov <> Reviewed-by: Marco Elver <> Cc: Alexander Potapenko <> Cc: Andrey Ryabinin <> Cc: Branislav Rankov <> Cc: Catalin Marinas <> Cc: Christoph Lameter <> Cc: David Rientjes <> Cc: Dmitry Vyukov <> Cc: Evgenii Stepanov <> Cc: Joonsoo Kim <> Cc: Kevin Brodsky <> Cc: Pekka Enberg <> Cc: Peter Collingbourne <> Cc: Vincenzo Frascino <> Cc: Vlastimil Babka <> Cc: Will Deacon <> Signed-off-by: Andrew Morton <> Signed-off-by: Linus Torvalds <>
Diffstat (limited to 'lib')
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/test_kasan.c b/lib/test_kasan.c
index 785e724ce0d8..0882d6c17e62 100644
--- a/lib/test_kasan.c
+++ b/lib/test_kasan.c
@@ -1049,14 +1049,14 @@ static void match_all_mem_tag(struct kunit *test)
/* Mark the first memory granule with the chosen memory tag. */
- kasan_poison(ptr, KASAN_GRANULE_SIZE, (u8)tag);
+ kasan_poison(ptr, KASAN_GRANULE_SIZE, (u8)tag, false);
/* This access must cause a KASAN report. */
KUNIT_EXPECT_KASAN_FAIL(test, *ptr = 0);
/* Recover the memory tag and free. */
- kasan_poison(ptr, KASAN_GRANULE_SIZE, get_tag(ptr));
+ kasan_poison(ptr, KASAN_GRANULE_SIZE, get_tag(ptr), false);