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

tracing/probes: Avoid setting TPARG_FL_FENTRY and TPARG_FL_RETURN

When parsing a kprobe event, the return probe always sets both
TPARG_FL_RETURN and TPARG_FL_FENTRY, but this is not useful because
some fetchargs are only for return probe and some others only for
function entry. Make it obviously mutual exclusive.

Link: https://lore.kernel.org/all/168507468731.913472.11354553441385410734.stgit@mhiramat.roam.corp.google.com/

Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>

+6 -1
+1 -1
kernel/trace/trace_kprobe.c
··· 825 825 if (is_return) 826 826 flags |= TPARG_FL_RETURN; 827 827 ret = kprobe_on_func_entry(NULL, symbol, offset); 828 - if (ret == 0) 828 + if (ret == 0 && !is_return) 829 829 flags |= TPARG_FL_FENTRY; 830 830 /* Defer the ENOENT case until register kprobe */ 831 831 if (ret == -EINVAL && is_return) {
+5
kernel/trace/trace_probe.h
··· 357 357 #define trace_probe_for_each_link_rcu(pos, tp) \ 358 358 list_for_each_entry_rcu(pos, &(tp)->event->files, list) 359 359 360 + /* 361 + * The flags used for parsing trace_probe arguments. 362 + * TPARG_FL_RETURN, TPARG_FL_FENTRY and TPARG_FL_TPOINT are mutually exclusive. 363 + * TPARG_FL_KERNEL and TPARG_FL_USER are also mutually exclusive. 364 + */ 360 365 #define TPARG_FL_RETURN BIT(0) 361 366 #define TPARG_FL_KERNEL BIT(1) 362 367 #define TPARG_FL_FENTRY BIT(2)