@@ -64,7 +64,7 @@ void fortify_add_kunit_error(int write)
6464 kunit_put_resource (resource );
6565}
6666
67- static void known_sizes_test (struct kunit * test )
67+ static void fortify_test_known_sizes (struct kunit * test )
6868{
6969 KUNIT_EXPECT_EQ (test , __compiletime_strlen ("88888888" ), 8 );
7070 KUNIT_EXPECT_EQ (test , __compiletime_strlen (array_of_10 ), 10 );
@@ -97,7 +97,7 @@ static noinline size_t want_minus_one(int pick)
9797 return __compiletime_strlen (str );
9898}
9999
100- static void control_flow_split_test (struct kunit * test )
100+ static void fortify_test_control_flow_split (struct kunit * test )
101101{
102102 KUNIT_EXPECT_EQ (test , want_minus_one (pick ), SIZE_MAX );
103103}
@@ -173,11 +173,11 @@ static volatile size_t unknown_size = 50;
173173#endif
174174
175175#define DEFINE_ALLOC_SIZE_TEST_PAIR (allocator ) \
176- static void alloc_size_ ##allocator##_const_test (struct kunit *test) \
176+ static void fortify_test_alloc_size_ ##allocator##_const (struct kunit *test) \
177177{ \
178178 CONST_TEST_BODY(TEST_##allocator); \
179179} \
180- static void alloc_size_ ##allocator##_dynamic_test (struct kunit *test) \
180+ static void fortify_test_alloc_size_ ##allocator##_dynamic (struct kunit *test) \
181181{ \
182182 DYNAMIC_TEST_BODY(TEST_##allocator); \
183183}
@@ -361,7 +361,7 @@ struct fortify_padding {
361361/* Force compiler into not being able to resolve size at compile-time. */
362362static volatile int unconst ;
363363
364- static void strlen_test (struct kunit * test )
364+ static void fortify_test_strlen (struct kunit * test )
365365{
366366 struct fortify_padding pad = { };
367367 int i , end = sizeof (pad .buf ) - 1 ;
@@ -384,7 +384,7 @@ static void strlen_test(struct kunit *test)
384384 KUNIT_EXPECT_EQ (test , fortify_read_overflows , 1 );
385385}
386386
387- static void strnlen_test (struct kunit * test )
387+ static void fortify_test_strnlen (struct kunit * test )
388388{
389389 struct fortify_padding pad = { };
390390 int i , end = sizeof (pad .buf ) - 1 ;
@@ -422,7 +422,7 @@ static void strnlen_test(struct kunit *test)
422422 KUNIT_EXPECT_EQ (test , fortify_read_overflows , 2 );
423423}
424424
425- static void strcpy_test (struct kunit * test )
425+ static void fortify_test_strcpy (struct kunit * test )
426426{
427427 struct fortify_padding pad = { };
428428 char src [sizeof (pad .buf ) + 1 ] = { };
@@ -480,7 +480,7 @@ static void strcpy_test(struct kunit *test)
480480 KUNIT_EXPECT_EQ (test , pad .bytes_after , 0 );
481481}
482482
483- static void strncpy_test (struct kunit * test )
483+ static void fortify_test_strncpy (struct kunit * test )
484484{
485485 struct fortify_padding pad = { };
486486 char src [] = "Copy me fully into a small buffer and I will overflow!" ;
@@ -539,7 +539,7 @@ static void strncpy_test(struct kunit *test)
539539 KUNIT_EXPECT_EQ (test , pad .bytes_after , 0 );
540540}
541541
542- static void strscpy_test (struct kunit * test )
542+ static void fortify_test_strscpy (struct kunit * test )
543543{
544544 struct fortify_padding pad = { };
545545 char src [] = "Copy me fully into a small buffer and I will overflow!" ;
@@ -596,7 +596,7 @@ static void strscpy_test(struct kunit *test)
596596 KUNIT_EXPECT_EQ (test , pad .bytes_after , 0 );
597597}
598598
599- static void strcat_test (struct kunit * test )
599+ static void fortify_test_strcat (struct kunit * test )
600600{
601601 struct fortify_padding pad = { };
602602 char src [sizeof (pad .buf ) / 2 ] = { };
@@ -653,7 +653,7 @@ static void strcat_test(struct kunit *test)
653653 KUNIT_EXPECT_EQ (test , pad .bytes_after , 0 );
654654}
655655
656- static void strncat_test (struct kunit * test )
656+ static void fortify_test_strncat (struct kunit * test )
657657{
658658 struct fortify_padding pad = { };
659659 char src [sizeof (pad .buf )] = { };
@@ -726,7 +726,7 @@ static void strncat_test(struct kunit *test)
726726 KUNIT_EXPECT_EQ (test , pad .bytes_after , 0 );
727727}
728728
729- static void strlcat_test (struct kunit * test )
729+ static void fortify_test_strlcat (struct kunit * test )
730730{
731731 struct fortify_padding pad = { };
732732 char src [sizeof (pad .buf )] = { };
@@ -811,7 +811,7 @@ static void strlcat_test(struct kunit *test)
811811 KUNIT_EXPECT_EQ (test , pad .bytes_after , 0 );
812812}
813813
814- static void memscan_test (struct kunit * test )
814+ static void fortify_test_memscan (struct kunit * test )
815815{
816816 char haystack [] = "Where oh where is my memory range?" ;
817817 char * mem = haystack + strlen ("Where oh where is " );
@@ -830,7 +830,7 @@ static void memscan_test(struct kunit *test)
830830 KUNIT_EXPECT_EQ (test , fortify_read_overflows , 2 );
831831}
832832
833- static void memchr_test (struct kunit * test )
833+ static void fortify_test_memchr (struct kunit * test )
834834{
835835 char haystack [] = "Where oh where is my memory range?" ;
836836 char * mem = haystack + strlen ("Where oh where is " );
@@ -849,7 +849,7 @@ static void memchr_test(struct kunit *test)
849849 KUNIT_EXPECT_EQ (test , fortify_read_overflows , 2 );
850850}
851851
852- static void memchr_inv_test (struct kunit * test )
852+ static void fortify_test_memchr_inv (struct kunit * test )
853853{
854854 char haystack [] = "Where oh where is my memory range?" ;
855855 char * mem = haystack + 1 ;
@@ -869,7 +869,7 @@ static void memchr_inv_test(struct kunit *test)
869869 KUNIT_EXPECT_EQ (test , fortify_read_overflows , 2 );
870870}
871871
872- static void memcmp_test (struct kunit * test )
872+ static void fortify_test_memcmp (struct kunit * test )
873873{
874874 char one [] = "My mind is going ..." ;
875875 char two [] = "My mind is going ... I can feel it." ;
@@ -891,7 +891,7 @@ static void memcmp_test(struct kunit *test)
891891 KUNIT_EXPECT_EQ (test , fortify_read_overflows , 2 );
892892}
893893
894- static void kmemdup_test (struct kunit * test )
894+ static void fortify_test_kmemdup (struct kunit * test )
895895{
896896 char src [] = "I got Doom running on it!" ;
897897 char * copy ;
@@ -951,31 +951,31 @@ static int fortify_test_init(struct kunit *test)
951951}
952952
953953static struct kunit_case fortify_test_cases [] = {
954- KUNIT_CASE (known_sizes_test ),
955- KUNIT_CASE (control_flow_split_test ),
956- KUNIT_CASE (alloc_size_kmalloc_const_test ),
957- KUNIT_CASE (alloc_size_kmalloc_dynamic_test ),
958- KUNIT_CASE (alloc_size_vmalloc_const_test ),
959- KUNIT_CASE (alloc_size_vmalloc_dynamic_test ),
960- KUNIT_CASE (alloc_size_kvmalloc_const_test ),
961- KUNIT_CASE (alloc_size_kvmalloc_dynamic_test ),
962- KUNIT_CASE (alloc_size_devm_kmalloc_const_test ),
963- KUNIT_CASE (alloc_size_devm_kmalloc_dynamic_test ),
964- KUNIT_CASE (strlen_test ),
965- KUNIT_CASE (strnlen_test ),
966- KUNIT_CASE (strcpy_test ),
967- KUNIT_CASE (strncpy_test ),
968- KUNIT_CASE (strscpy_test ),
969- KUNIT_CASE (strcat_test ),
970- KUNIT_CASE (strncat_test ),
971- KUNIT_CASE (strlcat_test ),
954+ KUNIT_CASE (fortify_test_known_sizes ),
955+ KUNIT_CASE (fortify_test_control_flow_split ),
956+ KUNIT_CASE (fortify_test_alloc_size_kmalloc_const ),
957+ KUNIT_CASE (fortify_test_alloc_size_kmalloc_dynamic ),
958+ KUNIT_CASE (fortify_test_alloc_size_vmalloc_const ),
959+ KUNIT_CASE (fortify_test_alloc_size_vmalloc_dynamic ),
960+ KUNIT_CASE (fortify_test_alloc_size_kvmalloc_const ),
961+ KUNIT_CASE (fortify_test_alloc_size_kvmalloc_dynamic ),
962+ KUNIT_CASE (fortify_test_alloc_size_devm_kmalloc_const ),
963+ KUNIT_CASE (fortify_test_alloc_size_devm_kmalloc_dynamic ),
964+ KUNIT_CASE (fortify_test_strlen ),
965+ KUNIT_CASE (fortify_test_strnlen ),
966+ KUNIT_CASE (fortify_test_strcpy ),
967+ KUNIT_CASE (fortify_test_strncpy ),
968+ KUNIT_CASE (fortify_test_strscpy ),
969+ KUNIT_CASE (fortify_test_strcat ),
970+ KUNIT_CASE (fortify_test_strncat ),
971+ KUNIT_CASE (fortify_test_strlcat ),
972972 /* skip memset: performs bounds checking on whole structs */
973973 /* skip memcpy: still using warn-and-overwrite instead of hard-fail */
974- KUNIT_CASE (memscan_test ),
975- KUNIT_CASE (memchr_test ),
976- KUNIT_CASE (memchr_inv_test ),
977- KUNIT_CASE (memcmp_test ),
978- KUNIT_CASE (kmemdup_test ),
974+ KUNIT_CASE (fortify_test_memscan ),
975+ KUNIT_CASE (fortify_test_memchr ),
976+ KUNIT_CASE (fortify_test_memchr_inv ),
977+ KUNIT_CASE (fortify_test_memcmp ),
978+ KUNIT_CASE (fortify_test_kmemdup ),
979979 {}
980980};
981981
0 commit comments