Skip to content

Commit 11f3708

Browse files
author
Shane Wall
committed
Removed the unsupported fentry/vfs_pwritev probe and cleaned up the loader/attach paths so only the standard write hooks remain. Updates: ebpf/diffkeeper.bpf.c drops the pwritev program; pkg/ebpf/bpf_objects_linux.go removes the program binding/close; pkg/ebpf/manager_linux.go now only attaches write/writev and counts successful attaches.
1 parent 8a32080 commit 11f3708

3 files changed

Lines changed: 8 additions & 27 deletions

File tree

ebpf/diffkeeper.bpf.c

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -79,22 +79,6 @@ int BPF_PROG(fentry_vfs_writev, struct kiocb *iocb, struct iovec *iov,
7979
return emit_syscall_event(file, total);
8080
}
8181

82-
SEC("fentry/vfs_pwritev")
83-
int BPF_PROG(fentry_vfs_pwritev, struct file *file, struct iovec *iov,
84-
unsigned long nr_segs, loff_t *pos)
85-
{
86-
size_t total = 0;
87-
88-
#pragma unroll
89-
for (int i = 0; i < 6; i++) {
90-
if (i >= nr_segs)
91-
break;
92-
size_t len = BPF_CORE_READ(&iov[i], iov_len);
93-
total += len;
94-
}
95-
return emit_syscall_event(file, total);
96-
}
97-
9882
SEC("tracepoint/sched/sched_process_exec")
9983
int handle_sched_exec(struct trace_event_raw_sched_process_exec *ctx)
10084
{

pkg/ebpf/bpf_objects_linux.go

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,11 @@ var diffkeeperObject []byte
1515

1616
// bpfObjects mirrors the maps and programs compiled into diffkeeper.bpf.o.
1717
type bpfObjects struct {
18-
Events *ebpf.Map `ebpf:"events"`
19-
LifecycleEvents *ebpf.Map `ebpf:"lifecycle_events"`
20-
FentryVfsWrite *ebpf.Program `ebpf:"fentry_vfs_write"`
21-
FentryVfsWritev *ebpf.Program `ebpf:"fentry_vfs_writev"`
22-
FentryVfsPwritev *ebpf.Program `ebpf:"fentry_vfs_pwritev"`
23-
HandleSchedExec *ebpf.Program `ebpf:"handle_sched_exec"`
18+
Events *ebpf.Map `ebpf:"events"`
19+
LifecycleEvents *ebpf.Map `ebpf:"lifecycle_events"`
20+
FentryVfsWrite *ebpf.Program `ebpf:"fentry_vfs_write"`
21+
FentryVfsWritev *ebpf.Program `ebpf:"fentry_vfs_writev"`
22+
HandleSchedExec *ebpf.Program `ebpf:"handle_sched_exec"`
2423
}
2524

2625
func (o *bpfObjects) Close() error {
@@ -40,9 +39,6 @@ func (o *bpfObjects) Close() error {
4039
if o.FentryVfsWritev != nil {
4140
o.FentryVfsWritev.Close()
4241
}
43-
if o.FentryVfsPwritev != nil {
44-
o.FentryVfsPwritev.Close()
45-
}
4642
if o.HandleSchedExec != nil {
4743
o.HandleSchedExec.Close()
4844
}

pkg/ebpf/manager_linux.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,9 @@ func (m *kernelManager) attachSyscallProbes() error {
144144
probes := []*ebpf.Program{
145145
m.objs.FentryVfsWrite,
146146
m.objs.FentryVfsWritev,
147-
m.objs.FentryVfsPwritev,
148147
}
149148

149+
attached := 0
150150
for _, prog := range probes {
151151
if prog == nil {
152152
continue
@@ -161,9 +161,10 @@ func (m *kernelManager) attachSyscallProbes() error {
161161
continue
162162
}
163163
m.links = append(m.links, l)
164+
attached++
164165
}
165166

166-
if len(m.links) == 0 {
167+
if attached == 0 {
167168
return fmt.Errorf("failed to attach any write probes")
168169
}
169170

0 commit comments

Comments
 (0)