]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.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)
committerStefan Bader <stefan.bader@canonical.com>
Fri, 20 May 2022 12:37:37 +0000 (14:37 +0200)
commit854b70c441723ed563310a84eea0b805f6e80382
tree946634812836ac0cefb061fd0f7120ba21839a79
parent997abf2778f4b82516d9b154827db653a40751cd
tracing: Have trace event string test handle zero length strings

BugLink: https://bugs.launchpad.net/bugs/1969110
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>
(cherry picked from commit 39483fd3b2d2bb324a65329a538061cc64109e62)
Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
kernel/trace/trace.c