Re: [PATCH] kasan: disable kasan_strings() kunit test when CONFIG_FORTIFY_SOURCE enabled
From: Yeoreum Yun
Date: Thu Jul 31 2025 - 05:35:32 EST
Hi Thomas,
> > When CONFIG_FORTIFY_SOURCE is enabled, invalid access from source
> > triggers __fortify_panic() which kills running task.
> >
> > This makes failured of kasan_strings() kunit testcase since the
> > kunit-try-cacth kthread running kasan_string() dies before checking the
> > fault.
> >
> > To address this, skip kasan_strings() kunit test when
> > CONFIG_FORTIFY_SOURCE is enabled.
> >
> > Signed-off-by: Yeoreum Yun <yeoreum.yun@xxxxxxx>
> > ---
> > mm/kasan/kasan_test_c.c | 6 ++++++
> > 1 file changed, 6 insertions(+)
> >
> > diff --git a/mm/kasan/kasan_test_c.c b/mm/kasan/kasan_test_c.c
> > index 5f922dd38ffa..1577d3edabb4 100644
> > --- a/mm/kasan/kasan_test_c.c
> > +++ b/mm/kasan/kasan_test_c.c
> > @@ -1576,6 +1576,12 @@ static void kasan_strings(struct kunit *test)
> > */
> > KASAN_TEST_NEEDS_CONFIG_OFF(test, CONFIG_AMD_MEM_ENCRYPT);
> >
> > + /*
> > + * Harden common str/mem functions kills the kunit-try-catch thread
> > + * before checking the fault.
> > + */
> > + KASAN_TEST_NEEDS_CONFIG_OFF(test, CONFIG_FORTIFY_SOURCE);
>
> Would it be enough to enable -D__NO_FORTIFY for the whole of kasan_test_c.c?
It would be better. I'll add it to Makefile unless other comment is.
Thanks!
[...]
--
Sincerely,
Yeoreum Yun