Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tracing/eprobes: Do not hardcode $comm as a string

The variable $comm is hard coded as a string, which is true for both
kprobes and uprobes, but for event probes (eprobes) it is a field name. In
most cases the "comm" field would be a string, but there's no guarantee of
that fact.

Do not assume that comm is a string. Not to mention, it currently forces
comm fields to fault, as string processing for event probes is currently
broken.

Link: https://lkml.kernel.org/r/20220820134400.756152112@goodmis.org

Cc: stable@vger.kernel.org
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Tzvetomir Stoyanov <tz.stoyanov@gmail.com>
Cc: Tom Zanussi <zanussi@kernel.org>
Fixes: 7491e2c44278 ("tracing: Add a probe that attaches to trace events")
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>

+3 -2
+3 -2
kernel/trace/trace_probe.c
··· 622 622 623 623 /* 624 624 * Since $comm and immediate string can not be dereferenced, 625 - * we can find those by strcmp. 625 + * we can find those by strcmp. But ignore for eprobes. 626 626 */ 627 - if (strcmp(arg, "$comm") == 0 || strncmp(arg, "\\\"", 2) == 0) { 627 + if (!(flags & TPARG_FL_TPOINT) && 628 + (strcmp(arg, "$comm") == 0 || strncmp(arg, "\\\"", 2) == 0)) { 628 629 /* The type of $comm must be "string", and not an array. */ 629 630 if (parg->count || (t && strcmp(t, "string"))) 630 631 goto out;