kernel-hacking-2024-linux-s.../kernel/trace
Alexei Starovoitov 8d3b7dce86 bpf: add support for %s specifier to bpf_trace_printk()
%s specifier makes bpf program and kernel debugging easier.
To make sure that trace_printk won't crash the unsafe string
is copied into stack and unsafe pointer is substituted.

The following C program:
 #include <linux/fs.h>
int foo(struct pt_regs *ctx, struct filename *filename)
{
  void *name = 0;

  bpf_probe_read(&name, sizeof(name), &filename->name);
  bpf_trace_printk("executed %s\n", name);
  return 0;
}

when attached to kprobe do_execve()
will produce output in /sys/kernel/debug/tracing/trace_pipe :
    make-13492 [002] d..1  3250.997277: : executed /bin/sh
      sh-13493 [004] d..1  3250.998716: : executed /usr/bin/gcc
     gcc-13494 [002] d..1  3250.999822: : executed /usr/lib/gcc/x86_64-linux-gnu/4.7/cc1
     gcc-13495 [002] d..1  3251.006731: : executed /usr/bin/as
     gcc-13496 [002] d..1  3251.011831: : executed /usr/lib/gcc/x86_64-linux-gnu/4.7/collect2
collect2-13497 [000] d..1  3251.012941: : executed /usr/bin/ld

Suggested-by: Brendan Gregg <brendan.d.gregg@gmail.com>
Signed-off-by: Alexei Starovoitov <ast@plumgrid.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2015-08-28 16:27:27 -07:00
..
blktrace.c This patch series contains several clean ups and even a new trace clock 2015-06-26 14:02:43 -07:00
bpf_trace.c bpf: add support for %s specifier to bpf_trace_printk() 2015-08-28 16:27:27 -07:00
ftrace.c ftrace: Fix breakage of set_ftrace_pid 2015-07-24 13:58:14 -04:00
Kconfig
Makefile
power-traces.c
ring_buffer.c ring-buffer: Add enum names for the context levels 2015-05-29 10:39:08 -04:00
ring_buffer_benchmark.c This patch series contains several clean ups and even a new trace clock 2015-06-26 14:02:43 -07:00
rpm-traces.c
trace.c tracing: Rename FTRACE_EVENT_FL_* flags to EVENT_FILE_FL_* 2015-05-13 15:24:57 -04:00
trace.h tracing: Have branch tracer use recursive field of task struct 2015-07-08 11:53:45 -04:00
trace_benchmark.c
trace_benchmark.h
trace_branch.c tracing: Have branch tracer use recursive field of task struct 2015-07-08 11:53:45 -04:00
trace_clock.c tracing: Export tracing clock functions 2015-05-12 15:56:57 -04:00
trace_entries.h
trace_event_perf.c tracing: Rename ftrace_event_{call,class} to trace_event_{call,class} 2015-05-13 14:06:10 -04:00
trace_events.c tracing: Rename FTRACE_EVENT_FL_* flags to EVENT_FILE_FL_* 2015-05-13 15:24:57 -04:00
trace_events_filter.c This patch series contains several clean ups and even a new trace clock 2015-06-26 14:02:43 -07:00
trace_events_filter_test.h
trace_events_trigger.c tracing: Rename ftrace_raw_##call event structures to trace_event_raw_##call 2015-05-13 21:48:40 -04:00
trace_export.c tracing: Rename ftrace_event_{call,class} to trace_event_{call,class} 2015-05-13 14:06:10 -04:00
trace_functions.c
trace_functions_graph.c tracing: Rename ftrace_event_{call,class} to trace_event_{call,class} 2015-05-13 14:06:10 -04:00
trace_irqsoff.c
trace_kdb.c
trace_kprobe.c lib: introduce strncpy_from_unsafe() 2015-08-28 16:27:27 -07:00
trace_mmiotrace.c tracing: Rename ftrace_event_{call,class} to trace_event_{call,class} 2015-05-13 14:06:10 -04:00
trace_nop.c
trace_output.c tracing: Rename ftrace_event_name() to trace_event_name() 2015-05-13 14:20:14 -04:00
trace_output.h tracing: Rename (un)register_ftrace_event() to (un)register_trace_event() 2015-05-13 14:05:14 -04:00
trace_printk.c
trace_probe.c
trace_probe.h tracing: Rename ftrace_event_{call,class} to trace_event_{call,class} 2015-05-13 14:06:10 -04:00
trace_sched_switch.c
trace_sched_wakeup.c tracing: Rename ftrace_event_{call,class} to trace_event_{call,class} 2015-05-13 14:06:10 -04:00
trace_selftest.c
trace_selftest_dynamic.c
trace_seq.c
trace_stack.c
trace_stat.c
trace_stat.h
trace_syscalls.c tracing: Rename ftrace_trigger_soft_disabled() to trace_trigger_soft_disabled() 2015-05-13 15:25:39 -04:00
trace_uprobe.c tracing: Rename ftrace_trigger_soft_disabled() to trace_trigger_soft_disabled() 2015-05-13 15:25:39 -04:00