Debian Codegraph @

tapset/linux/x86_64/sysc_compat_fallocate.stp

raw
1 # fallocate __________________________________________________
2 #
3 # COMPAT_SYSCALL_DEFINE6(x86_fallocate, int, fd, int, mode,
4 # unsigned int, offset_lo, unsigned int, offset_hi,
5 # unsigned int, len_lo, unsigned int, len_hi)
6 # asmlinkage long sys32_fallocate(int fd, int mode, unsigned offset_lo,
7 # unsigned offset_hi, unsigned len_lo,
8 # unsigned len_hi)
9
10 @define _SYSCALL_COMPAT_FALLOCATE_NAME
11 %(
12 name = "fallocate"
13 %)
14
15 @define _SYSCALL_COMPAT_FALLOCATE_ARGSTR
16 %(
17 argstr = sprintf("%d, %s, %#x, %u", fd, mode_str, offset, len)
18 %)
19
20 @define _SYSCALL_COMPAT_FALLOCATE_REGARGS
21 %(
22 fd = int_arg(1)
23 mode = int_arg(2)
24 mode_str = _stp_fallocate_mode_str(mode)
25 offset = ((uint_arg(4) << 32) | uint_arg(3))
26 len = ((uint_arg(6) << 32) | uint_arg(5))
27 %)
28
29 @define _SYSCALL_COMPAT_FALLOCATE_REGARGS_STORE
30 %(
31 if (@probewrite(fd))
32 set_int_arg(1, fd)
33
34 if (@probewrite(mode))
35 set_int_arg(2, mode)
36
37 if (@probewrite(offset)) {
38 set_uint_arg(3, offset & 0xffffffff)
39 set_uint_arg(4, offset >> 32)
40 }
41
42 if (@probewrite(len)) {
43 set_uint_arg(5, len & 0xffffffff)
44 set_uint_arg(6, len >> 32)
45 }
46 %)
47
48 probe syscall.compat_fallocate = dw_syscall.compat_fallocate !,
49 nd_syscall.compat_fallocate ? {}
50 probe syscall.compat_fallocate.return = dw_syscall.compat_fallocate.return !,
51 nd_syscall.compat_fallocate.return ? {}
52
53 # dw_compat_fallocate _____________________________________________________
54
55 probe dw_syscall.compat_fallocate = kernel.function("sys32_fallocate").call ?,
56 kernel.function("comapt_sys_x86_fallocate").call ?
57 {
58 @_SYSCALL_COMPAT_FALLOCATE_NAME
59 fd = __int32($fd)
60 mode = __int32($mode)
61 mode_str = _stp_fallocate_mode_str(mode)
62 offset = (($offset_hi << 32) | $offset_lo)
63 len = (($len_hi << 32) | $len_lo)
64 @_SYSCALL_COMPAT_FALLOCATE_ARGSTR
65 }
66 probe dw_syscall.compat_fallocate.return =
67 kernel.function("sys32_fallocate").return ?,
68 kernel.function("compat_sys_x86_fallocate").return ?
69 {
70 @_SYSCALL_COMPAT_FALLOCATE_NAME
71 @SYSC_RETVALSTR($return)
72 }
73
74 # nd_compat_fallocate _____________________________________________________
75
76 probe nd_syscall.compat_fallocate = nd1_syscall.compat_fallocate!, nd2_syscall.compat_fallocate!, tp_syscall.compat_fallocate
77 { }
78
79 probe nd1_syscall.compat_fallocate = kprobe.function("sys32_fallocate") ?,
80 kprobe.function("compat_sys_x86_fallocate") ?
81 {
82 asmlinkage()
83 @_SYSCALL_COMPAT_FALLOCATE_NAME
84 @_SYSCALL_COMPAT_FALLOCATE_REGARGS
85 @_SYSCALL_COMPAT_FALLOCATE_ARGSTR
86 }
87
88 /* kernel 4.17+ */
89 probe nd2_syscall.compat_fallocate =
90 kprobe.function(@arch_syscall_prefix "compat_sys_x86_fallocate") ?
91 {
92 __set_syscall_pt_regs(pointer_arg(1))
93 @_SYSCALL_COMPAT_FALLOCATE_NAME
94 @_SYSCALL_COMPAT_FALLOCATE_REGARGS
95 @_SYSCALL_COMPAT_FALLOCATE_ARGSTR
96 },
97 {
98 %( @_IS_SREG_KERNEL %? @_SYSCALL_COMPAT_FALLOCATE_REGARGS_STORE %)
99 }
100
101 /* kernel 3.5+, but undesirable because it affects all syscalls */
102 probe tp_syscall.compat_fallocate = kernel.trace("sys_enter")
103 {
104 __set_syscall_pt_regs($regs)
105 @__compat_syscall_gate(@const("__NR_ia32_fallocate"))
106 @_SYSCALL_COMPAT_FALLOCATE_NAME
107 @_SYSCALL_COMPAT_FALLOCATE_REGARGS
108 @_SYSCALL_COMPAT_FALLOCATE_ARGSTR
109 },
110 {
111 %( @_IS_SREG_KERNEL %? @_SYSCALL_COMPAT_FALLOCATE_REGARGS_STORE %)
112 }
113
114 probe nd_syscall.compat_fallocate.return = nd1_syscall.compat_fallocate.return!, nd2_syscall.compat_fallocate.return!, tp_syscall.compat_fallocate.return
115 { }
116
117 probe nd1_syscall.compat_fallocate.return =
118 kprobe.function("sys32_fallocate").return ?,
119 kprobe.function("compat_sys_x86_fallocate").return ?
120 {
121 @_SYSCALL_COMPAT_FALLOCATE_NAME
122 @SYSC_RETVALSTR(returnval())
123 }
124
125 /* kernel 4.17+ */
126 probe nd2_syscall.compat_fallocate.return =
127 kprobe.function(@arch_syscall_prefix "compat_sys_x86_fallocate").return ?
128 {
129 @_SYSCALL_COMPAT_FALLOCATE_NAME
130 @SYSC_RETVALSTR(returnval())
131 }
132
133 /* kernel 3.5+, but undesirable because it affects all syscalls */
134 probe tp_syscall.compat_fallocate.return = kernel.trace("sys_exit")
135 {
136 __set_syscall_pt_regs($regs)
137 @__compat_syscall_gate(@const("__NR_ia32_fallocate"))
138 @_SYSCALL_COMPAT_FALLOCATE_NAME
139 @SYSC_RETVALSTR($ret)
140 }