Debian Codegraph @

tapset/linux/sysc_chdir.stp

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