Debian Codegraph @

tapset/linux/sysc_poll.stp

raw
1 # poll _______________________________________________________
2 #
3 # long sys_poll(struct pollfd __user * ufds, unsigned int nfds, int timeout)
4 #
5
6 @define _SYSCALL_POLL_NAME
7 %(
8 name = "poll"
9 %)
10
11 @define _SYSCALL_POLL_ARGSTR
12 %(
13 argstr = sprintf("%p, %u, %d", ufds_uaddr, nfds, timeout)
14 %)
15
16 @define _SYSCALL_POLL_REGARGS
17 %(
18 ufds_uaddr = pointer_arg(1)
19 nfds = uint_arg(2)
20 timeout = int_arg(3)
21 %)
22
23 @define _SYSCALL_POLL_REGARGS_STORE
24 %(
25 if (@probewrite(ufds_uaddr))
26 set_pointer_arg(1, ufds_uaddr)
27
28 if (@probewrite(nfds))
29 set_uint_arg(2, nfds)
30
31 if (@probewrite(timeout))
32 set_int_arg(3, timeout)
33 %)
34
35 probe syscall.poll = dw_syscall.poll !, nd_syscall.poll ? {}
36 probe syscall.poll.return = dw_syscall.poll.return !, nd_syscall.poll.return ? {}
37
38 # dw_poll _____________________________________________________
39
40 probe dw_syscall.poll = kernel.function("sys_poll").call
41 {
42 @_SYSCALL_POLL_NAME
43 ufds_uaddr = $ufds
44 nfds = __uint32($nfds)
45 timeout = __int32(@choose_defined($timeout_msecs, $timeout))
46 @_SYSCALL_POLL_ARGSTR
47 }
48 probe dw_syscall.poll.return = kernel.function("sys_poll").return
49 {
50 @_SYSCALL_POLL_NAME
51 @SYSC_RETVALSTR($return)
52 }
53
54 # nd_poll _____________________________________________________
55
56 probe nd_syscall.poll = nd1_syscall.poll!, nd2_syscall.poll!, tp_syscall.poll
57 { }
58
59 probe nd1_syscall.poll = kprobe.function("sys_poll") ?
60 {
61 @_SYSCALL_POLL_NAME
62 asmlinkage()
63 @_SYSCALL_POLL_REGARGS
64 @_SYSCALL_POLL_ARGSTR
65 }
66
67 /* kernel 4.17+ */
68 probe nd2_syscall.poll = kprobe.function(@arch_syscall_prefix "sys_poll") ?
69 {
70 __set_syscall_pt_regs(pointer_arg(1))
71 @_SYSCALL_POLL_NAME
72 @_SYSCALL_POLL_REGARGS
73 @_SYSCALL_POLL_ARGSTR
74 },
75 {
76 %( @_IS_SREG_KERNEL %? @_SYSCALL_POLL_REGARGS_STORE %)
77 }
78
79 /* kernel 3.5+, but undesirable because it affects all syscalls */
80 probe tp_syscall.poll = kernel.trace("sys_enter")
81 {
82 __set_syscall_pt_regs($regs)
83 @__syscall_compat_gate(@const("__NR_poll"), @const("__NR_compat_poll"))
84 @_SYSCALL_POLL_NAME
85 @_SYSCALL_POLL_REGARGS
86 @_SYSCALL_POLL_ARGSTR
87 },
88 {
89 %( @_IS_SREG_KERNEL %? @_SYSCALL_POLL_REGARGS_STORE %)
90 }
91
92 probe nd_syscall.poll.return = nd1_syscall.poll.return!, nd2_syscall.poll.return!, tp_syscall.poll.return
93 { }
94
95 probe nd1_syscall.poll.return = kprobe.function("sys_poll").return ?
96 {
97 @_SYSCALL_POLL_NAME
98 @SYSC_RETVALSTR(returnval())
99 }
100
101 /* kernel 4.17+ */
102 probe nd2_syscall.poll.return = kprobe.function(@arch_syscall_prefix "sys_poll").return ?
103 {
104 @_SYSCALL_POLL_NAME
105 @SYSC_RETVALSTR(returnval())
106 }
107
108 /* kernel 3.5+, but undesirable because it affects all syscalls */
109 probe tp_syscall.poll.return = kernel.trace("sys_exit")
110 {
111 __set_syscall_pt_regs($regs)
112 @__syscall_compat_gate(@const("__NR_poll"), @const("__NR_compat_poll"))
113 @_SYSCALL_POLL_NAME
114 @SYSC_RETVALSTR($ret)
115 }