OSDN Git Service

tracing: Add check of trace event print fmts for dereferencing pointers
authorSteven Rostedt (VMware) <rostedt@goodmis.org>
Thu, 25 Feb 2021 21:51:23 +0000 (16:51 -0500)
committerSteven Rostedt (VMware) <rostedt@goodmis.org>
Thu, 18 Mar 2021 16:58:26 +0000 (12:58 -0400)
commit5013f454a352cce8e62162976026a9c472595e42
tree2751610508db73285c0c3ba59e3b254b6ef826a2
parente0196ae732343adfe8d854d88b3c0aae9595152f
tracing: Add check of trace event print fmts for dereferencing pointers

Trace events record data into the ring buffer at the time of the event. The
trace event has a printf logic to display the recorded data at a much later
time when the user reads the trace file. This makes using dereferencing
pointers unsafe if the dereferenced pointer points to the original source.
The safe way to handle this is to create an array within the trace event and
copy the source into the array. Then the dereference pointer may point to
that array.

As this is a easy mistake to make, a check is added to examine all trace
event print fmts to make sure that they are safe to use. This only checks
the various %p* dereferenced pointers like %pB, %pR, etc. It does not handle
dereferencing of strings, as there are some use cases that are OK to
dereference the source. That will be dealt with differently.

Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
kernel/trace/trace_events.c