[PATCH v3 08/13] tracing/probes: Reject array count on non-dereference string sources
From: Masami Hiramatsu (Google)
Date: Fri Nov 13 2026 - 10:03:38 EST
From: Masami Hiramatsu (Google) <mhiramat@xxxxxxxxxx>
The runtime array loop (FETCH_OP_LP_ARRAY) for string types requires a
preceding memory dereference instruction so it can advance the pointer
address on each iteration. Non-dereference string sources such as $comm,
immediate strings, and eprobe event fields cannot be indexed as pointer
arrays, but finalize_fetch_insn() still accepts an array count on them
and emits an invalid FETCH_OP_LP_ARRAY sequence.
Reject string array counts when the preceding operation is not a memory
dereference.
Fixes: 40b53b771806 ("tracing: probeevent: Add array type support")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@xxxxxxxxxx>
---
Changes in v2:
- Add Fixes and Cc: stable tags.
---
kernel/trace/trace_probe.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/kernel/trace/trace_probe.c b/kernel/trace/trace_probe.c
index eee5353ef5c7..9c789ca316b7 100644
--- a/kernel/trace/trace_probe.c
+++ b/kernel/trace/trace_probe.c
@@ -1990,6 +1990,12 @@ static int finalize_fetch_insn(struct fetch_insn *code,
* For the symstr, it doesn't need to dereference, thus
* it just get the value.
*/
+ if (parg->count && (code->op != FETCH_OP_DEREF &&
+ code->op != FETCH_OP_UDEREF)) {
+ trace_probe_log_err(ctx->offset + type_offset,
+ BAD_STRING);
+ return -EINVAL;
+ }
code++;
if (code->op != FETCH_OP_NOP) {
trace_probe_log_err(ctx->offset, TOO_MANY_OPS);