mirror of
https://github.com/torvalds/linux.git
synced 2024-12-04 18:13:04 +00:00
983df5f269
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: 9d907f1ae8
("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>
49 lines
1.0 KiB
C
49 lines
1.0 KiB
C
// SPDX-License-Identifier: GPL-2.0-only
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/sched.h> /* for wake_up_process() */
|
|
#include <linux/ftrace.h>
|
|
|
|
void my_direct_func(struct task_struct *p)
|
|
{
|
|
trace_printk("waking up %s-%d\n", p->comm, p->pid);
|
|
}
|
|
|
|
extern void my_tramp(void *);
|
|
|
|
asm (
|
|
" .pushsection .text, \"ax\", @progbits\n"
|
|
" .type my_tramp, @function\n"
|
|
" .globl my_tramp\n"
|
|
" my_tramp:"
|
|
" pushq %rbp\n"
|
|
" movq %rsp, %rbp\n"
|
|
" pushq %rdi\n"
|
|
" call my_direct_func\n"
|
|
" popq %rdi\n"
|
|
" leave\n"
|
|
" ret\n"
|
|
" .size my_tramp, .-my_tramp\n"
|
|
" .popsection\n"
|
|
);
|
|
|
|
|
|
static int __init ftrace_direct_init(void)
|
|
{
|
|
return register_ftrace_direct((unsigned long)wake_up_process,
|
|
(unsigned long)my_tramp);
|
|
}
|
|
|
|
static void __exit ftrace_direct_exit(void)
|
|
{
|
|
unregister_ftrace_direct((unsigned long)wake_up_process,
|
|
(unsigned long)my_tramp);
|
|
}
|
|
|
|
module_init(ftrace_direct_init);
|
|
module_exit(ftrace_direct_exit);
|
|
|
|
MODULE_AUTHOR("Steven Rostedt");
|
|
MODULE_DESCRIPTION("Example use case of using register_ftrace_direct()");
|
|
MODULE_LICENSE("GPL");
|