@@ -64,7 +64,7 @@ void fortify_add_kunit_error(int write)
64
64
kunit_put_resource (resource );
65
65
}
66
66
67
- static void known_sizes_test (struct kunit * test )
67
+ static void fortify_test_known_sizes (struct kunit * test )
68
68
{
69
69
KUNIT_EXPECT_EQ (test , __compiletime_strlen ("88888888" ), 8 );
70
70
KUNIT_EXPECT_EQ (test , __compiletime_strlen (array_of_10 ), 10 );
@@ -97,7 +97,7 @@ static noinline size_t want_minus_one(int pick)
97
97
return __compiletime_strlen (str );
98
98
}
99
99
100
- static void control_flow_split_test (struct kunit * test )
100
+ static void fortify_test_control_flow_split (struct kunit * test )
101
101
{
102
102
KUNIT_EXPECT_EQ (test , want_minus_one (pick ), SIZE_MAX );
103
103
}
@@ -173,11 +173,11 @@ static volatile size_t unknown_size = 50;
173
173
#endif
174
174
175
175
#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) \
177
177
{ \
178
178
CONST_TEST_BODY(TEST_##allocator); \
179
179
} \
180
- static void alloc_size_ ##allocator##_dynamic_test (struct kunit *test) \
180
+ static void fortify_test_alloc_size_ ##allocator##_dynamic (struct kunit *test) \
181
181
{ \
182
182
DYNAMIC_TEST_BODY(TEST_##allocator); \
183
183
}
@@ -361,7 +361,7 @@ struct fortify_padding {
361
361
/* Force compiler into not being able to resolve size at compile-time. */
362
362
static volatile int unconst ;
363
363
364
- static void strlen_test (struct kunit * test )
364
+ static void fortify_test_strlen (struct kunit * test )
365
365
{
366
366
struct fortify_padding pad = { };
367
367
int i , end = sizeof (pad .buf ) - 1 ;
@@ -384,7 +384,7 @@ static void strlen_test(struct kunit *test)
384
384
KUNIT_EXPECT_EQ (test , fortify_read_overflows , 1 );
385
385
}
386
386
387
- static void strnlen_test (struct kunit * test )
387
+ static void fortify_test_strnlen (struct kunit * test )
388
388
{
389
389
struct fortify_padding pad = { };
390
390
int i , end = sizeof (pad .buf ) - 1 ;
@@ -422,7 +422,7 @@ static void strnlen_test(struct kunit *test)
422
422
KUNIT_EXPECT_EQ (test , fortify_read_overflows , 2 );
423
423
}
424
424
425
- static void strcpy_test (struct kunit * test )
425
+ static void fortify_test_strcpy (struct kunit * test )
426
426
{
427
427
struct fortify_padding pad = { };
428
428
char src [sizeof (pad .buf ) + 1 ] = { };
@@ -480,7 +480,7 @@ static void strcpy_test(struct kunit *test)
480
480
KUNIT_EXPECT_EQ (test , pad .bytes_after , 0 );
481
481
}
482
482
483
- static void strncpy_test (struct kunit * test )
483
+ static void fortify_test_strncpy (struct kunit * test )
484
484
{
485
485
struct fortify_padding pad = { };
486
486
char src [] = "Copy me fully into a small buffer and I will overflow!" ;
@@ -539,7 +539,7 @@ static void strncpy_test(struct kunit *test)
539
539
KUNIT_EXPECT_EQ (test , pad .bytes_after , 0 );
540
540
}
541
541
542
- static void strscpy_test (struct kunit * test )
542
+ static void fortify_test_strscpy (struct kunit * test )
543
543
{
544
544
struct fortify_padding pad = { };
545
545
char src [] = "Copy me fully into a small buffer and I will overflow!" ;
@@ -596,7 +596,7 @@ static void strscpy_test(struct kunit *test)
596
596
KUNIT_EXPECT_EQ (test , pad .bytes_after , 0 );
597
597
}
598
598
599
- static void strcat_test (struct kunit * test )
599
+ static void fortify_test_strcat (struct kunit * test )
600
600
{
601
601
struct fortify_padding pad = { };
602
602
char src [sizeof (pad .buf ) / 2 ] = { };
@@ -653,7 +653,7 @@ static void strcat_test(struct kunit *test)
653
653
KUNIT_EXPECT_EQ (test , pad .bytes_after , 0 );
654
654
}
655
655
656
- static void strncat_test (struct kunit * test )
656
+ static void fortify_test_strncat (struct kunit * test )
657
657
{
658
658
struct fortify_padding pad = { };
659
659
char src [sizeof (pad .buf )] = { };
@@ -726,7 +726,7 @@ static void strncat_test(struct kunit *test)
726
726
KUNIT_EXPECT_EQ (test , pad .bytes_after , 0 );
727
727
}
728
728
729
- static void strlcat_test (struct kunit * test )
729
+ static void fortify_test_strlcat (struct kunit * test )
730
730
{
731
731
struct fortify_padding pad = { };
732
732
char src [sizeof (pad .buf )] = { };
@@ -811,7 +811,7 @@ static void strlcat_test(struct kunit *test)
811
811
KUNIT_EXPECT_EQ (test , pad .bytes_after , 0 );
812
812
}
813
813
814
- static void memscan_test (struct kunit * test )
814
+ static void fortify_test_memscan (struct kunit * test )
815
815
{
816
816
char haystack [] = "Where oh where is my memory range?" ;
817
817
char * mem = haystack + strlen ("Where oh where is " );
@@ -830,7 +830,7 @@ static void memscan_test(struct kunit *test)
830
830
KUNIT_EXPECT_EQ (test , fortify_read_overflows , 2 );
831
831
}
832
832
833
- static void memchr_test (struct kunit * test )
833
+ static void fortify_test_memchr (struct kunit * test )
834
834
{
835
835
char haystack [] = "Where oh where is my memory range?" ;
836
836
char * mem = haystack + strlen ("Where oh where is " );
@@ -849,7 +849,7 @@ static void memchr_test(struct kunit *test)
849
849
KUNIT_EXPECT_EQ (test , fortify_read_overflows , 2 );
850
850
}
851
851
852
- static void memchr_inv_test (struct kunit * test )
852
+ static void fortify_test_memchr_inv (struct kunit * test )
853
853
{
854
854
char haystack [] = "Where oh where is my memory range?" ;
855
855
char * mem = haystack + 1 ;
@@ -869,7 +869,7 @@ static void memchr_inv_test(struct kunit *test)
869
869
KUNIT_EXPECT_EQ (test , fortify_read_overflows , 2 );
870
870
}
871
871
872
- static void memcmp_test (struct kunit * test )
872
+ static void fortify_test_memcmp (struct kunit * test )
873
873
{
874
874
char one [] = "My mind is going ..." ;
875
875
char two [] = "My mind is going ... I can feel it." ;
@@ -891,7 +891,7 @@ static void memcmp_test(struct kunit *test)
891
891
KUNIT_EXPECT_EQ (test , fortify_read_overflows , 2 );
892
892
}
893
893
894
- static void kmemdup_test (struct kunit * test )
894
+ static void fortify_test_kmemdup (struct kunit * test )
895
895
{
896
896
char src [] = "I got Doom running on it!" ;
897
897
char * copy ;
@@ -951,31 +951,31 @@ static int fortify_test_init(struct kunit *test)
951
951
}
952
952
953
953
static 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 ),
972
972
/* skip memset: performs bounds checking on whole structs */
973
973
/* 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 ),
979
979
{}
980
980
};
981
981
0 commit comments