Debian Codegraph @

tapset/linux/sysc_open_by_handle_at.stp

raw
1 # open_by_handle_at ___________________________________________
2 #
3 # SYSCALL_DEFINE3(open_by_handle_at, int, mountdirfd,
4 # struct file_handle __user *, handle,
5 # int, flags)
6 # COMPAT_SYSCALL_DEFINE3(open_by_handle_at, int, mountdirfd,
7 # struct file_handle __user *, handle, int, flags)
8
9 @define _SYSCALL_OPEN_BY_HANDLE_AT_NAME
10 %(
11 name = "open_by_handle_at"
12 %)
13
14 @define _SYSCALL_OPEN_BY_HANDLE_AT_ARGSTR
15 %(
16 argstr = sprintf("%s, %p, %s", mount_dfd_str, handle_uaddr, flags_str)
17 %)
18
19 @define _SYSCALL_OPEN_BY_HANDLE_AT_REGARGS
20 %(
21 mount_dfd = int_arg(1)
22 mount_dfd_str = _dfd_str(mount_dfd)
23 handle_uaddr = pointer_arg(2)
24 flags = int_arg(3)
25 flags_str = _sys_open_flag_str(flags)
26 %)
27
28 @define _SYSCALL_OPEN_BY_HANDLE_AT_REGARGS_STORE
29 %(
30 if (@probewrite(mount_dfd))
31 set_int_arg(1, mount_dfd)
32
33 if (@probewrite(handle_uaddr))
34 set_pointer_arg(2, handle_uaddr)
35
36 if (@probewrite(flags))
37 set_int_arg(3, flags)
38 %)
39
40 probe syscall.open_by_handle_at = dw_syscall.open_by_handle_at !,
41 nd_syscall.open_by_handle_at ? {}
42 probe syscall.open_by_handle_at.return = dw_syscall.open_by_handle_at.return !,
43 nd_syscall.open_by_handle_at.return ? {}
44
45 # dw_open_by_handle_at _____________________________________________________
46
47 probe dw_syscall.open_by_handle_at =
48 kernel.function("sys_open_by_handle_at").call ?,
49 kernel.function("compat_sys_open_by_handle_at").call ?
50 {
51 @_SYSCALL_OPEN_BY_HANDLE_AT_NAME
52 mount_dfd = __int32($mountdirfd)
53 mount_dfd_str = _dfd_str(mount_dfd)
54 handle_uaddr = @__pointer($handle)
55 flags = __int32($flags)
56 flags_str = _sys_open_flag_str(flags)
57 @_SYSCALL_OPEN_BY_HANDLE_AT_ARGSTR
58 }
59 probe dw_syscall.open_by_handle_at.return =
60 kernel.function("sys_open_by_handle_at").return ?,
61 kernel.function("compat_sys_open_by_handle_at").return ?
62 {
63 @_SYSCALL_OPEN_BY_HANDLE_AT_NAME
64 @SYSC_RETVALSTR($return)
65 }
66
67 # nd_open_by_handle_at _____________________________________________________
68
69 probe nd_syscall.open_by_handle_at = nd1_syscall.open_by_handle_at!, nd2_syscall.open_by_handle_at!, tp_syscall.open_by_handle_at
70 { }
71
72 probe nd1_syscall.open_by_handle_at = kprobe.function("sys_open_by_handle_at") ?,
73 kprobe.function("compat_sys_open_by_handle_at") ?
74 {
75 @_SYSCALL_OPEN_BY_HANDLE_AT_NAME
76 asmlinkage()
77 @_SYSCALL_OPEN_BY_HANDLE_AT_REGARGS
78 @_SYSCALL_OPEN_BY_HANDLE_AT_ARGSTR
79 }
80
81 /* kernel 4.17+ */
82 probe nd2_syscall.open_by_handle_at =
83 kprobe.function(@arch_syscall_prefix "sys_open_by_handle_at") ?,
84 kprobe.function(@arch_syscall_prefix "compat_sys_open_by_handle_at") ?
85 {
86 __set_syscall_pt_regs(pointer_arg(1))
87 @_SYSCALL_OPEN_BY_HANDLE_AT_NAME
88 @_SYSCALL_OPEN_BY_HANDLE_AT_REGARGS
89 @_SYSCALL_OPEN_BY_HANDLE_AT_ARGSTR
90 },
91 {
92 %( @_IS_SREG_KERNEL %? @_SYSCALL_OPEN_BY_HANDLE_AT_REGARGS_STORE %)
93 }
94
95 /* kernel 3.5+, but undesirable because it affects all syscalls */
96 probe tp_syscall.open_by_handle_at = kernel.trace("sys_enter")
97 {
98 __set_syscall_pt_regs($regs)
99 @__syscall_compat_gate(@const("__NR_open_by_handle_at"),
100 @const("__NR_compat_open_by_handle_at"))
101 @_SYSCALL_OPEN_BY_HANDLE_AT_NAME
102 @_SYSCALL_OPEN_BY_HANDLE_AT_REGARGS
103 @_SYSCALL_OPEN_BY_HANDLE_AT_ARGSTR
104 },
105 {
106 %( @_IS_SREG_KERNEL %? @_SYSCALL_OPEN_BY_HANDLE_AT_REGARGS_STORE %)
107 }
108
109 probe nd_syscall.open_by_handle_at.return = nd1_syscall.open_by_handle_at.return!, nd2_syscall.open_by_handle_at.return!, tp_syscall.open_by_handle_at.return
110 { }
111
112 probe nd1_syscall.open_by_handle_at.return =
113 kprobe.function("sys_open_by_handle_at").return ?,
114 kprobe.function("compat_sys_open_by_handle_at").return ?
115 {
116 @_SYSCALL_OPEN_BY_HANDLE_AT_NAME
117 @SYSC_RETVALSTR(returnval())
118 }
119
120 /* kernel 4.17+ */
121 probe nd2_syscall.open_by_handle_at.return =
122 kprobe.function(@arch_syscall_prefix "sys_open_by_handle_at").return ?,
123 kprobe.function(@arch_syscall_prefix "compat_sys_open_by_handle_at").return ?
124 {
125 @_SYSCALL_OPEN_BY_HANDLE_AT_NAME
126 @SYSC_RETVALSTR(returnval())
127 }
128
129 /* kernel 3.5+, but undesirable because it affects all syscalls */
130 probe tp_syscall.open_by_handle_at.return = kernel.trace("sys_exit")
131 {
132 __set_syscall_pt_regs($regs)
133 @__syscall_compat_gate(@const("__NR_open_by_handle_at"),
134 @const("__NR_compat_open_by_handle_at"))
135 @_SYSCALL_OPEN_BY_HANDLE_AT_NAME
136 @SYSC_RETVALSTR($ret)
137 }