linux-stable/include/trace
Steven Rostedt (Google) 7ec10a27d6 tracing: Use a copy of the va_list for __assign_vstr()
commit 3a2dcbaf4d upstream.

If an instance of tracing enables the same trace event as another
instance, or the top level instance, or even perf, then the va_list passed
into some tracepoints can be used more than once.

As va_list can only be traversed once, this can cause issues:

 # cat /sys/kernel/tracing/instances/qla2xxx/trace
             cat-56106   [012] ..... 2419873.470098: ql_dbg_log: qla2xxx [0000:05:00.0]-1054:14:  Entered (null).
             cat-56106   [012] ..... 2419873.470101: ql_dbg_log: qla2xxx [0000:05:00.0]-1000:14:  Entered ×+<96>²Ü<98>^H.
             cat-56106   [012] ..... 2419873.470102: ql_dbg_log: qla2xxx [0000:05:00.0]-1006:14:  Prepare to issue mbox cmd=0xde589000.

 # cat /sys/kernel/tracing/trace
             cat-56106   [012] ..... 2419873.470097: ql_dbg_log: qla2xxx [0000:05:00.0]-1054:14:  Entered qla2x00_get_firmware_state.
             cat-56106   [012] ..... 2419873.470100: ql_dbg_log: qla2xxx [0000:05:00.0]-1000:14:  Entered qla2x00_mailbox_command.
             cat-56106   [012] ..... 2419873.470102: ql_dbg_log: qla2xxx [0000:05:00.0]-1006:14:  Prepare to issue mbox cmd=0x69.

The instance version is corrupted because the top level instance iterated
the va_list first.

Use va_copy() in the __assign_vstr() macro to make sure that each trace
event for each use case gets a fresh va_list.

Link: https://lore.kernel.org/all/259d53a5-958e-6508-4e45-74dba2821242@marvell.com/
Link: https://lkml.kernel.org/r/20220719182004.21daa83e@gandalf.local.home

Fixes: 0563231f93 ("tracing/events: Add __vstring() and __assign_vstr() helper macros")
Reported-by: Arun Easi <aeasi@marvell.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-08-17 14:42:34 +02:00
..
events spmi: trace: fix stack-out-of-bound access in SPMI tracing functions 2022-08-17 14:42:20 +02:00
stages tracing: Use a copy of the va_list for __assign_vstr() 2022-08-17 14:42:34 +02:00
bpf_probe.h tracing: Introduce helpers to safely handle dynamic-sized sockaddrs 2022-02-28 10:26:38 -05:00
define_custom_trace.h tracing: Add TRACE_CUSTOM_EVENT() macro 2022-03-11 11:49:24 -05:00
define_trace.h
perf.h tracing: Introduce helpers to safely handle dynamic-sized sockaddrs 2022-02-28 10:26:38 -05:00
syscall.h tracepoints: Migrate to use SYSCALL_WORK flag 2020-11-16 21:53:15 +01:00
trace_custom_events.h tracing: Rename the staging files for trace_events 2022-04-02 08:40:04 -04:00
trace_events.h tracing: Rename the staging files for trace_events 2022-04-02 08:40:04 -04:00