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
..
2015-06-26 14:02:43 -07:00
2015-08-28 16:27:27 -07:00
2015-07-24 13:58:14 -04:00
2015-04-14 14:37:47 -07:00
2015-04-02 16:28:06 +02:00
2015-01-30 02:10:41 +01:00
2015-06-26 14:02:43 -07:00
2015-05-29 10:39:08 -04:00
2011-09-27 22:53:27 +02:00
2014-06-06 00:41:38 -04:00
2014-05-29 22:49:54 -04:00
2015-07-08 11:53:45 -04:00
2015-05-12 15:56:57 -04:00
2015-03-25 08:57:22 -04:00
2015-05-13 14:06:10 -04:00
2011-08-19 14:35:59 -04:00
2015-06-26 14:02:43 -07:00
2015-05-13 21:48:40 -04:00
2015-05-13 15:24:57 -04:00
2015-05-13 14:06:10 -04:00
2015-05-13 14:06:10 -04:00
2014-11-20 10:05:36 -05:00
2015-01-22 11:19:48 -05:00
2015-01-09 20:51:10 -08:00
2015-08-28 16:27:27 -07:00
2015-05-13 14:06:10 -04:00
2015-01-22 11:19:48 -05:00
2015-05-13 14:20:14 -04:00
2015-05-13 14:05:14 -04:00
2015-01-22 11:19:49 -05:00
2015-03-25 08:57:23 -04:00
2015-05-13 14:06:10 -04:00
2015-01-22 11:19:48 -05:00
2015-05-13 14:06:10 -04:00
2011-05-18 19:24:51 -04:00
2014-10-12 07:28:55 -04:00
2015-02-13 21:21:37 -08:00
2015-04-15 16:35:25 -07:00
2015-02-03 12:48:41 -05:00
2015-05-13 15:25:39 -04:00
2015-05-13 15:25:39 -04:00
2015-05-13 15:24:57 -04:00
2015-07-08 11:53:45 -04:00