File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -285,6 +285,24 @@ static noinline void __init kmalloc_oob_in_memset(void)
285
285
kfree (ptr );
286
286
}
287
287
288
+ static noinline void __init kmalloc_memmove_invalid_size (void )
289
+ {
290
+ char * ptr ;
291
+ size_t size = 64 ;
292
+ volatile size_t invalid_size = -2 ;
293
+
294
+ pr_info ("invalid size in memmove\n" );
295
+ ptr = kmalloc (size , GFP_KERNEL );
296
+ if (!ptr ) {
297
+ pr_err ("Allocation failed\n" );
298
+ return ;
299
+ }
300
+
301
+ memset ((char * )ptr , 0 , 64 );
302
+ memmove ((char * )ptr , (char * )ptr + 4 , invalid_size );
303
+ kfree (ptr );
304
+ }
305
+
288
306
static noinline void __init kmalloc_uaf (void )
289
307
{
290
308
char * ptr ;
@@ -799,6 +817,7 @@ static int __init kmalloc_tests_init(void)
799
817
kmalloc_oob_memset_4 ();
800
818
kmalloc_oob_memset_8 ();
801
819
kmalloc_oob_memset_16 ();
820
+ kmalloc_memmove_invalid_size ();
802
821
kmalloc_uaf ();
803
822
kmalloc_uaf_memset ();
804
823
kmalloc_uaf2 ();
You can’t perform that action at this time.
0 commit comments