mirror of
https://github.com/lkl/linux.git
synced 2025-12-19 16:13:19 +09:00
bpf: add support for sys_enter_* and sys_exit_* tracepoints
Currently, bpf programs cannot be attached to sys_enter_* and sys_exit_* style tracepoints. The iovisor/bcc issue #748 (https://github.com/iovisor/bcc/issues/748) documents this issue. For example, if you try to attach a bpf program to tracepoints syscalls/sys_enter_newfstat, you will get the following error: # ./tools/trace.py t:syscalls:sys_enter_newfstat Ioctl(PERF_EVENT_IOC_SET_BPF): Invalid argument Failed to attach BPF to tracepoint The main reason is that syscalls/sys_enter_* and syscalls/sys_exit_* tracepoints are treated differently from other tracepoints and there is no bpf hook to it. This patch adds bpf support for these syscalls tracepoints by . permitting bpf attachment in ioctl PERF_EVENT_IOC_SET_BPF . calling bpf programs in perf_syscall_enter and perf_syscall_exit The legality of bpf program ctx access is also checked. Function trace_event_get_offsets returns correct max offset for each specific syscall tracepoint, which is compared against the maximum offset access in bpf program. Signed-off-by: Yonghong Song <yhs@fb.com> Acked-by: Alexei Starovoitov <ast@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
d226a2b84d
commit
cf5f5cea27
@@ -172,8 +172,20 @@ extern struct trace_event_functions exit_syscall_print_funcs;
|
||||
static struct syscall_metadata __used \
|
||||
__attribute__((section("__syscalls_metadata"))) \
|
||||
*__p_syscall_meta_##sname = &__syscall_meta_##sname;
|
||||
|
||||
static inline int is_syscall_trace_event(struct trace_event_call *tp_event)
|
||||
{
|
||||
return tp_event->class == &event_class_syscall_enter ||
|
||||
tp_event->class == &event_class_syscall_exit;
|
||||
}
|
||||
|
||||
#else
|
||||
#define SYSCALL_METADATA(sname, nb, ...)
|
||||
|
||||
static inline int is_syscall_trace_event(struct trace_event_call *tp_event)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#define SYSCALL_DEFINE0(sname) \
|
||||
|
||||
Reference in New Issue
Block a user