Message ID | 20230801075222.7717-1-ykaliuta@redhat.com (mailing list archive) |
---|---|
State | Accepted |
Commit | d3c4db86c71164ed9ae17b4026e1acde460a18ab |
Delegated to: | BPF |
Headers | show |
Series | [bpf-next,v3] tracing: perf_call_bpf: use struct trace_entry in struct syscall_tp_t | expand |
On 8/1/23 12:52 AM, Yauheni Kaliuta wrote: > bpf tracepoint program uses struct trace_event_raw_sys_enter as > argument where trace_entry is the first field. Use the same instead > of unsigned long long since if it's amended (for example by RT > patch) it accesses data with wrong offset. > > Signed-off-by: Yauheni Kaliuta <ykaliuta@redhat.com> Acked-by: Yonghong Song <yonghong.song@linux.dev>
Hello: This patch was applied to bpf/bpf-next.git (master) by Alexei Starovoitov <ast@kernel.org>: On Tue, 1 Aug 2023 10:52:22 +0300 you wrote: > bpf tracepoint program uses struct trace_event_raw_sys_enter as > argument where trace_entry is the first field. Use the same instead > of unsigned long long since if it's amended (for example by RT > patch) it accesses data with wrong offset. > > Signed-off-by: Yauheni Kaliuta <ykaliuta@redhat.com> > > [...] Here is the summary with links: - [bpf-next,v3] tracing: perf_call_bpf: use struct trace_entry in struct syscall_tp_t https://git.kernel.org/bpf/bpf-next/c/d3c4db86c711 You are awesome, thank you!
diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c index 942ddbdace4a..de753403cdaf 100644 --- a/kernel/trace/trace_syscalls.c +++ b/kernel/trace/trace_syscalls.c @@ -555,12 +555,15 @@ static int perf_call_bpf_enter(struct trace_event_call *call, struct pt_regs *re struct syscall_trace_enter *rec) { struct syscall_tp_t { - unsigned long long regs; + struct trace_entry ent; unsigned long syscall_nr; unsigned long args[SYSCALL_DEFINE_MAXARGS]; - } param; + } __aligned(8) param; int i; + BUILD_BUG_ON(sizeof(param.ent) < sizeof(void *)); + + /* bpf prog requires 'regs' to be the first member in the ctx (a.k.a. ¶m) */ *(struct pt_regs **)¶m = regs; param.syscall_nr = rec->nr; for (i = 0; i < sys_data->nb_args; i++) @@ -657,11 +660,12 @@ static int perf_call_bpf_exit(struct trace_event_call *call, struct pt_regs *reg struct syscall_trace_exit *rec) { struct syscall_tp_t { - unsigned long long regs; + struct trace_entry ent; unsigned long syscall_nr; unsigned long ret; - } param; + } __aligned(8) param; + /* bpf prog requires 'regs' to be the first member in the ctx (a.k.a. ¶m) */ *(struct pt_regs **)¶m = regs; param.syscall_nr = rec->nr; param.ret = rec->ret;
bpf tracepoint program uses struct trace_event_raw_sys_enter as argument where trace_entry is the first field. Use the same instead of unsigned long long since if it's amended (for example by RT patch) it accesses data with wrong offset. Signed-off-by: Yauheni Kaliuta <ykaliuta@redhat.com> --- v3: - Fixed comment v2: - remove extra BUILD_BUG_ON - add structure alignement --- kernel/trace/trace_syscalls.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)