From: "Masami Hiramatsu (Google)" <mhiramat@kernel.org>
To: Steven Rostedt <rostedt@goodmis.org>,
Masami Hiramatsu <mhiramat@kernel.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org
Subject: [PATCH 07/12] tracing/probes: Fix user-space dereference string array store type
Date: Mon, 9 Nov 2026 09:29:07 +0900 [thread overview]
Message-ID: <179418414754.227715.9900534226622724613.stgit@devnote2> (raw)
In-Reply-To: <179418408457.227715.1485179201014819821.stgit@devnote2>
From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
When finalizing a string array argument (e.g. +0u(%reg):string[N]),
finalize_fetch_insn() advances the instruction pointer to a new slot
for the store operation before checking whether the preceding operation
was FETCH_OP_UDEREF. As a result, user-space dereference string arrays
with type "string" emit FETCH_OP_ST_STRING (kernel memory read) instead
of FETCH_OP_ST_USTRING.
Check for FETCH_OP_UDEREF before advancing the instruction pointer.
Fixes: e65f7ae7f4da ("tracing/probe: Support user-space dereference")
Cc: stable@vger.kernel.org
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
---
kernel/trace/trace_probe.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/kernel/trace/trace_probe.c b/kernel/trace/trace_probe.c
index 829fa6559b59..e62acf05a8ee 100644
--- a/kernel/trace/trace_probe.c
+++ b/kernel/trace/trace_probe.c
@@ -1952,6 +1952,8 @@ static int finalize_fetch_insn(struct fetch_insn *code,
/* Store operation */
if (parg->type->is_string) {
+ bool is_uderef;
+
/* Check bad combination of the type and the last fetch_insn. */
if (!strcmp(parg->type->name, "symstr")) {
if (code->op != FETCH_OP_REG && code->op != FETCH_OP_STACK &&
@@ -1971,6 +1973,7 @@ static int finalize_fetch_insn(struct fetch_insn *code,
}
}
+ is_uderef = (code->op == FETCH_OP_UDEREF);
if (!strcmp(parg->type->name, "symstr") ||
(code->op == FETCH_OP_IMM || code->op == FETCH_OP_COMM ||
code->op == FETCH_OP_IMMSTR) || code->op == FETCH_OP_TP_ARG ||
@@ -1991,8 +1994,7 @@ static int finalize_fetch_insn(struct fetch_insn *code,
}
/* If op == DEREF, replace it with STRING */
- if (!strcmp(parg->type->name, "ustring") ||
- code->op == FETCH_OP_UDEREF)
+ if (!strcmp(parg->type->name, "ustring") || is_uderef)
code->op = FETCH_OP_ST_USTRING;
else if (!strcmp(parg->type->name, "symstr"))
code->op = FETCH_OP_ST_SYMSTR;
next prev parent reply other threads:[~2026-11-09 0:29 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-09 0:28 [PATCH 00/12] tracing/probes: Fix various bugs in dynamic probe events Masami Hiramatsu (Google)
2026-11-09 0:28 ` [PATCH 01/12] tracing/probes: Check enabled and busy state before unlinking sibling probes Masami Hiramatsu (Google)
2026-11-09 0:28 ` [PATCH 02/12] tracing/probes: Enable newly appended probe when target event is enabled Masami Hiramatsu (Google)
2026-11-09 0:28 ` [PATCH 03/12] tracing/probes: Fix BTF bitfield parsing and out-of-bounds buffer write Masami Hiramatsu (Google)
2026-11-09 0:28 ` [PATCH 04/12] tracing/probes: Fix missing BTF kind checks in char pointer/array helpers Masami Hiramatsu (Google)
2026-11-09 0:28 ` [PATCH 05/12] tracing/eprobe: Fix 1-byte signed field fetch in get_event_field() Masami Hiramatsu (Google)
2026-11-09 0:28 ` [PATCH 06/12] tracing/eprobe: Disallow attaching eprobes to fprobe events Masami Hiramatsu (Google)
2026-11-09 0:29 ` Masami Hiramatsu (Google) [this message]
2026-11-09 0:29 ` [PATCH 08/12] tracing/probes: Reject array count on non-dereference string sources Masami Hiramatsu (Google)
2026-11-09 0:29 ` [PATCH 09/12] tracing/probes: Allow symstr type for function entry arguments in return probes Masami Hiramatsu (Google)
2026-11-09 0:29 ` [PATCH 10/12] tracing/probes: Reject empty fetch expression for %pd and %pD Masami Hiramatsu (Google)
2026-11-09 0:29 ` [PATCH 11/12] tracing/probes: Validate command prefix in kprobe, uprobe, and eprobe Masami Hiramatsu (Google)
2026-11-09 0:29 ` [PATCH 12/12] tracing/probes: Propagate error codes in eprobe and fprobe creation Masami Hiramatsu (Google)
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=179418414754.227715.9900534226622724613.stgit@devnote2 \
--to=mhiramat@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.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
all inboxes | Powered by JetHome®