tracing/probes: Add string type check with BTF
authorMasami Hiramatsu (Google) <mhiramat@kernel.org>
Tue, 22 Aug 2023 16:26:32 +0000 (01:26 +0900)
committerMasami Hiramatsu (Google) <mhiramat@kernel.org>
Wed, 23 Aug 2023 00:41:13 +0000 (09:41 +0900)
commit27973e5c64b9e6dbea06a3ee86ed7509147b3848
treeaadf61b9eb2eb851a160b3587fdb5daf4770e042
parentd157d7694460b9aa5b974c37b1ad5fb10c8f8b7c
tracing/probes: Add string type check with BTF

Add a string type checking with BTF information if possible.
This will check whether the given BTF argument (and field) is
signed char array or pointer to signed char. If not, it reject
the 'string' type. If it is pointer to signed char, it adds
a dereference opration so that it can correctly fetch the
string data from memory.

 # echo 'f getname_flags%return retval->name:string' >> dynamic_events
 # echo 't sched_switch next->comm:string' >> dynamic_events

The above cases, 'struct filename::name' is 'char *' and
'struct task_struct::comm' is 'char []'. But in both case,
user can specify ':string' to fetch the string data.

Link: https://lore.kernel.org/all/169272159250.160970.1881112937198526188.stgit@devnote2/
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Acked-by: Steven Rostedt (Google) <rostedt@goodmis.org>
kernel/trace/trace_probe.c
kernel/trace/trace_probe.h