Debian Codegraph @

tapset/linux/sysc_readv.stp

raw
1 # readv ______________________________________________________
2 #
3 # ssize_t sys_readv(unsigned long fd,
4 # const struct iovec __user *vec,
5 # unsigned long vlen)
6 # ssize_t compat_sys_readv(unsigned long fd,
7 # const struct compat_iovec __user *vec,
8 # unsigned long vlen)
9 #
10
11 @define _SYSCALL_READV_NAME
12 %(
13 name = "readv"
14 %)
15
16 @define _SYSCALL_READV_ARGSTR
17 %(
18 argstr = sprintf("%d, %p, %d", fd, vector_uaddr, count)
19 %)
20
21 @define _SYSCALL_READV_REGARGS
22 %(
23 vector_uaddr = pointer_arg(2)
24 count = int_arg(3)
25 fd = int_arg(1)
26 %)
27
28 @define _SYSCALL_READV_REGARGS_STORE
29 %(
30 if (@probewrite(fd))
31 set_int_arg(1, fd)
32
33 if (@probewrite(vector_uaddr))
34 set_pointer_arg(2, vector_uaddr)
35
36 if (@probewrite(count))
37 set_int_arg(3, count)
38 %)
39
40 probe syscall.readv = dw_syscall.readv !, nd_syscall.readv ? {}
41 probe syscall.readv.return = dw_syscall.readv.return !,
42 nd_syscall.readv.return ? {}
43
44 # dw_readv _____________________________________________________
45
46 probe dw_syscall.readv = kernel.function("compat_sys_readv").call ?,
47 kernel.function("sys_readv").call
48 {
49 @_SYSCALL_READV_NAME
50 vector_uaddr = $vec
51 count = __int32($vlen)
52 # Although the kernel gets an unsigned long fd, on the
53 # user-side it is a signed int. Fix this.
54 fd = __int32($fd)
55 @_SYSCALL_READV_ARGSTR
56 }
57 probe dw_syscall.readv.return = kernel.function("compat_sys_readv").return ?,
58 kernel.function("sys_readv").return
59 {
60 @_SYSCALL_READV_NAME
61 @SYSC_RETVALSTR($return)
62 }
63
64 # nd_readv _____________________________________________________
65
66 probe nd_syscall.readv = nd1_syscall.readv!, nd2_syscall.readv!, tp_syscall.readv
67 { }
68
69 probe nd1_syscall.readv = kprobe.function("compat_sys_readv") ?,
70 kprobe.function("sys_readv") ?
71 {
72 @_SYSCALL_READV_NAME
73 asmlinkage()
74 @_SYSCALL_READV_REGARGS
75 @_SYSCALL_READV_ARGSTR
76 }
77
78 /* kernel 4.17+ */
79 probe nd2_syscall.readv = kprobe.function(@arch_syscall_prefix "sys_readv") ?,
80 kprobe.function(@arch_syscall_prefix "compat_sys_readv") ?
81 {
82 __set_syscall_pt_regs(pointer_arg(1))
83 @_SYSCALL_READV_NAME
84 @_SYSCALL_READV_REGARGS
85 @_SYSCALL_READV_ARGSTR
86 },
87 {
88 %( @_IS_SREG_KERNEL %? @_SYSCALL_READV_REGARGS_STORE %)
89 }
90
91 /* kernel 3.5+, but undesirable because it affects all syscalls */
92 probe tp_syscall.readv = kernel.trace("sys_enter")
93 {
94 __set_syscall_pt_regs($regs)
95 @__syscall_compat_gate(@const("__NR_readv"), @const("__NR_compat_readv"))
96 @_SYSCALL_READV_NAME
97 @_SYSCALL_READV_REGARGS
98 @_SYSCALL_READV_ARGSTR
99 },
100 {
101 %( @_IS_SREG_KERNEL %? @_SYSCALL_READV_REGARGS_STORE %)
102 }
103
104 probe nd_syscall.readv.return = nd1_syscall.readv.return!, nd2_syscall.readv.return!, tp_syscall.readv.return
105 { }
106
107 probe nd1_syscall.readv.return = kprobe.function("compat_sys_readv").return ?,
108 kprobe.function("sys_readv").return ?
109 {
110 @_SYSCALL_READV_NAME
111 @SYSC_RETVALSTR(returnval())
112 }
113
114 /* kernel 4.17+ */
115 probe nd2_syscall.readv.return = kprobe.function(@arch_syscall_prefix "sys_readv").return ?,
116 kprobe.function(@arch_syscall_prefix "compat_sys_readv").return ?
117 {
118 @_SYSCALL_READV_NAME
119 @SYSC_RETVALSTR(returnval())
120 }
121
122 /* kernel 3.5+, but undesirable because it affects all syscalls */
123 probe tp_syscall.readv.return = kernel.trace("sys_exit")
124 {
125 __set_syscall_pt_regs($regs)
126 @__syscall_compat_gate(@const("__NR_readv"), @const("__NR_compat_readv"))
127 @_SYSCALL_READV_NAME
128 @SYSC_RETVALSTR($ret)
129 }