linux/kernel/trace
Masami Hiramatsu 97c753e62e tracing/kprobe: Fix to support kretprobe events on unloaded modules
Fix kprobe_on_func_entry() returns error code instead of false so that
register_kretprobe() can return an appropriate error code.

append_trace_kprobe() expects the kprobe registration returns -ENOENT
when the target symbol is not found, and it checks whether the target
module is unloaded or not. If the target module doesn't exist, it
defers to probe the target symbol until the module is loaded.

However, since register_kretprobe() returns -EINVAL instead of -ENOENT
in that case, it always fail on putting the kretprobe event on unloaded
modules. e.g.

Kprobe event:
/sys/kernel/debug/tracing # echo p xfs:xfs_end_io >> kprobe_events
[   16.515574] trace_kprobe: This probe might be able to register after target module is loaded. Continue.

Kretprobe event: (p -> r)
/sys/kernel/debug/tracing # echo r xfs:xfs_end_io >> kprobe_events
sh: write error: Invalid argument
/sys/kernel/debug/tracing # cat error_log
[   41.122514] trace_kprobe: error: Failed to register probe event
  Command: r xfs:xfs_end_io
             ^

To fix this bug, change kprobe_on_func_entry() to detect symbol lookup
failure and return -ENOENT in that case. Otherwise it returns -EINVAL
or 0 (succeeded, given address is on the entry).

Link: https://lkml.kernel.org/r/161176187132.1067016.8118042342894378981.stgit@devnote2

Cc: stable@vger.kernel.org
Fixes: 59158ec4ae ("tracing/kprobes: Check the probe on unloaded module correctly")
Reported-by: Jianlin Lv <Jianlin.Lv@arm.com>
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
2021-01-29 15:39:48 -05:00
..
blktrace.c Tracing updates for 5.11 2020-12-17 13:22:17 -08:00
bpf_trace.c Tracing updates for 5.11 2020-12-17 13:22:17 -08:00
bpf_trace.h
fgraph.c fgraph: Initialize tracing_graph_pause at task creation 2021-01-29 15:07:32 -05:00
ftrace_internal.h
ftrace.c Tracing updates for 5.11 2020-12-17 13:22:17 -08:00
Kconfig tracing/kprobes: Do the notrace functions check without kprobes on ftrace 2021-01-11 16:09:53 -05:00
kprobe_event_gen_test.c
Makefile ftrace: Add recording of functions that caused recursion 2020-11-06 08:42:26 -05:00
power-traces.c
preemptirq_delay_test.c
ring_buffer_benchmark.c
ring_buffer.c Tracing updates for 5.11 2020-12-17 13:22:17 -08:00
rpm-traces.c
synth_event_gen_test.c tracing: Remove the useless value assignment in test_create_synth_event() 2020-11-13 12:19:52 -05:00
trace_benchmark.c tracing: Fix some typos in comments 2020-11-10 20:39:40 -05:00
trace_benchmark.h
trace_boot.c tracing: Disable ftrace selftests when any tracer is running 2020-12-14 12:05:03 -05:00
trace_branch.c
trace_clock.c
trace_dynevent.c tracing: Fix some typos in comments 2020-11-10 20:39:40 -05:00
trace_dynevent.h tracing: Fix some typos in comments 2020-11-10 20:39:40 -05:00
trace_entries.h tracing: Fix some typos in comments 2020-11-10 20:39:40 -05:00
trace_event_perf.c ftrace: Have the callbacks receive a struct ftrace_regs instead of pt_regs 2020-11-13 12:14:55 -05:00
trace_events_filter_test.h
trace_events_filter.c tracing: Clean up after filter logic rewriting 2020-11-16 12:32:34 -05:00
trace_events_hist.c tracing: Fix some typos in comments 2020-11-10 20:39:40 -05:00
trace_events_inject.c
trace_events_synth.c tracing: Fix some typos in comments 2020-11-10 20:39:40 -05:00
trace_events_trigger.c
trace_events.c Tracing updates for 5.11 2020-12-17 13:22:17 -08:00
trace_export.c tracing: Fix some typos in comments 2020-11-10 20:39:40 -05:00
trace_functions_graph.c fgraph: Make overruns 4 bytes in graph stack structure 2020-11-10 20:39:36 -05:00
trace_functions.c ftrace: Have the callbacks receive a struct ftrace_regs instead of pt_regs 2020-11-13 12:14:55 -05:00
trace_hwlat.c Tracing updates for 5.11 2020-12-17 13:22:17 -08:00
trace_irqsoff.c tracing: Use pause-on-trace with the latency tracers 2021-01-29 15:35:33 -05:00
trace_kdb.c
trace_kprobe_selftest.c
trace_kprobe_selftest.h
trace_kprobe.c tracing/kprobe: Fix to support kretprobe events on unloaded modules 2021-01-29 15:39:48 -05:00
trace_mmiotrace.c
trace_nop.c
trace_output.c ftrace: Add recording of functions that caused recursion 2020-11-06 08:42:26 -05:00
trace_output.h ftrace: Add recording of functions that caused recursion 2020-11-06 08:42:26 -05:00
trace_preemptirq.c lockdep: fix order in trace_hardirqs_off_caller() 2020-09-14 10:08:07 +02:00
trace_printk.c Updates for tracing and bootconfig: 2020-10-15 15:51:28 -07:00
trace_probe_tmpl.h
trace_probe.c
trace_probe.h tracing: Move is_good_name() from trace_probe.h to trace.h 2020-10-15 12:01:13 -04:00
trace_recursion_record.c ftrace: Add recording of functions that caused recursion 2020-11-06 08:42:26 -05:00
trace_sched_switch.c
trace_sched_wakeup.c ftrace: Have the callbacks receive a struct ftrace_regs instead of pt_regs 2020-11-13 12:14:55 -05:00
trace_selftest_dynamic.c
trace_selftest.c tracing: Disable ftrace selftests when any tracer is running 2020-12-14 12:05:03 -05:00
trace_seq.c
trace_stack.c ftrace: Have the callbacks receive a struct ftrace_regs instead of pt_regs 2020-11-13 12:14:55 -05:00
trace_stat.c tracing: make tracing_init_dentry() returns an integer instead of a d_entry pointer 2020-09-18 22:17:14 -04:00
trace_stat.h
trace_synth.h tracing: Add support for dynamic strings to synthetic events 2020-10-05 19:32:18 -04:00
trace_syscalls.c
trace_uprobe.c tracing/uprobes: Support perf-style return probe 2020-09-21 21:06:03 -04:00
trace.c Tracing updates for 5.11 2020-12-17 13:22:17 -08:00
trace.h tracing: Disable ftrace selftests when any tracer is running 2020-12-14 12:05:03 -05:00
tracing_map.c tracing: Fix some typos in comments 2020-11-10 20:39:40 -05:00
tracing_map.h tracing: Fix some typos in comments 2020-11-10 20:39:40 -05:00