File: sysc_msgget.stp

package info (click to toggle)
systemtap 5.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 47,556 kB
  • sloc: cpp: 81,117; ansic: 54,933; xml: 49,795; exp: 43,595; sh: 11,526; python: 5,003; perl: 2,252; tcl: 1,312; makefile: 1,006; javascript: 149; lisp: 105; awk: 101; asm: 91; java: 70; sed: 16
file content (173 lines) | stat: -rw-r--r-- 4,423 bytes parent folder | download | duplicates (4)
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
# msgget _____________________________________________________
# long sys_msgget (key_t key, int msgflg)
#

@define _SYSCALL_MSGGET_NAME
%(
	name = "msgget"
%)

@define _SYSCALL_MSGGET_ARGSTR
%(
	argstr = sprintf("%s, %s", key_str, msgflg_str)
%)

@define _SYSCALL_MSGGET_REGARGS
%(
	key = int_arg(1)
	key_str = _stp_msgget_key_str(key)
	msgflg = int_arg(2)
	msgflg_str = __sem_flags(msgflg)
%)

@define _SYSCALL_MSGGET_REGARGS_STORE
%(
        if (@probewrite(key))
          set_int_arg(1, key)

	if (@probewrite(msgflg))
	  set_int_arg(2, msgflg)
%)

@define _SYSCALL_IPC_MSGGET_REGARGS
%(
	key = int_arg(2)
	key_str = _stp_msgget_key_str(key)
	msgflg = int_arg(3)
	msgflg_str = __sem_flags(msgflg)
%)

@define _SYSCALL_IPC_MSGGET_REGARGS_STORE
%(
        if (@probewrite(key))
          set_int_arg(2, key)

	if (@probewrite(msgflg))
	  set_int_arg(3, msgflg)
%)

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

# dw_msgget _____________________________________________________

probe dw_syscall.msgget = kernel.function("sys_msgget").call ?
{
	@_SYSCALL_MSGGET_NAME
	key = __int32($key)
	key_str = _stp_msgget_key_str(__int32($key))
	msgflg = __int32($msgflg)
	msgflg_str = __sem_flags(__int32($msgflg))
	@_SYSCALL_MSGGET_ARGSTR
}
probe dw_syscall.msgget.return = kernel.function("sys_msgget").return ?
{
	@_SYSCALL_MSGGET_NAME
	@SYSC_RETVALSTR($return)
}

# nd_msgget _____________________________________________________

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

probe nd1_syscall.msgget = kprobe.function("sys_msgget") ?
{
	@_SYSCALL_MSGGET_NAME
	asmlinkage()
	@_SYSCALL_MSGGET_REGARGS
	@_SYSCALL_MSGGET_ARGSTR
}

/* kernel 4.17+ */
probe nd2_syscall.msgget = __nd2_syscall.msgget ?,
	__nd2_syscall.compat_ipc.msgget ?
{
	@_SYSCALL_MSGGET_NAME
	@_SYSCALL_MSGGET_ARGSTR
}
probe __nd2_syscall.msgget = kprobe.function(@arch_syscall_prefix "sys_msgget") ?
{
	__set_syscall_pt_regs(pointer_arg(1))
	@_SYSCALL_MSGGET_REGARGS
},
{
        %( @_IS_SREG_KERNEL %? @_SYSCALL_MSGGET_REGARGS_STORE %)
}
probe __nd2_syscall.compat_ipc.msgget =
	kprobe.function(@arch_syscall_prefix "compat_sys_ipc") ?
{
	__set_syscall_pt_regs(pointer_arg(1))
	if ((uint_arg(1) & 0xffff) != @const("MSGGET")) next;
	@_SYSCALL_IPC_MSGGET_REGARGS
},
{
        %( @_IS_SREG_KERNEL %? @_SYSCALL_IPC_MSGGET_REGARGS_STORE %)
}

/* kernel 3.5+, but undesirable because it affects all syscalls */
probe tp_syscall.msgget = __tp_syscall.msgget, __tp_syscall.ipc.msgget
{
	@_SYSCALL_MSGGET_NAME
	@_SYSCALL_MSGGET_ARGSTR
}
probe __tp_syscall.msgget = kernel.trace("sys_enter")
{
	__set_syscall_pt_regs($regs)
	@__syscall_gate(@const("__NR_msgget"))
	@_SYSCALL_MSGGET_REGARGS
},
{
        %( @_IS_SREG_KERNEL %? @_SYSCALL_MSGGET_REGARGS_STORE %)
}
probe __tp_syscall.ipc.msgget = kernel.trace("sys_enter")
{
	__set_syscall_pt_regs($regs)
	@__syscall_compat_gate(@const("__NR_ipc"), @const("__NR_compat_ipc"))
	if ((uint_arg(1) & 0xffff) != @const("MSGGET")) next;
	@_SYSCALL_IPC_MSGGET_REGARGS
},
{
        %( @_IS_SREG_KERNEL %? @_SYSCALL_IPC_MSGGET_REGARGS_STORE %)
}

probe nd_syscall.msgget.return = nd1_syscall.msgget.return!, nd2_syscall.msgget.return!, tp_syscall.msgget.return
  { }
  
probe nd1_syscall.msgget.return = kprobe.function("sys_msgget").return ?
{
	@_SYSCALL_MSGGET_NAME
	@SYSC_RETVALSTR(returnval())
}

/* kernel 4.17+ */
probe nd2_syscall.msgget.return =
	__nd2_syscall.compat_ipc.msgget.return ?,
	kprobe.function(@arch_syscall_prefix "sys_msgget").return ?
{
	@_SYSCALL_MSGGET_NAME
	@SYSC_RETVALSTR(returnval())
}
probe __nd2_syscall.compat_ipc.msgget.return =
	kprobe.function(@arch_syscall_prefix "compat_sys_ipc").return ?
{
	__set_syscall_pt_regs(@entry(pointer_arg(1)))
	if ((uint_arg(1) & 0xffff) != @const("MSGGET")) next;
}
 
/* kernel 3.5+, but undesirable because it affects all syscalls */
probe tp_syscall.msgget.return = __tp_syscall.msgget.return, __tp_syscall.ipc.msgget.return
{
	@_SYSCALL_MSGGET_NAME
	@SYSC_RETVALSTR($ret)
}
probe __tp_syscall.msgget.return = kernel.trace("sys_exit")
{
	@__syscall_gate(@const("__NR_msgget"))
}
probe __tp_syscall.ipc.msgget.return = kernel.trace("sys_exit")
{
	__set_syscall_pt_regs($regs)
	@__syscall_compat_gate(@const("__NR_ipc"), @const("__NR_compat_ipc"))
	if ((uint_arg(1) & 0xffff) != @const("MSGGET")) next;
}