tracing: Remove "__attribute__()" from the type field of event format
Steven Rostedt
maintainerPATCH 1/1 tracing: Remove "__attribute__()" from the type field of event format
git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace.git
trace/for-next
Head SHA1: 1a967e92bf47cf5170336b88d748117c700edc47
Masami Hiramatsu (Google) (1):
tracing: Remove "__attribute__()" from the type field of event format
----
kernel/trace/trace.c | 28 ++++++---- kernel/trace/trace.h | 4 +- kernel/trace/trace_events.c | 128 ++++++++++++++++++++++++++++++++++++-------- 3 files changed, 127 insertions(+), 33 deletions(-) --------------------------- commit 1a967e92bf47cf5170336b88d748117c700edc47 Author: Masami Hiramatsu (Google) <[email protected]> Date: Tue Jul 29 14:10:35 2025 +0900
tracing: Remove "__attribute__()" from the type field of event format
With CONFIG_DEBUG_INFO_BTF=y and PAHOLE_HAS_BTF_TAG=y, `__user` is
converted to `__attribute__((btf_type_tag("user")))`. In this case,
some syscall events have it for __user data, like below;
/sys/kernel/tracing # cat events/syscalls/sys_enter_openat/format
name: sys_enter_openat
ID: 720
format:
field:unsigned short common_type; offset:0; size:2; signed:0;
field:unsigned char common_flags; offset:2; size:1; signed:0;
field:unsigned char common_preempt_count; offset:3; size:1; signed:0;
field:int common_pid; offset:4; size:4; signed:1;
field:int __syscall_nr; offset:8; size:4; signed:1;
field:int dfd; offset:16; size:8; signed:0;
field:const char __attribute__((btf_type_tag("user"))) * filename; offset:24; size:8; signed:0;
field:int flags; offset:32; size:8; signed:0;
field:umode_t mode; offset:40; size:8; signed:0;
Then the trace event filter fails to set the string acceptable flag
(FILTER_PTR_STRING) to the field and rejects setting string filter;
# echo 'filename.ustring ~ "*ftracetest-dir.wbx24v*"' \
>> events/syscalls/sys_enter_openat/filter
sh: write error: Invalid argument
# cat error_log
[ 723.743637] event filter parse error: error: Expecting numeric field
Command: filename.ustring ~ "*ftracetest-dir.wbx24v*"
Since this __attribute__ makes format parsing complicated and not
needed, remove the __attribute__(.*) from the type string.
Cc: Mathieu Desnoyers <[email protected]>
Link: https://lore.kernel.org/175376583493.1688759.12333973498014733551.stgit@mhiramat.tok.corp.google.com
Signed-off-by: Masami Hiramatsu (Google) <[email protected]>
Signed-off-by: Steven Rostedt (Google) <[email protected]>kernel/trace/trace.c +18 -10
@@ -5930,17 +5930,27 @@ static inline void trace_insert_eval_map_file(struct module *mod, struct trace_eval_map **start, int len) { }#endif /* !CONFIG_TRACE_EVAL_MAP_FILE */ -static void trace_insert_eval_map (struct module *mod, -struct trace_eval_map **start,int len) +static void +trace_event_update_with_eval_map (struct module *mod, +struct trace_eval_map **start, +int len) {struct trace_eval_map **map; -if (len <=0 ) -return ; +/* Always run sanitizer only if btf_type_tag attr exists. */ +if (len <=0 ) { +if (!(IS_ENABLED (CONFIG_DEBUG_INFO_BTF ) && +IS_ENABLED (CONFIG_PAHOLE_HAS_BTF_TAG ) && +__has_attribute (btf_type_tag))) +return ; + } map = start; -trace_event_eval_update (map, len); +trace_event_update_all (map, len); + +if (len <=0 ) +return ;trace_insert_eval_map_file (mod, start, len); }
@@ -10334,7 +10344,7 @@ static void __init eval_map_work_func(struct work_struct *work)int len; len = __stop_ftrace_eval_maps - __start_ftrace_eval_maps; -trace_insert_eval_map (NULL , __start_ftrace_eval_maps, len); +trace_event_update_with_eval_map (NULL , __start_ftrace_eval_maps, len); }static int __init trace_eval_init (void )
@@ -10387,9 +10397,6 @@ bool module_exists(const char *module)static void trace_module_add_evals (struct module *mod) { -if (!mod->num_trace_evals) -return ; -/* * Modules with bad taint do not have events created, do * not bother with enums either.
@@ -10397,7 +10404,8 @@ static void trace_module_add_evals(struct module *mod)if (trace_module_has_bad_taint (mod))return ; -trace_insert_eval_map (mod, mod->trace_evals, mod->num_trace_evals); +/* Even if no trace_evals, this need to sanitize field types. */ +trace_event_update_with_eval_map (mod, mod->trace_evals, mod->num_trace_evals); }#ifdef CONFIG_TRACE_EVAL_MAP_FILE
kernel/trace/trace.h +2 -2
@@ -2125,13 +2125,13 @@ static inline const char *get_syscall_name(int syscall)#ifdef CONFIG_EVENT_TRACING void trace_event_init (void ); -void trace_event_eval_update (struct trace_eval_map **map,int len); +void trace_event_update_all (struct trace_eval_map **map,int len);/* Used from boot time tracer */ extern int ftrace_set_clr_event (struct trace_array *tr,char *buf,int set);extern int trigger_process_regex (struct trace_event_file *file,char *buff);#else static inline void __init trace_event_init (void ) { } -static inline void trace_event_eval_update (struct trace_eval_map **map,int len) { } +static inline void trace_event_update_all (struct trace_eval_map **map,int len) { }#endif #ifdef CONFIG_TRACER_SNAPSHOT
kernel/trace/trace_events.c +107 -21
178 lines not on this page · raw message