From: Kees Cook Date: Tue, 13 Sep 2022 17:28:56 +0000 (-0700) Subject: fortify: Adjust KUnit test for modular build X-Git-Tag: v6.1-rc5~349^2~9 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=06c1c49d0cd1d6cec5b78963109ba728e49e0063;p=platform%2Fkernel%2Flinux-starfive.git fortify: Adjust KUnit test for modular build A much better "unknown size" string pointer is available directly from struct test, so use that instead of a global that isn't shared with modules. Reported-by: Nathan Chancellor Link: https://lore.kernel.org/lkml/YyCOHOchVuE/E7vS@dev-arch.thelio-3990X Fixes: 875bfd5276f3 ("fortify: Add KUnit test for FORTIFY_SOURCE internals") Cc: linux-hardening@vger.kernel.org Build-tested-by: Nathan Chancellor Reviewed-by: David Gow Signed-off-by: Kees Cook --- diff --git a/lib/fortify_kunit.c b/lib/fortify_kunit.c index 99bc0ea..409af07 100644 --- a/lib/fortify_kunit.c +++ b/lib/fortify_kunit.c @@ -17,7 +17,6 @@ #include #include -#include static const char array_of_10[] = "this is 10"; static const char *ptr_of_11 = "this is 11!"; @@ -31,7 +30,7 @@ static void known_sizes_test(struct kunit *test) KUNIT_EXPECT_EQ(test, __compiletime_strlen(array_unknown), SIZE_MAX); /* Externally defined and dynamically sized string pointer: */ - KUNIT_EXPECT_EQ(test, __compiletime_strlen(saved_command_line), SIZE_MAX); + KUNIT_EXPECT_EQ(test, __compiletime_strlen(test->name), SIZE_MAX); } /* This is volatile so the optimizer can't perform DCE below. */