Debian Codegraph @

tapset/linux/sysc_linkat.stp

raw
1 # linkat _____________________________________________________
2 # new function with 2.6.16
3 # long sys_linkat(int olddfd, const char __user *oldname,
4 # int newdfd, const char __user *newname, int flags)
5
6 @define _SYSCALL_LINKAT_NAME
7 %(
8 name = "linkat"
9 %)
10
11 @define _SYSCALL_LINKAT_ARGSTR
12 %(
13 argstr = sprintf("%s, %s, %s, %s, %s", olddirfd_str, oldpath,
14 newdirfd_str, newpath, flags_str)
15 %)
16
17 @define _SYSCALL_LINKAT_REGARGS
18 %(
19 olddirfd = int_arg(1)
20 olddirfd_str = _dfd_str(olddirfd)
21 oldpath = user_string_quoted(pointer_arg(2))
22 oldpath_unquoted = user_string_nofault(pointer_arg(2))
23 newdirfd = int_arg(3)
24 newdirfd_str = _dfd_str(newdirfd)
25 newpath = user_string_quoted(pointer_arg(4))
26 newpath_unquoted = user_string_nofault(pointer_arg(4))
27 flags = int_arg(5)
28 flags_str = _at_flag_str(flags)
29 %)
30
31 @define _SYSCALL_LINKAT_REGARGS_STORE
32 %(
33 if (@probewrite(olddirfd))
34 set_int_arg(1, olddirfd)
35
36 if (@probewrite(oldpath_unquoted))
37 set_user_string_arg(pointer_arg(2), oldpath_unquoted)
38
39 if (@probewrite(newdirfd))
40 set_int_arg(3, newdirfd)
41
42 if (@probewrite(newpath_unquoted))
43 set_user_string_arg(pointer_arg(4), newpath_unquoted)
44
45 if (@probewrite(flags))
46 set_int_arg(5, flags)
47 %)
48
49 probe syscall.linkat = dw_syscall.linkat !, nd_syscall.linkat ? {}
50 probe syscall.linkat.return = dw_syscall.linkat.return !,
51 nd_syscall.linkat.return ? {}
52
53 # dw_linkat _____________________________________________________
54
55 probe dw_syscall.linkat = kernel.function("sys_linkat").call ?
56 {
57 @__syscall_compat_gate(@const("__NR_linkat"), @const("__NR_compat_linkat"))
58 @_SYSCALL_LINKAT_NAME
59 olddirfd = __int32($olddfd)
60 olddirfd_str = _dfd_str(__int32($olddfd))
61 oldpath = user_string_quoted($oldname)
62 newdirfd = __int32($newdfd)
63 newdirfd_str = _dfd_str(__int32($newdfd))
64 newpath = user_string_quoted($newname)
65 flags = __int32($flags)
66 flags_str = _at_flag_str(__int32($flags))
67 @_SYSCALL_LINKAT_ARGSTR
68 }
69 probe dw_syscall.linkat.return = kernel.function("sys_linkat").return ?
70 {
71 @__syscall_compat_gate(@const("__NR_linkat"), @const("__NR_compat_linkat"))
72 @_SYSCALL_LINKAT_NAME
73 @SYSC_RETVALSTR($return)
74 }
75
76 # nd_linkat _____________________________________________________
77
78 probe nd_syscall.linkat = nd1_syscall.linkat!, nd2_syscall.linkat!, tp_syscall.linkat
79 { }
80
81 probe nd1_syscall.linkat = kprobe.function("sys_linkat") ?
82 {
83 @__syscall_compat_gate(@const("__NR_linkat"), @const("__NR_compat_linkat"))
84 @_SYSCALL_LINKAT_NAME
85 asmlinkage()
86 @_SYSCALL_LINKAT_REGARGS
87 @_SYSCALL_LINKAT_ARGSTR
88 }
89
90 /* kernel 4.17+ */
91 probe nd2_syscall.linkat = kprobe.function(@arch_syscall_prefix "sys_linkat") ?
92 {
93 __set_syscall_pt_regs(pointer_arg(1))
94 @_SYSCALL_LINKAT_NAME
95 @_SYSCALL_LINKAT_REGARGS
96 @_SYSCALL_LINKAT_ARGSTR
97 },
98 {
99 %( @_IS_SREG_KERNEL %? @_SYSCALL_LINKAT_REGARGS_STORE %)
100 }
101
102 /* kernel 3.5+, but undesirable because it affects all syscalls */
103 probe tp_syscall.linkat = kernel.trace("sys_enter")
104 {
105 __set_syscall_pt_regs($regs)
106 @__syscall_compat_gate(@const("__NR_linkat"), @const("__NR_compat_linkat"))
107 @_SYSCALL_LINKAT_NAME
108 @_SYSCALL_LINKAT_REGARGS
109 @_SYSCALL_LINKAT_ARGSTR
110 },
111 {
112 %( @_IS_SREG_KERNEL %? @_SYSCALL_LINKAT_REGARGS_STORE %)
113 }
114
115 probe nd_syscall.linkat.return = nd1_syscall.linkat.return!, nd2_syscall.linkat.return!, tp_syscall.linkat.return
116 { }
117
118 probe nd1_syscall.linkat.return = kprobe.function("sys_linkat").return ?
119 {
120 @__syscall_compat_gate(@const("__NR_linkat"), @const("__NR_compat_linkat"))
121 @_SYSCALL_LINKAT_NAME
122 @SYSC_RETVALSTR(returnval())
123 }
124
125 /* kernel 4.17+ */
126 probe nd2_syscall.linkat.return = kprobe.function(@arch_syscall_prefix "sys_linkat").return ?
127 {
128 @_SYSCALL_LINKAT_NAME
129 @SYSC_RETVALSTR(returnval())
130 }
131
132 /* kernel 3.5+, but undesirable because it affects all syscalls */
133 probe tp_syscall.linkat.return = kernel.trace("sys_exit")
134 {
135 __set_syscall_pt_regs($regs)
136 @__syscall_compat_gate(@const("__NR_linkat"), @const("__NR_compat_linkat"))
137 @_SYSCALL_LINKAT_NAME
138 @SYSC_RETVALSTR($ret)
139 }