@@ -383,6 +383,22 @@ static void test_use_after_free_read(struct kunit *test)
383
383
KUNIT_EXPECT_TRUE (test , report_matches (& expect ));
384
384
}
385
385
386
+ static void test_use_after_free_read_nofault (struct kunit * test )
387
+ {
388
+ const size_t size = 32 ;
389
+ char * addr ;
390
+ char dst ;
391
+ int ret ;
392
+
393
+ setup_test_cache (test , size , 0 , NULL );
394
+ addr = test_alloc (test , size , GFP_KERNEL , ALLOCATE_ANY );
395
+ test_free (addr );
396
+ /* Use after free with *_nofault() */
397
+ ret = copy_from_kernel_nofault (& dst , addr , 1 );
398
+ KUNIT_EXPECT_EQ (test , ret , - EFAULT );
399
+ KUNIT_EXPECT_FALSE (test , report_available ());
400
+ }
401
+
386
402
static void test_double_free (struct kunit * test )
387
403
{
388
404
const size_t size = 32 ;
@@ -780,6 +796,7 @@ static struct kunit_case kfence_test_cases[] = {
780
796
KFENCE_KUNIT_CASE (test_out_of_bounds_read ),
781
797
KFENCE_KUNIT_CASE (test_out_of_bounds_write ),
782
798
KFENCE_KUNIT_CASE (test_use_after_free_read ),
799
+ KFENCE_KUNIT_CASE (test_use_after_free_read_nofault ),
783
800
KFENCE_KUNIT_CASE (test_double_free ),
784
801
KFENCE_KUNIT_CASE (test_invalid_addr_free ),
785
802
KFENCE_KUNIT_CASE (test_corruption ),
0 commit comments