]> www.infradead.org Git - users/jedix/linux-maple.git/commit
tracing: Handle NULL formats in hold_module_trace_bprintk_format()
authorSteven Rostedt (Red Hat) <rostedt@goodmis.org>
Fri, 17 Jun 2016 20:10:42 +0000 (16:10 -0400)
committerDhaval Giani <dhaval.giani@oracle.com>
Fri, 20 Jan 2017 22:21:57 +0000 (17:21 -0500)
commit99b1e39721b81616634bbc9ef61b3b6182321a0a
treed7b779deb665c49b0d4e844b01ef3b33ee8e5888
parent7640eb2168ec4996d8ca4db369d9f0485b973f4f
tracing: Handle NULL formats in hold_module_trace_bprintk_format()

Orabug: 25308021

[ Upstream commit 70c8217acd4383e069fe1898bbad36ea4fcdbdcc ]

If a task uses a non constant string for the format parameter in
trace_printk(), then the trace_printk_fmt variable is set to NULL. This
variable is then saved in the __trace_printk_fmt section.

The function hold_module_trace_bprintk_format() checks to see if duplicate
formats are used by modules, and reuses them if so (saves them to the list
if it is new). But this function calls lookup_format() that does a strcmp()
to the value (which is now NULL) and can cause a kernel oops.

This wasn't an issue till 3debb0a9ddb ("tracing: Fix trace_printk() to print
when not using bprintk()") which added "__used" to the trace_printk_fmt
variable, and before that, the kernel simply optimized it out (no NULL value
was saved).

The fix is simply to handle the NULL pointer in lookup_format() and have the
caller ignore the value if it was NULL.

Link: http://lkml.kernel.org/r/1464769870-18344-1-git-send-email-zhengjun.xing@intel.com
Reported-by: xingzhen <zhengjun.xing@intel.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Fixes: 3debb0a9ddb ("tracing: Fix trace_printk() to print when not using bprintk()")
Cc: stable@vger.kernel.org # v3.5+
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
(cherry picked from commit 335f166ee3341efcf402c46ea0e7d6362e7c9122)
Signed-off-by: Dhaval Giani <dhaval.giani@oracle.com>
kernel/trace/trace_printk.c