From a7584d2cd0fc4b10b3266939f3250b7e94cae63c Mon Sep 17 00:00:00 2001 From: Sami Tolvanen Date: Tue, 14 Apr 2020 16:37:11 -0700 Subject: [PATCH] ANDROID: x86: kprobes: fix references to optprobe_template_func optprobe_template_func is not marked as a global symbol, which conflicts with the C declaration and confuses LLVM when CFI is enabled. However, marking the symbol global results in a CFI jump table entry being generated for it, which makes objtool unhappy as the jump table contains a jump to .rodata. This change solves both issues by removing the C reference to optprobe_template_func and generates the STACK_FRAME_NON_STANDARD entry in inline assembly instead. Bug: 145210207 Change-Id: Ib19b86cf437277036fa218d6e8d7292f10bef940 Signed-off-by: Sami Tolvanen --- arch/x86/kernel/kprobes/opt.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/arch/x86/kernel/kprobes/opt.c b/arch/x86/kernel/kprobes/opt.c index 08eb23074f92..50d656dc60a1 100644 --- a/arch/x86/kernel/kprobes/opt.c +++ b/arch/x86/kernel/kprobes/opt.c @@ -103,6 +103,14 @@ static void synthesize_set_arg1(kprobe_opcode_t *addr, unsigned long val) asm ( ".pushsection .rodata\n" "optprobe_template_func:\n" + ".pushsection .discard.func_stack_frame_non_standard\n" + "__func_stack_frame_non_standard_optprobe_template_func:\n" +#ifdef CONFIG_64BIT + ".quad optprobe_template_func\n" +#else + ".long optprobe_template_func\n" +#endif + ".popsection\n" ".global optprobe_template_entry\n" "optprobe_template_entry:\n" #ifdef CONFIG_X86_64 @@ -154,9 +162,6 @@ asm ( "optprobe_template_end:\n" ".popsection\n"); -void optprobe_template_func(void); -STACK_FRAME_NON_STANDARD(optprobe_template_func); - #define TMPL_CLAC_IDX \ ((long)optprobe_template_clac - (long)optprobe_template_entry) #define TMPL_MOVE_IDX \