History

tracing/probes: Make the $ prefix mandatory for comm access

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/

Masami Hiramatsu (Google) committed 4 months ago

Commit a3692991 parent 367c49d1 file · +7 −5Browse files

Unified · Split

kernel/trace/trace_probe.c+7−5
@@ -342,10 +342,6 @@ static int parse_trace_event(char *arg, struct fetch_insn *code, · 341 unmodified lines
342342 ret = parse_trace_event_arg(arg, code, ctx);
343343 if (!ret)
344344 return 0;
345− if (strcmp(arg, "comm") == 0 || strcmp(arg, "COMM") == 0) {
346− code->op = FETCH_OP_COMM;
347− return 0;
348− }
349345 return -EINVAL;
350346 }
351347
@@ -1068,8 +1064,14 @@ static int parse_probe_vars(char *orig_arg, const struct fetch_type *t, · 716 unmodified lines
10681064 int len;
10691065
10701066 if (ctx->flags & TPARG_FL_TEVENT) {
1071− if (parse_trace_event(arg, code, ctx) < 0)
1067+ if (parse_trace_event(arg, code, ctx) < 0) {
1068+ /* 'comm' should be checked after field parsing. */
1069+ if (strcmp(arg, "comm") == 0 || strcmp(arg, "COMM") == 0) {
1070+ code->op = FETCH_OP_COMM;
1071+ return 0;
1072+ }
10721073 goto inval;
1074+ }
10731075 return 0;
10741076 }
10751077