Skip to content

Commit d05851a

Browse files
committed
eBPF tracer: determine the size of the first io_vec element when handling writev syscalls
1 parent c96452b commit d05851a

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

ebpftracer/ebpf.go

Lines changed: 4 additions & 4 deletions
Large diffs are not rendered by default.

ebpftracer/ebpf/l7/l7.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ struct trace_event_raw_sys_exit_rw__stub {
7272
long int ret;
7373
};
7474

75+
struct iov {
76+
char* buf;
77+
__u64 size;
78+
};
79+
7580
static inline __attribute__((__always_inline__))
7681
int trace_enter_write(__u64 fd, char *buf, __u64 size) {
7782
__u64 id = bpf_get_current_pid_tgid();
@@ -177,11 +182,11 @@ int trace_exit_read(struct trace_event_raw_sys_exit_rw__stub* ctx) {
177182

178183
SEC("tracepoint/syscalls/sys_enter_writev")
179184
int sys_enter_writev(struct trace_event_raw_sys_enter_rw__stub* ctx) {
180-
void *vec;
181-
if (bpf_probe_read(&vec, sizeof(void*), (void *)ctx->buf) < 0) {
185+
struct iov iov0 = {};
186+
if (bpf_probe_read(&iov0, sizeof(struct iov), (void *)ctx->buf) < 0) {
182187
return 0;
183188
}
184-
return trace_enter_write(ctx->fd, vec, 0);
189+
return trace_enter_write(ctx->fd, iov0.buf, iov0.size);
185190
}
186191

187192
SEC("tracepoint/syscalls/sys_enter_write")

0 commit comments

Comments
 (0)