From: Paul Cacheux via B4 Relay <devnull+paulcacheux.gmail.com@kernel.org>
To: Steven Rostedt <rostedt@goodmis.org>,
Masami Hiramatsu <mhiramat@kernel.org>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
Namhyung Kim <namhyung@kernel.org>
Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
Paul Cacheux <paulcacheux@gmail.com>
Subject: [PATCH v2 0/2] tracing: fix race when creating trace probe log error message
Date: Fri, 02 May 2025 15:15:51 +0200 [thread overview]
Message-ID: <20250502-fix-trace-probe-log-race-v2-0-511ecc1521ec@gmail.com> (raw)
Hello,
As reported in [1] a race exists in the shared trace probe log
used to build error messages. This can cause kernel crashes
when building the actual error message, but the race happens
even for non-error tracefs uses, it's just not visible.
Reproducer first reported that is still crashing:
# 'p4' is invalid command which make kernel run into trace_probe_log_err()
cd /sys/kernel/debug/tracing
while true; do
echo 'p4:myprobe1 do_sys_openat2 dfd=%ax filename=%dx flags=%cx mode=+4($stack)' >> kprobe_events &
echo 'p4:myprobe2 do_sys_openat2' >> kprobe_events &
echo 'p4:myprobe3 do_sys_openat2 dfd=%ax filename=%dx' >> kprobe_events &
done;
The original email suggested to use a mutex or to allocate the
trace_probe_log on the stack. This patch implements a simpler
solution suggest during the review of the v1 where we only protect
access to the shared trace_probe_log with a mutex. This will prevent
any crash from happening.
[1] https://lore.kernel.org/all/20221121081103.3070449-1-zhengyejian1@huawei.com/T/
Signed-off-by: Paul Cacheux <paulcacheux@gmail.com>
---
Changes in v2:
- change approach, and use the mutex based solution suggested during
review
- Link to v1: https://lore.kernel.org/r/20250422-fix-trace-probe-log-race-v1-1-d2728d42cacb@gmail.com
---
Paul Cacheux (2):
tracing: add missing trace_probe_log_clear for eprobes
tracing: protect trace_probe_log with mutex
kernel/trace/trace_eprobe.c | 3 +++
kernel/trace/trace_probe.c | 6 ++++++
2 files changed, 9 insertions(+)
---
base-commit: ebd297a2affadb6f6f4d2e5d975c1eda18ac762d
change-id: 20250420-fix-trace-probe-log-race-cc89d8e5fb15
Best regards,
--
Paul Cacheux <paulcacheux@gmail.com>
next reply other threads:[~2025-05-02 13:16 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-02 13:15 Paul Cacheux via B4 Relay [this message]
2025-05-02 13:15 ` [PATCH v2 1/2] tracing: add missing trace_probe_log_clear for eprobes Paul Cacheux via B4 Relay
2025-05-09 22:18 ` Masami Hiramatsu
2025-05-02 13:15 ` [PATCH v2 2/2] tracing: protect trace_probe_log with mutex Paul Cacheux via B4 Relay
2025-05-02 13:50 ` Steven Rostedt
2025-05-07 6:49 ` Paul Cacheux
2025-05-09 22:44 ` Masami Hiramatsu
2025-05-09 23:57 ` Masami Hiramatsu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250502-fix-trace-probe-log-race-v2-0-511ecc1521ec@gmail.com \
--to=devnull+paulcacheux.gmail.com@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mhiramat@kernel.org \
--cc=namhyung@kernel.org \
--cc=paulcacheux@gmail.com \
--cc=rostedt@goodmis.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).