Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

samples/ftrace: Mark my_tramp[12]? global

my_tramp[12]? are declared as global functions in C, but they are not
marked global in the inline assembly definition. This mismatch confuses
Clang's Control-Flow Integrity checking. Fix the definitions by adding
.globl.

Link: https://lkml.kernel.org/r/20201113183414.1446671-1-samitolvanen@google.com

Fixes: 9d907f1ae80b8 ("ftrace/samples: Add a sample module that implements modify_ftrace_direct()")
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>

authored by

Sami Tolvanen and committed by
Steven Rostedt (VMware)
983df5f2 8785f51a

+4
+2
samples/ftrace/ftrace-direct-modify.c
··· 21 21 asm ( 22 22 " .pushsection .text, \"ax\", @progbits\n" 23 23 " .type my_tramp1, @function\n" 24 + " .globl my_tramp1\n" 24 25 " my_tramp1:" 25 26 " pushq %rbp\n" 26 27 " movq %rsp, %rbp\n" ··· 30 29 " .size my_tramp1, .-my_tramp1\n" 31 30 " ret\n" 32 31 " .type my_tramp2, @function\n" 32 + " .globl my_tramp2\n" 33 33 " my_tramp2:" 34 34 " pushq %rbp\n" 35 35 " movq %rsp, %rbp\n"
+1
samples/ftrace/ftrace-direct-too.c
··· 16 16 asm ( 17 17 " .pushsection .text, \"ax\", @progbits\n" 18 18 " .type my_tramp, @function\n" 19 + " .globl my_tramp\n" 19 20 " my_tramp:" 20 21 " pushq %rbp\n" 21 22 " movq %rsp, %rbp\n"
+1
samples/ftrace/ftrace-direct.c
··· 14 14 asm ( 15 15 " .pushsection .text, \"ax\", @progbits\n" 16 16 " .type my_tramp, @function\n" 17 + " .globl my_tramp\n" 17 18 " my_tramp:" 18 19 " pushq %rbp\n" 19 20 " movq %rsp, %rbp\n"