Skip to content

Commit

Permalink
tools/opensnoop: Use do_sys_open for kprobe hook
Browse files Browse the repository at this point in the history
Systems such as Android mostly use openat which makes us miss all
attempts to open. Instead use do_sys_open for the kprobe hook where
all the open calls finally end up, so that we don't miss anything.

Signed-off-by: Joel Fernandes <[email protected]>
  • Loading branch information
Joel Fernandes committed Jan 28, 2018
1 parent 0d5084d commit 9af548f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions tools/opensnoop.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
BPF_HASH(infotmp, u64, struct val_t);
BPF_PERF_OUTPUT(events);
int trace_entry(struct pt_regs *ctx, const char __user *filename)
int trace_entry(struct pt_regs *ctx, int dfd, const char __user *filename)
{
struct val_t val = {};
u64 id = bpf_get_current_pid_tgid();
Expand Down Expand Up @@ -124,8 +124,8 @@

# initialize BPF
b = BPF(text=bpf_text)
b.attach_kprobe(event="sys_open", fn_name="trace_entry")
b.attach_kretprobe(event="sys_open", fn_name="trace_return")
b.attach_kprobe(event="do_sys_open", fn_name="trace_entry")
b.attach_kretprobe(event="do_sys_open", fn_name="trace_return")

TASK_COMM_LEN = 16 # linux/sched.h
NAME_MAX = 255 # linux/limits.h
Expand Down

0 comments on commit 9af548f

Please sign in to comment.