@@ -28,6 +28,13 @@ static const unsigned long rodata = 0xAA55AA55;
28
28
/* This is marked __ro_after_init, so it should ultimately be .rodata. */
29
29
static unsigned long ro_after_init __ro_after_init = 0x55AA5500 ;
30
30
31
+ /*
32
+ * This is a pointer to do_nothing() which is initialized at runtime rather
33
+ * than build time to avoid objtool IBT validation warnings caused by an
34
+ * inlined unrolled memcpy() in execute_location().
35
+ */
36
+ static void __ro_after_init * do_nothing_ptr ;
37
+
31
38
/*
32
39
* This just returns to the caller. It is designed to be copied into
33
40
* non-executable memory regions.
@@ -65,13 +72,12 @@ static noinline __nocfi void execute_location(void *dst, bool write)
65
72
{
66
73
void (* func )(void );
67
74
func_desc_t fdesc ;
68
- void * do_nothing_text = dereference_function_descriptor (do_nothing );
69
75
70
- pr_info ("attempting ok execution at %px\n" , do_nothing_text );
76
+ pr_info ("attempting ok execution at %px\n" , do_nothing_ptr );
71
77
do_nothing ();
72
78
73
79
if (write == CODE_WRITE ) {
74
- memcpy (dst , do_nothing_text , EXEC_SIZE );
80
+ memcpy (dst , do_nothing_ptr , EXEC_SIZE );
75
81
flush_icache_range ((unsigned long )dst ,
76
82
(unsigned long )dst + EXEC_SIZE );
77
83
}
@@ -267,6 +273,8 @@ static void lkdtm_ACCESS_NULL(void)
267
273
268
274
void __init lkdtm_perms_init (void )
269
275
{
276
+ do_nothing_ptr = dereference_function_descriptor (do_nothing );
277
+
270
278
/* Make sure we can write to __ro_after_init values during __init */
271
279
ro_after_init |= 0xAA ;
272
280
}
0 commit comments