Re: [PATCH v19 01/17] iov_iter: Fix kunit test to remove __init and __refdata marks
From: Wang Yibo
Date: Thu Nov 19 2026 - 04:21:43 EST
Hi David,
> Remove the __init marks from the functions in the iov_iter kunit test so
> that they don't get removed after the module is loaded or if the test is
> built in as the tests can be triggered through debugfs too.
The reasoning looks right to me. The suite is registered with
kunit_test_suites(), so it gets a debugfs "run" file and can be re-run
after the init sections have been freed; calling into an __init function
from there is a use-after-free, and __refdata on the case array keeps
modpost from flagging the reference to init text.
There is one more file in the tree with the same problem:
lib/tests/bitfield_kunit.c:60 __init test_bitfields_constants()
lib/tests/bitfield_kunit.c:103 __init test_bitfields_variables()
lib/tests/bitfield_kunit.c:140 __refdata bitfields_test_cases[]
lib/tests/bitfield_kunit.c:151 kunit_test_suites(&bitfields_test_suite)
(line numbers from v7.4-rc1; test_bitfields_compile() is also marked
__init but is only built under TEST_BITFIELD_COMPILE and is not in the
case array)
I went through the other suites that still have __init case functions --
drivers/char/misc_minor_kunit.c, init/initramfs_test.c,
security/landlock/id.c and lib/kunit/kunit-example-test.c -- and they
are fine: they are all registered with
kunit_test_init_section_suites(), which does not create a "run" file, so
keeping __init there is correct.
Do you want the bitfields one folded into this series, or would you
rather I send it separately?
Thanks,
Wang Yibo