Debian Codegraph @

tapset/linux/sysc_fchdir.stp

raw
1 # fchdir _____________________________________________________
2 # long sys_fchdir(unsigned int fd)
3
4 @define _SYSCALL_FCHDIR_NAME
5 %(
6 name = "fchdir"
7 %)
8
9 @define _SYSCALL_FCHDIR_ARGSTR
10 %(
11 argstr = sprint(fd)
12 %)
13
14 @define _SYSCALL_FCHDIR_REGARGS
15 %(
16 fd = int_arg(1)
17 %)
18
19 @define _SYSCALL_FCHDIR_REGARGS_STORE
20 %(
21 if (@probewrite(fd))
22 set_int_arg(1, fd)
23 %)
24
25 probe syscall.fchdir = dw_syscall.fchdir !, nd_syscall.fchdir ? {}
26 probe syscall.fchdir.return = dw_syscall.fchdir.return !, nd_syscall.fchdir.return ? {}
27
28 # dw_fchdir _____________________________________________________
29
30 probe dw_syscall.fchdir = kernel.function("sys_fchdir").call
31 {
32 @_SYSCALL_FCHDIR_NAME
33 fd = __int32($fd)
34 @_SYSCALL_FCHDIR_ARGSTR
35 }
36 probe dw_syscall.fchdir.return = kernel.function("sys_fchdir").return
37 {
38 @_SYSCALL_FCHDIR_NAME
39 @SYSC_RETVALSTR($return)
40 }
41
42 # nd_fchdir _____________________________________________________
43
44 probe nd_syscall.fchdir = nd1_syscall.fchdir!, nd2_syscall.fchdir!, tp_syscall.fchdir
45 { }
46
47 probe nd1_syscall.fchdir = kprobe.function("sys_fchdir") ?
48 {
49 @_SYSCALL_FCHDIR_NAME
50 asmlinkage()
51 @_SYSCALL_FCHDIR_REGARGS
52 @_SYSCALL_FCHDIR_ARGSTR
53 }
54
55 /* kernel 4.17+ */
56 probe nd2_syscall.fchdir = kprobe.function(@arch_syscall_prefix "sys_fchdir")
57 {
58 __set_syscall_pt_regs(pointer_arg(1))
59 @_SYSCALL_FCHDIR_NAME
60 @_SYSCALL_FCHDIR_REGARGS
61 @_SYSCALL_FCHDIR_ARGSTR
62 },
63 {
64 %( @_IS_SREG_KERNEL %? @_SYSCALL_FCHDIR_REGARGS_STORE %)
65 }
66
67 /* kernel 3.5+, but undesirable because it affects all syscalls */
68 probe tp_syscall.fchdir = kernel.trace("sys_enter")
69 {
70 __set_syscall_pt_regs($regs)
71 @__syscall_compat_gate(@const("__NR_fchdir"), @const("__NR_compat_fchdir"))
72 @_SYSCALL_FCHDIR_NAME
73 @_SYSCALL_FCHDIR_REGARGS
74 @_SYSCALL_FCHDIR_ARGSTR
75 },
76 {
77 %( @_IS_SREG_KERNEL %? @_SYSCALL_FCHDIR_REGARGS_STORE %)
78 }
79
80 probe nd_syscall.fchdir.return = nd1_syscall.fchdir.return!, nd2_syscall.fchdir.return!, tp_syscall.fchdir.return
81 { }
82
83 probe nd1_syscall.fchdir.return = kprobe.function("sys_fchdir").return ?
84 {
85 @_SYSCALL_FCHDIR_NAME
86 @SYSC_RETVALSTR(returnval())
87 }
88
89 /* kernel 4.17+ */
90 probe nd2_syscall.fchdir.return = kprobe.function(@arch_syscall_prefix "sys_fchdir").return
91 {
92 @_SYSCALL_FCHDIR_NAME
93 @SYSC_RETVALSTR(returnval())
94 }
95
96 /* kernel 3.5+, but undesirable because it affects all syscalls */
97 probe tp_syscall.fchdir.return = kernel.trace("sys_exit")
98 {
99 __set_syscall_pt_regs($regs)
100 @__syscall_compat_gate(@const("__NR_fchdir"), @const("__NR_compat_fchdir"))
101 @_SYSCALL_FCHDIR_NAME
102 @SYSC_RETVALSTR($ret)
103 }