Debian Codegraph @

tapset/linux/x86_64/sysc_compat_truncate64.stp

raw
1 # truncate _______________________________________________________
2 #
3 # asmlinkage long sys32_truncate64(const char __user *filename,
4 # unsigned long offset_low,
5 # unsigned long offset_high)
6 # COMPAT_SYSCALL_DEFINE3(x86_truncate64, const char __user *, filename,
7 # unsigned long, offset_low, unsigned long, offset_high)
8 #
9
10 @define _SYSCALL_COMPAT_TRUNCATE64_NAME
11 %(
12 name = "truncate"
13 %)
14
15 @define _SYSCALL_COMPAT_TRUNCATE64_ARGSTR
16 %(
17 argstr = sprintf("%s, %d", path, length)
18 %)
19
20 @define _SYSCALL_COMPAT_TRUNCATE64_REGARGS
21 %(
22 path_uaddr = pointer_arg(1)
23 path = user_string_quoted(path_uaddr)
24 path_unquoted = user_string_nofault(pointer_arg(1))
25 length = ((uint_arg(3) << 32) | uint_arg(2))
26 %)
27
28 @define _SYSCALL_COMPAT_TRUNCATE64_REGARGS_STORE
29 %(
30 if (@probewrite(path_uaddr))
31 set_pointer_arg(1, path_uaddr)
32
33 if (@probewrite(path_unquoted))
34 set_user_string_arg(pointer_arg(1), path_unquoted)
35
36 if (@probewrite(length)) {
37 set_uint_arg(2, length & 0xffffffff)
38 set_uint_arg(3, length >> 32)
39 }
40 %)
41
42 probe syscall.compat_truncate64 = dw_syscall.compat_truncate64 !,
43 nd_syscall.compat_truncate64 ? {}
44 probe syscall.compat_truncate64.return = dw_syscall.compat_truncate64.return !,
45 nd_syscall.compat_truncate64.return ? {}
46
47 # dw_compat_truncate64 _____________________________________________________
48
49 probe dw_syscall.compat_truncate64 =
50 kernel.function("sys32_truncate64").call ?,
51 kernel.function("compat_sys_x86_truncate64").call ?
52 {
53 @_SYSCALL_COMPAT_TRUNCATE64_NAME
54 path_uaddr = $filename
55 path = user_string_quoted(path_uaddr)
56 length = (($offset_high << 32) | $offset_low)
57 @_SYSCALL_COMPAT_TRUNCATE64_ARGSTR
58 }
59 probe dw_syscall.compat_truncate64.return =
60 kernel.function("sys32_truncate64").return ?,
61 kernel.function("compat_sys_x86_truncate64").return ?
62 {
63 @_SYSCALL_COMPAT_TRUNCATE64_NAME
64 @SYSC_RETVALSTR($return)
65 }
66
67 # nd_compat_truncate64 _____________________________________________________
68
69 probe nd_syscall.compat_truncate64 = nd1_syscall.compat_truncate64!, nd2_syscall.compat_truncate64!, tp_syscall.compat_truncate64
70 { }
71
72 probe nd1_syscall.compat_truncate64 =
73 kprobe.function("sys32_truncate64") ?,
74 kprobe.function("compat_sys_x86_truncate64") ?
75 {
76 asmlinkage()
77 @_SYSCALL_COMPAT_TRUNCATE64_NAME
78 @_SYSCALL_COMPAT_TRUNCATE64_REGARGS
79 @_SYSCALL_COMPAT_TRUNCATE64_ARGSTR
80 }
81
82 /* kernel 4.17+ */
83 probe nd2_syscall.compat_truncate64 =
84 kprobe.function(@arch_syscall_prefix "compat_sys_x86_truncate64") ?
85 {
86 __set_syscall_pt_regs(pointer_arg(1))
87 @_SYSCALL_COMPAT_TRUNCATE64_NAME
88 @_SYSCALL_COMPAT_TRUNCATE64_REGARGS
89 @_SYSCALL_COMPAT_TRUNCATE64_ARGSTR
90 },
91 {
92 %( @_IS_SREG_KERNEL %? @_SYSCALL_COMPAT_TRUNCATE64_REGARGS_STORE %)
93 }
94
95 /* kernel 3.5+, but undesirable because it affects all syscalls */
96 probe tp_syscall.compat_truncate64 = kernel.trace("sys_enter")
97 {
98 __set_syscall_pt_regs($regs)
99 @__compat_syscall_gate(@const("__NR_ia32_truncate64"))
100 @_SYSCALL_COMPAT_TRUNCATE64_NAME
101 @_SYSCALL_COMPAT_TRUNCATE64_REGARGS
102 @_SYSCALL_COMPAT_TRUNCATE64_ARGSTR
103 },
104 {
105 %( @_IS_SREG_KERNEL %? @_SYSCALL_COMPAT_TRUNCATE64_REGARGS_STORE %)
106 }
107
108 probe nd_syscall.compat_truncate64.return = nd1_syscall.compat_truncate64.return!, nd2_syscall.compat_truncate64.return!, tp_syscall.compat_truncate64.return
109 { }
110
111 probe nd1_syscall.compat_truncate64.return =
112 kprobe.function("sys32_truncate64").return ?,
113 kprobe.function("compat_sys_x86_truncate64").return ?
114 {
115 @_SYSCALL_COMPAT_TRUNCATE64_NAME
116 @SYSC_RETVALSTR(returnval())
117 }
118
119 /* kernel 4.17+ */
120 probe nd2_syscall.compat_truncate64.return =
121 kprobe.function(@arch_syscall_prefix "compat_sys_x86_truncate64").return ?
122 {
123 @_SYSCALL_COMPAT_TRUNCATE64_NAME
124 @SYSC_RETVALSTR(returnval())
125 }
126
127 /* kernel 3.5+, but undesirable because it affects all syscalls */
128 probe tp_syscall.compat_truncate64.return = kernel.trace("sys_exit")
129 {
130 __set_syscall_pt_regs($regs)
131 @__compat_syscall_gate(@const("__NR_ia32_truncate64"))
132 @_SYSCALL_COMPAT_TRUNCATE64_NAME
133 @SYSC_RETVALSTR($ret)
134 }