tracing: Export live module tracepoint strings in printk_formats
tracepoint_string() mappings for built-in strings are exported through
printk_formats, but the module loader does not collect __tracepoint_str.
Consequently, user space cannot resolve these module string pointers.
Collect the module section and expose its live address-to-text mappings.
Serialize registration, removal and the full printk_formats seq_file
iteration with btrace_mutex. Remove the range before module memory is
freed; do not retain strings after unload.
Keep trace_is_tracepoint_string() and event string validation unchanged.
Exporting decoder metadata does not require accepting module pointers in
core or other modules' events, nor does it extend the strings' lifetime.
Count successfully retained unique module trace_printk formats so the
iterator can locate the following module string ranges. These formats
remain retained after unload, so the count is not decremented.
Add a sample TRACE_EVENT and a dedicated selftest for multiple exported
strings, event output and mapping removal. Make unload and every residual
string/read-error check fail explicitly.
Link: https://patch.msgid.link/4b28954d.85c9.1a19b73b227.Coremail.create0818@163.com
Fixes: 102c9323c35a ("tracing: Add __tracepoint_string() to export string pointers")
Closes: https://bugzilla.kernel.org/show_bug.cgi?id=217196
Link: https://lore.kernel.org/r/41e81533-0fd6-49f5-b7c1-b4e172affd2a@suse.com
Link: https://lore.kernel.org/r/20261030173049.6656d506@gandalf.local.home
Suggested-by: Petr Pavlu <petr.pavlu@suse.com>
Assisted-by: LLM (GPT-6.1-Sol)
Signed-off-by: Cao Ruichuang <create0818@163.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
7 files changed