File: sysc_io_getevents.stp

package info (click to toggle)
systemtap 4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 36,436 kB
  • sloc: cpp: 72,388; ansic: 58,430; xml: 47,797; exp: 40,417; sh: 10,793; python: 2,759; perl: 2,252; tcl: 1,305; makefile: 1,119; lisp: 105; java: 102; awk: 101; asm: 91; sed: 16
file content (140 lines) | stat: -rw-r--r-- 4,355 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# io_getevents _______________________________________________
# long sys_io_getevents(aio_context_t ctx_id,
#		long min_nr,
#		long nr,
#		struct io_event __user *events,
#		struct timespec __user *timeout)
# long compat_sys_io_getevents(aio_context_t ctx_id,
#		 long min_nr,
#		 long nr,
#		 struct io_event __user *events,
#		 struct compat_timespec __user *timeout)
#

@define _SYSCALL_IO_GETEVENTS_NAME
%(
	name = "io_getevents"
%)

@define _SYSCALL_IO_GETEVENTS_ARGSTR
%(
	argstr = sprintf("%u, %d, %d, %p, %s", ctx_id, min_nr,
	                 nr, events_uaddr, timestr)
%)

@define _SYSCALL_IO_GETEVENTS_REGARGS
%(
	ctx_id = ulong_arg(1)
	min_nr = @__compat_task ? int_arg(2) : long_arg(2)
	nr = @__compat_task ? int_arg(3) : long_arg(3)
	events_uaddr = pointer_arg(4)
	timeout_uaddr = pointer_arg(5)
        timestr = (@__compat_task
	           ? _struct_compat_timespec_u(timeout_uaddr, 1)
	           : _struct_timespec_u(timeout_uaddr, 1))
%)

probe syscall.io_getevents = dw_syscall.io_getevents !, nd_syscall.io_getevents ? {}
probe syscall.io_getevents.return = dw_syscall.io_getevents.return !,
                                    nd_syscall.io_getevents.return ? {}

# dw_io_getevents _____________________________________________________

probe dw_syscall.io_getevents = __syscall.io_getevents ?,
	kernel.function("compat_sys_io_getevents").call ?
{
	@_SYSCALL_IO_GETEVENTS_NAME
        ctx_id = @__compat_ulong($ctx_id)
	events_uaddr = $events
	timeout_uaddr = $timeout
	nr = @__compat_long($nr)
	min_nr = @__compat_long($min_nr)
	timestr = (@__compat_task ?
	           _struct_compat_timespec_u($timeout, 1) :
	           _struct_timespec_u($timeout, 1))
	@_SYSCALL_IO_GETEVENTS_ARGSTR
}
probe __syscall.io_getevents = kernel.function("sys_io_getevents").call
{
	@__syscall_gate(@const("__NR_io_getevents"))
}
probe dw_syscall.io_getevents.return = __syscall.io_getevents.return,
	kernel.function("compat_sys_io_getevents").return ?
{
	@_SYSCALL_IO_GETEVENTS_NAME
	@SYSC_RETVALSTR($return)
}
probe __syscall.io_getevents.return = kernel.function("sys_io_getevents").return ?
{
	@__syscall_gate(@const("__NR_io_getevents"))
}

# nd_io_getevents _____________________________________________________

probe nd_syscall.io_getevents = nd1_syscall.io_getevents!, nd2_syscall.io_getevents!, tp_syscall.io_getevents
  { }

probe nd1_syscall.io_getevents = __nd1_syscall.io_getevents ?,
	kprobe.function("compat_sys_io_getevents") ?
{
	@_SYSCALL_IO_GETEVENTS_NAME
	asmlinkage()
	@_SYSCALL_IO_GETEVENTS_REGARGS
	@_SYSCALL_IO_GETEVENTS_ARGSTR
}
probe __nd1_syscall.io_getevents = kprobe.function("sys_io_getevents")
{
	@__syscall_gate_compat_simple
}

/* kernel 4.17+ */
probe nd2_syscall.io_getevents = kprobe.function(@arch_syscall_prefix "sys_io_getevents") ?,
	kprobe.function(@arch_syscall_prefix "compat_sys_io_getevents") ?
{
	__set_syscall_pt_regs(pointer_arg(1))
	@_SYSCALL_IO_GETEVENTS_NAME
	@_SYSCALL_IO_GETEVENTS_REGARGS
	@_SYSCALL_IO_GETEVENTS_ARGSTR
}

/* kernel 3.5+, but undesirable because it affects all syscalls */
probe tp_syscall.io_getevents = kernel.trace("sys_enter")
{
	__set_syscall_pt_regs($regs)
	@__syscall_compat_gate(@const("__NR_io_getevents"), @const("__NR_compat_io_getevents"))
	@_SYSCALL_IO_GETEVENTS_NAME
	@_SYSCALL_IO_GETEVENTS_REGARGS
	@_SYSCALL_IO_GETEVENTS_ARGSTR
}

probe nd_syscall.io_getevents.return = nd1_syscall.io_getevents.return!, nd2_syscall.io_getevents.return!, tp_syscall.io_getevents.return
  { }
  
probe nd1_syscall.io_getevents.return = __nd1_syscall.io_getevents.return,
	kprobe.function("compat_sys_io_getevents").return ?
{
	@_SYSCALL_IO_GETEVENTS_NAME
	@SYSC_RETVALSTR(returnval())
}
probe __nd1_syscall.io_getevents.return =
	kprobe.function("sys_io_getevents").return ?
{
	@__syscall_gate_compat_simple
}

/* kernel 4.17+ */
probe nd2_syscall.io_getevents.return = kprobe.function(@arch_syscall_prefix "sys_io_getevents").return ?,
	kprobe.function(@arch_syscall_prefix "compat_sys_io_getevents").return ?
{
	@_SYSCALL_IO_GETEVENTS_NAME
	@SYSC_RETVALSTR(returnval())
}
 
/* kernel 3.5+, but undesirable because it affects all syscalls */
probe tp_syscall.io_getevents.return = kernel.trace("sys_exit")
{
	__set_syscall_pt_regs($regs)
	@__syscall_compat_gate(@const("__NR_io_getevents"), @const("__NR_compat_io_getevents"))
	@_SYSCALL_IO_GETEVENTS_NAME
	@SYSC_RETVALSTR($ret)
}