Skip to content

Commit 362257e

Browse files
LeviYeoReumakpm00
authored andcommitted
kunit: kasan_test: disable fortify string checker on kasan_strings() test
Similar to commit 09c6304 ("kasan: test: fix compatibility with FORTIFY_SOURCE") the kernel is panicing in kasan_string(). This is due to the `src` and `ptr` not being hidden from the optimizer which would disable the runtime fortify string checker. Call trace: __fortify_panic+0x10/0x20 (P) kasan_strings+0x980/0x9b0 kunit_try_run_case+0x68/0x190 kunit_generic_run_threadfn_adapter+0x34/0x68 kthread+0x1c4/0x228 ret_from_fork+0x10/0x20 Code: d503233f a9bf7bfd 910003fd 9424b243 (d4210000) ---[ end trace 0000000000000000 ]--- note: kunit_try_catch[128] exited with irqs disabled note: kunit_try_catch[128] exited with preempt_count 1 # kasan_strings: try faulted: last ** replaying previous printk message ** # kasan_strings: try faulted: last line seen mm/kasan/kasan_test_c.c:1600 # kasan_strings: internal error occurred preventing test case from running: -4 Link: https://lkml.kernel.org/r/[email protected] Fixes: 73228c7 ("KASAN: port KASAN Tests to KUnit") Signed-off-by: Yeoreum Yun <[email protected]> Cc: Alexander Potapenko <[email protected]> Cc: Andrey Konovalov <[email protected]> Cc: Andrey Ryabinin <[email protected]> Cc: Dmitriy Vyukov <[email protected]> Cc: Vincenzo Frascino <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 519c200 commit 362257e

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

mm/kasan/kasan_test_c.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1578,9 +1578,11 @@ static void kasan_strings(struct kunit *test)
15781578

15791579
ptr = kmalloc(size, GFP_KERNEL | __GFP_ZERO);
15801580
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr);
1581+
OPTIMIZER_HIDE_VAR(ptr);
15811582

15821583
src = kmalloc(KASAN_GRANULE_SIZE, GFP_KERNEL | __GFP_ZERO);
15831584
strscpy(src, "f0cacc1a0000000", KASAN_GRANULE_SIZE);
1585+
OPTIMIZER_HIDE_VAR(src);
15841586

15851587
/*
15861588
* Make sure that strscpy() does not trigger KASAN if it overreads into

0 commit comments

Comments
 (0)