]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
lib/string_kunit: add correctness test for strnlen()
authorFeng Jiang <jiangfeng@kylinos.cn>
Sat, 4 Apr 2026 01:28:47 +0000 (19:28 -0600)
committerPaul Walmsley <pjw@kernel.org>
Sun, 5 Apr 2026 00:42:44 +0000 (18:42 -0600)
commit263dca234e5cc12aa8b434592ceb655538bf4ea4
tree85d310031b62550f1ed758afd861f78542181997
parentae45f896a40a07449d9b45d0395fb7245fdd75fc
lib/string_kunit: add correctness test for strnlen()

Add a KUnit test for strnlen() to verify correctness across
different string lengths and memory alignments. Use vmalloc()
to place the NUL character at the page boundary to ensure
over-reads are detected.

Suggested-by: Andy Shevchenko <andy@kernel.org>
Suggested-by: Kees Cook <kees@kernel.org>
Signed-off-by: Feng Jiang <jiangfeng@kylinos.cn>
Reviewed-by: Kees Cook <kees@kernel.org>
Link: https://patch.msgid.link/20260130025018.172925-3-jiangfeng@kylinos.cn
Signed-off-by: Paul Walmsley <pjw@kernel.org>
lib/tests/string_kunit.c