mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-07-16 17:57:38 -04:00
ftrace,kcfi: Separate ftrace_stub() and ftrace_stub_graph()
Different function signatures means they needs to be different
functions; otherwise CFI gets upset.
As triggered by the ftrace boot tests:
[] CFI failure at ftrace_return_to_handler+0xac/0x16c (target: ftrace_stub+0x0/0x14; expected type: 0x0a5d5347)
Fixes: 3c516f89e1 ("x86: Add support for CONFIG_CFI_CLANG")
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Mark Rutland <mark.rutland@arm.com>
Tested-by: Mark Rutland <mark.rutland@arm.com>
Link: https://lkml.kernel.org/r/Y06dg4e1xF6JTdQq@hirez.programming.kicks-ass.net
This commit is contained in:
@@ -162,6 +162,16 @@
|
||||
#define PATCHABLE_DISCARDS *(__patchable_function_entries)
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_ARCH_SUPPORTS_CFI_CLANG
|
||||
/*
|
||||
* Simply points to ftrace_stub, but with the proper protocol.
|
||||
* Defined by the linker script in linux/vmlinux.lds.h
|
||||
*/
|
||||
#define FTRACE_STUB_HACK ftrace_stub_graph = ftrace_stub;
|
||||
#else
|
||||
#define FTRACE_STUB_HACK
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_FTRACE_MCOUNT_RECORD
|
||||
/*
|
||||
* The ftrace call sites are logged to a section whose name depends on the
|
||||
@@ -169,10 +179,6 @@
|
||||
* FTRACE_CALLSITE_SECTION. We capture all of them here to avoid header
|
||||
* dependencies for FTRACE_CALLSITE_SECTION's definition.
|
||||
*
|
||||
* Need to also make ftrace_stub_graph point to ftrace_stub
|
||||
* so that the same stub location may have different protocols
|
||||
* and not mess up with C verifiers.
|
||||
*
|
||||
* ftrace_ops_list_func will be defined as arch_ftrace_ops_list_func
|
||||
* as some archs will have a different prototype for that function
|
||||
* but ftrace_ops_list_func() will have a single prototype.
|
||||
@@ -182,11 +188,11 @@
|
||||
KEEP(*(__mcount_loc)) \
|
||||
KEEP_PATCHABLE \
|
||||
__stop_mcount_loc = .; \
|
||||
ftrace_stub_graph = ftrace_stub; \
|
||||
FTRACE_STUB_HACK \
|
||||
ftrace_ops_list_func = arch_ftrace_ops_list_func;
|
||||
#else
|
||||
# ifdef CONFIG_FUNCTION_TRACER
|
||||
# define MCOUNT_REC() ftrace_stub_graph = ftrace_stub; \
|
||||
# define MCOUNT_REC() FTRACE_STUB_HACK \
|
||||
ftrace_ops_list_func = arch_ftrace_ops_list_func;
|
||||
# else
|
||||
# define MCOUNT_REC()
|
||||
|
||||
Reference in New Issue
Block a user