]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
tracing: Fix potential null-pointer-access of entry in list 'tr->err_log'
authorZheng Yejian <zhengyejian1@huawei.com>
Mon, 14 Nov 2022 10:46:32 +0000 (18:46 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 26 Nov 2022 08:27:54 +0000 (09:27 +0100)
commit76f9434d2faa56c8458b2432361760407fdab3b8
treed1ef35ee29e304ff755f06e7b10f92e2f6693a0b
parent55788ebbe8b365b4375bd56b4ba7db79d393a370
tracing: Fix potential null-pointer-access of entry in list 'tr->err_log'

[ Upstream commit 067df9e0ad48a97382ab2179bbe773a13a846028 ]

Entries in list 'tr->err_log' will be reused after entry number
exceed TRACING_LOG_ERRS_MAX.

The cmd string of the to be reused entry will be freed first then
allocated a new one. If the allocation failed, then the entry will
still be in list 'tr->err_log' but its 'cmd' field is set to be NULL,
later access of 'cmd' is risky.

Currently above problem can cause the loss of 'cmd' information of first
entry in 'tr->err_log'. When execute `cat /sys/kernel/tracing/error_log`,
reproduce logs like:
  [   37.495100] trace_kprobe: error: Maxactive is not for kprobe(null) ^
  [   38.412517] trace_kprobe: error: Maxactive is not for kprobe
    Command: p4:myprobe2 do_sys_openat2
            ^

Link: https://lore.kernel.org/linux-trace-kernel/20221114104632.3547266-1-zhengyejian1@huawei.com
Fixes: 1581a884b7ca ("tracing: Remove size restriction on tracing_log_err cmd strings")
Signed-off-by: Zheng Yejian <zhengyejian1@huawei.com>
Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
kernel/trace/trace.c