]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
tracing/probes: Make the $ prefix mandatory for comm access
authorMasami Hiramatsu (Google) <mhiramat@kernel.org>
Wed, 24 Jun 2026 23:34:48 +0000 (08:34 +0900)
committerMasami Hiramatsu (Google) <mhiramat@kernel.org>
Tue, 30 Jun 2026 14:58:20 +0000 (23:58 +0900)
Since $comm or $COMM are not event field but special fetcharg
variables to access current->comm, It should not be accessed
without '$' prefix even with typecast.

Link: https://lore.kernel.org/all/178231209724.732967.12049805699091810641.stgit@devnote2/
Fixes: 69efd863a785 ("tracing/eprobes: Allow use of BTF names to dereference pointers")
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
kernel/trace/trace_probe.c

index 502fa6da59492b1779b7015a2cfd4c67da79010d..d17cfee77d9cea337539ff44e3ec6a278f8aa5bf 100644 (file)
@@ -342,10 +342,6 @@ static int parse_trace_event(char *arg, struct fetch_insn *code,
        ret = parse_trace_event_arg(arg, code, ctx);
        if (!ret)
                return 0;
-       if (strcmp(arg, "comm") == 0 || strcmp(arg, "COMM") == 0) {
-               code->op = FETCH_OP_COMM;
-               return 0;
-       }
        return -EINVAL;
 }
 
@@ -1068,8 +1064,14 @@ static int parse_probe_vars(char *orig_arg, const struct fetch_type *t,
        int len;
 
        if (ctx->flags & TPARG_FL_TEVENT) {
-               if (parse_trace_event(arg, code, ctx) < 0)
+               if (parse_trace_event(arg, code, ctx) < 0) {
+                       /* 'comm' should be checked after field parsing. */
+                       if (strcmp(arg, "comm") == 0 || strcmp(arg, "COMM") == 0) {
+                               code->op = FETCH_OP_COMM;
+                               return 0;
+                       }
                        goto inval;
+               }
                return 0;
        }