]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
tracing: Have trace event string test handle zero length strings
authorSteven Rostedt (Google) <rostedt@goodmis.org>
Wed, 23 Mar 2022 14:32:51 +0000 (10:32 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 8 Apr 2022 11:57:23 +0000 (13:57 +0200)
commit84678a90bb1af872c35f428aa02a52be389ef222
treefb9bd91d5d1f426fcf10cafdfaf765ba4c0b75f6
parent700fe2d4e64bd3f42c0d547e5712e53cd0277cd5
tracing: Have trace event string test handle zero length strings

commit eca344a7362e0f34f179298fd8366bcd556eede1 upstream.

If a trace event has in its TP_printk():

 "%*.s", len, len ? __get_str(string) : NULL

It is perfectly valid if len is zero and passing in the NULL.
Unfortunately, the runtime string check at time of reading the trace sees
the NULL and flags it as a bad string and produces a WARN_ON().

Handle this case by passing into the test function if the format has an
asterisk (star) and if so, if the length is zero, then mark it as safe.

Link: https://lore.kernel.org/all/YjsWzuw5FbWPrdqq@bfoster/
Cc: stable@vger.kernel.org
Reported-by: Brian Foster <bfoster@redhat.com>
Tested-by: Brian Foster <bfoster@redhat.com>
Fixes: 9a6944fee68e2 ("tracing: Add a verifier to check string pointers for trace events")
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
kernel/trace/trace.c