Debian Codegraph @

tapset/linux/sysc_msgget.stp

raw
1 # msgget _____________________________________________________
2 # long sys_msgget (key_t key, int msgflg)
3 #
4
5 @define _SYSCALL_MSGGET_NAME
6 %(
7 name = "msgget"
8 %)
9
10 @define _SYSCALL_MSGGET_ARGSTR
11 %(
12 argstr = sprintf("%s, %s", key_str, msgflg_str)
13 %)
14
15 @define _SYSCALL_MSGGET_REGARGS
16 %(
17 key = int_arg(1)
18 key_str = _stp_msgget_key_str(key)
19 msgflg = int_arg(2)
20 msgflg_str = __sem_flags(msgflg)
21 %)
22
23 @define _SYSCALL_MSGGET_REGARGS_STORE
24 %(
25 if (@probewrite(key))
26 set_int_arg(1, key)
27
28 if (@probewrite(msgflg))
29 set_int_arg(2, msgflg)
30 %)
31
32 @define _SYSCALL_IPC_MSGGET_REGARGS
33 %(
34 key = int_arg(2)
35 key_str = _stp_msgget_key_str(key)
36 msgflg = int_arg(3)
37 msgflg_str = __sem_flags(msgflg)
38 %)
39
40 @define _SYSCALL_IPC_MSGGET_REGARGS_STORE
41 %(
42 if (@probewrite(key))
43 set_int_arg(2, key)
44
45 if (@probewrite(msgflg))
46 set_int_arg(3, msgflg)
47 %)
48
49 probe syscall.msgget = dw_syscall.msgget !, nd_syscall.msgget ? {}
50 probe syscall.msgget.return = dw_syscall.msgget.return !, nd_syscall.msgget.return ? {}
51
52 # dw_msgget _____________________________________________________
53
54 probe dw_syscall.msgget = kernel.function("sys_msgget").call ?
55 {
56 @_SYSCALL_MSGGET_NAME
57 key = __int32($key)
58 key_str = _stp_msgget_key_str(__int32($key))
59 msgflg = __int32($msgflg)
60 msgflg_str = __sem_flags(__int32($msgflg))
61 @_SYSCALL_MSGGET_ARGSTR
62 }
63 probe dw_syscall.msgget.return = kernel.function("sys_msgget").return ?
64 {
65 @_SYSCALL_MSGGET_NAME
66 @SYSC_RETVALSTR($return)
67 }
68
69 # nd_msgget _____________________________________________________
70
71 probe nd_syscall.msgget = nd1_syscall.msgget!, nd2_syscall.msgget!, tp_syscall.msgget
72 { }
73
74 probe nd1_syscall.msgget = kprobe.function("sys_msgget") ?
75 {
76 @_SYSCALL_MSGGET_NAME
77 asmlinkage()
78 @_SYSCALL_MSGGET_REGARGS
79 @_SYSCALL_MSGGET_ARGSTR
80 }
81
82 /* kernel 4.17+ */
83 probe nd2_syscall.msgget = __nd2_syscall.msgget ?,
84 __nd2_syscall.compat_ipc.msgget ?
85 {
86 @_SYSCALL_MSGGET_NAME
87 @_SYSCALL_MSGGET_ARGSTR
88 }
89 probe __nd2_syscall.msgget = kprobe.function(@arch_syscall_prefix "sys_msgget") ?
90 {
91 __set_syscall_pt_regs(pointer_arg(1))
92 @_SYSCALL_MSGGET_REGARGS
93 },
94 {
95 %( @_IS_SREG_KERNEL %? @_SYSCALL_MSGGET_REGARGS_STORE %)
96 }
97 probe __nd2_syscall.compat_ipc.msgget =
98 kprobe.function(@arch_syscall_prefix "compat_sys_ipc") ?
99 {
100 __set_syscall_pt_regs(pointer_arg(1))
101 if ((uint_arg(1) & 0xffff) != @const("MSGGET")) next;
102 @_SYSCALL_IPC_MSGGET_REGARGS
103 },
104 {
105 %( @_IS_SREG_KERNEL %? @_SYSCALL_IPC_MSGGET_REGARGS_STORE %)
106 }
107
108 /* kernel 3.5+, but undesirable because it affects all syscalls */
109 probe tp_syscall.msgget = __tp_syscall.msgget, __tp_syscall.ipc.msgget
110 {
111 @_SYSCALL_MSGGET_NAME
112 @_SYSCALL_MSGGET_ARGSTR
113 }
114 probe __tp_syscall.msgget = kernel.trace("sys_enter")
115 {
116 __set_syscall_pt_regs($regs)
117 @__syscall_gate(@const("__NR_msgget"))
118 @_SYSCALL_MSGGET_REGARGS
119 },
120 {
121 %( @_IS_SREG_KERNEL %? @_SYSCALL_MSGGET_REGARGS_STORE %)
122 }
123 probe __tp_syscall.ipc.msgget = kernel.trace("sys_enter")
124 {
125 __set_syscall_pt_regs($regs)
126 @__syscall_compat_gate(@const("__NR_ipc"), @const("__NR_compat_ipc"))
127 if ((uint_arg(1) & 0xffff) != @const("MSGGET")) next;
128 @_SYSCALL_IPC_MSGGET_REGARGS
129 },
130 {
131 %( @_IS_SREG_KERNEL %? @_SYSCALL_IPC_MSGGET_REGARGS_STORE %)
132 }
133
134 probe nd_syscall.msgget.return = nd1_syscall.msgget.return!, nd2_syscall.msgget.return!, tp_syscall.msgget.return
135 { }
136
137 probe nd1_syscall.msgget.return = kprobe.function("sys_msgget").return ?
138 {
139 @_SYSCALL_MSGGET_NAME
140 @SYSC_RETVALSTR(returnval())
141 }
142
143 /* kernel 4.17+ */
144 probe nd2_syscall.msgget.return =
145 __nd2_syscall.compat_ipc.msgget.return ?,
146 kprobe.function(@arch_syscall_prefix "sys_msgget").return ?
147 {
148 @_SYSCALL_MSGGET_NAME
149 @SYSC_RETVALSTR(returnval())
150 }
151 probe __nd2_syscall.compat_ipc.msgget.return =
152 kprobe.function(@arch_syscall_prefix "compat_sys_ipc").return ?
153 {
154 __set_syscall_pt_regs(@entry(pointer_arg(1)))
155 if ((uint_arg(1) & 0xffff) != @const("MSGGET")) next;
156 }
157
158 /* kernel 3.5+, but undesirable because it affects all syscalls */
159 probe tp_syscall.msgget.return = __tp_syscall.msgget.return, __tp_syscall.ipc.msgget.return
160 {
161 @_SYSCALL_MSGGET_NAME
162 @SYSC_RETVALSTR($ret)
163 }
164 probe __tp_syscall.msgget.return = kernel.trace("sys_exit")
165 {
166 @__syscall_gate(@const("__NR_msgget"))
167 }
168 probe __tp_syscall.ipc.msgget.return = kernel.trace("sys_exit")
169 {
170 __set_syscall_pt_regs($regs)
171 @__syscall_compat_gate(@const("__NR_ipc"), @const("__NR_compat_ipc"))
172 if ((uint_arg(1) & 0xffff) != @const("MSGGET")) next;
173 }