File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -102,6 +102,7 @@ enum ctype {
102
102
CT_EXEC_USERSPACE ,
103
103
CT_ACCESS_USERSPACE ,
104
104
CT_WRITE_RO ,
105
+ CT_WRITE_KERN ,
105
106
};
106
107
107
108
static char * cp_name [] = {
@@ -138,6 +139,7 @@ static char* cp_type[] = {
138
139
"EXEC_USERSPACE" ,
139
140
"ACCESS_USERSPACE" ,
140
141
"WRITE_RO" ,
142
+ "WRITE_KERN" ,
141
143
};
142
144
143
145
static struct jprobe lkdtm ;
@@ -317,6 +319,13 @@ static void do_nothing(void)
317
319
return ;
318
320
}
319
321
322
+ /* Must immediately follow do_nothing for size calculuations to work out. */
323
+ static void do_overwritten (void )
324
+ {
325
+ pr_info ("do_overwritten wasn't overwritten!\n" );
326
+ return ;
327
+ }
328
+
320
329
static noinline void corrupt_stack (void )
321
330
{
322
331
/* Use default char array length that triggers stack protection. */
@@ -496,6 +505,22 @@ static void lkdtm_do_action(enum ctype which)
496
505
497
506
break ;
498
507
}
508
+ case CT_WRITE_KERN : {
509
+ size_t size ;
510
+ unsigned char * ptr ;
511
+
512
+ size = (unsigned long )do_overwritten -
513
+ (unsigned long )do_nothing ;
514
+ ptr = (unsigned char * )do_overwritten ;
515
+
516
+ pr_info ("attempting bad %zu byte write at %p\n" , size , ptr );
517
+ memcpy (ptr , (unsigned char * )do_nothing , size );
518
+ flush_icache_range ((unsigned long )ptr ,
519
+ (unsigned long )(ptr + size ));
520
+
521
+ do_overwritten ();
522
+ break ;
523
+ }
499
524
case CT_NONE :
500
525
default :
501
526
break ;
You can’t perform that action at this time.
0 commit comments