Skip to content

Commit 0652a3d

Browse files
LekKitrostedt
authored andcommitted
tracing: Fix CFI violation in probestub being called by tprobes
The probestub is a function to allow tprobes to hook to a tracepoint to gain access to its parameters. The function itself is only referenced by the tracepoint structure which lives in the __tracepoint section. objtool explicitly ignores that section and when processing functions in the kernel, if it detects one that has no references it will seal it to have its ENDBR stripped on boot up. This means when a tprobe is attached to the sched_wakeup tracepoint, when it is triggered it will call __probestub_sched_wakeup and due to the missing ENDBR on a CFI-enabled machine it will take a #CP exception. Fix this by adding CFI_NOSEAL annotation to probestub declaration. Cc: stable@vger.kernel.org Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org> Link: https://patch.msgid.link/20260603153147.573589-1-eva.kurchatova@virtuozzo.com Fixes: d5173f7 ("objtool: Exclude __tracepoints data from ENDBR checks") Signed-off-by: Eva Kurchatova <eva.kurchatova@virtuozzo.com> [ Updated change log ] Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
1 parent e43ffb6 commit 0652a3d

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

include/linux/tracepoint.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <linux/rcupdate_trace.h>
2121
#include <linux/tracepoint-defs.h>
2222
#include <linux/static_call.h>
23+
#include <linux/cfi.h>
2324

2425
struct module;
2526
struct tracepoint;
@@ -389,6 +390,13 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p)
389390
void __probestub_##_name(void *__data, proto) \
390391
{ \
391392
} \
393+
/* \
394+
* Annotate the probestub 'CFI_NOSEAL' to stop objtool from \
395+
* requesting the kernel remove the ENDBR, because the only \
396+
* references to the function are in the __tracepoint section, \
397+
* that objtool doesn't scan. \
398+
*/ \
399+
CFI_NOSEAL(__probestub_##_name); \
392400
DEFINE_STATIC_CALL(tp_func_##_name, __traceiter_##_name); \
393401
DEFINE_RUST_DO_TRACE(_name, TP_PROTO(proto), TP_ARGS(args))
394402

0 commit comments

Comments
 (0)