blob: 52582380bb0171da5d0a171f836d379a0bc669df [file] [log] [blame]
Grant Edwards8a082772011-04-07 20:25:40 +00001/*
Elliott Hughes39bac052017-05-25 16:56:11 -07002 * Copyright (c) 2011 Comtrol Corp.
3 * Copyright (c) 2011-2017 The strace developers.
Grant Edwards8a082772011-04-07 20:25:40 +00004 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 */
29
30#include "defs.h"
Dmitry V. Levinb038a432011-08-30 16:05:26 +000031#include <sys/param.h>
Dmitry V. Levin80d5e012015-07-30 16:23:58 +000032#include <poll.h>
Grant Edwards8a082772011-04-07 20:25:40 +000033
34#include "syscall.h"
35
Elliott Hughes77c3ff82017-09-08 17:11:00 -070036struct path_set global_path_set;
Grant Edwards8a082772011-04-07 20:25:40 +000037
38/*
39 * Return true if specified path matches one that we're tracing.
40 */
Elliott Hughes77c3ff82017-09-08 17:11:00 -070041static bool
42pathmatch(const char *path, struct path_set *set)
Grant Edwards8a082772011-04-07 20:25:40 +000043{
Denys Vlasenko7239dbc2013-03-05 15:46:34 +010044 unsigned i;
Grant Edwards8a082772011-04-07 20:25:40 +000045
Elliott Hughes77c3ff82017-09-08 17:11:00 -070046 for (i = 0; i < set->num_selected; ++i) {
47 if (strcmp(path, set->paths_selected[i]) == 0)
48 return true;
Grant Edwards8a082772011-04-07 20:25:40 +000049 }
Elliott Hughes77c3ff82017-09-08 17:11:00 -070050 return false;
Grant Edwards8a082772011-04-07 20:25:40 +000051}
52
53/*
54 * Return true if specified path (in user-space) matches.
55 */
Elliott Hughes77c3ff82017-09-08 17:11:00 -070056static bool
57upathmatch(struct tcb *const tcp, const kernel_ulong_t upath,
58 struct path_set *set)
Grant Edwards8a082772011-04-07 20:25:40 +000059{
Denys Vlasenko7b609d52011-06-22 14:32:43 +020060 char path[PATH_MAX + 1];
Grant Edwards8a082772011-04-07 20:25:40 +000061
Elliott Hughesdc75b012017-07-05 13:54:44 -070062 return umovestr(tcp, upath, sizeof(path), path) > 0 &&
Elliott Hughes77c3ff82017-09-08 17:11:00 -070063 pathmatch(path, set);
Grant Edwards8a082772011-04-07 20:25:40 +000064}
65
66/*
67 * Return true if specified fd maps to a path we're tracing.
68 */
Elliott Hughes77c3ff82017-09-08 17:11:00 -070069static bool
70fdmatch(struct tcb *tcp, int fd, struct path_set *set)
Grant Edwards8a082772011-04-07 20:25:40 +000071{
Denys Vlasenko61ad0a42013-03-06 18:24:34 +010072 char path[PATH_MAX + 1];
73 int n = getfdpath(tcp, fd, path, sizeof(path));
Grant Edwards8a082772011-04-07 20:25:40 +000074
Elliott Hughes77c3ff82017-09-08 17:11:00 -070075 return n >= 0 && pathmatch(path, set);
Grant Edwards8a082772011-04-07 20:25:40 +000076}
77
78/*
79 * Add a path to the set we're tracing.
Philippe Ombredanne894c7e32014-02-01 09:57:45 -080080 * Specifying NULL will delete all paths.
Grant Edwards8a082772011-04-07 20:25:40 +000081 */
Denys Vlasenko7239dbc2013-03-05 15:46:34 +010082static void
Elliott Hughes77c3ff82017-09-08 17:11:00 -070083storepath(const char *path, struct path_set *set)
Grant Edwards8a082772011-04-07 20:25:40 +000084{
Denys Vlasenko7239dbc2013-03-05 15:46:34 +010085 unsigned i;
Grant Edwards8a082772011-04-07 20:25:40 +000086
Elliott Hughes77c3ff82017-09-08 17:11:00 -070087 if (pathmatch(path, set))
Denys Vlasenko7239dbc2013-03-05 15:46:34 +010088 return; /* already in table */
Grant Edwards8a082772011-04-07 20:25:40 +000089
Elliott Hughes77c3ff82017-09-08 17:11:00 -070090 i = set->num_selected++;
91 set->paths_selected = xreallocarray(set->paths_selected,
92 set->num_selected,
93 sizeof(set->paths_selected[0]));
94 set->paths_selected[i] = path;
Grant Edwards8a082772011-04-07 20:25:40 +000095}
96
97/*
98 * Get path associated with fd.
99 */
Denys Vlasenko61ad0a42013-03-06 18:24:34 +0100100int
101getfdpath(struct tcb *tcp, int fd, char *buf, unsigned bufsize)
Grant Edwards8a082772011-04-07 20:25:40 +0000102{
Denys Vlasenko384b0ad2012-03-15 18:11:51 +0100103 char linkpath[sizeof("/proc/%u/fd/%u") + 2 * sizeof(int)*3];
Grant Edwards8a082772011-04-07 20:25:40 +0000104 ssize_t n;
105
106 if (fd < 0)
Denys Vlasenko61ad0a42013-03-06 18:24:34 +0100107 return -1;
Grant Edwards8a082772011-04-07 20:25:40 +0000108
Denys Vlasenko29865e72012-03-15 18:03:56 +0100109 sprintf(linkpath, "/proc/%u/fd/%u", tcp->pid, fd);
Denys Vlasenko61ad0a42013-03-06 18:24:34 +0100110 n = readlink(linkpath, buf, bufsize - 1);
111 /*
112 * NB: if buf is too small, readlink doesn't fail,
113 * it returns truncated result (IOW: n == bufsize - 1).
114 */
115 if (n >= 0)
116 buf[n] = '\0';
117 return n;
Grant Edwards8a082772011-04-07 20:25:40 +0000118}
119
120/*
121 * Add a path to the set we're tracing. Also add the canonicalized
Elliott Hughes77c3ff82017-09-08 17:11:00 -0700122 * version of the path. Specifying NULL will delete all paths.
Grant Edwards8a082772011-04-07 20:25:40 +0000123 */
Denys Vlasenko7239dbc2013-03-05 15:46:34 +0100124void
Elliott Hughes77c3ff82017-09-08 17:11:00 -0700125pathtrace_select_set(const char *path, struct path_set *set)
Grant Edwards8a082772011-04-07 20:25:40 +0000126{
Denys Vlasenko29865e72012-03-15 18:03:56 +0100127 char *rpath;
Grant Edwards8a082772011-04-07 20:25:40 +0000128
Elliott Hughes77c3ff82017-09-08 17:11:00 -0700129 storepath(path, set);
Grant Edwards8a082772011-04-07 20:25:40 +0000130
131 rpath = realpath(path, NULL);
132
133 if (rpath == NULL)
Denys Vlasenko7239dbc2013-03-05 15:46:34 +0100134 return;
Grant Edwards8a082772011-04-07 20:25:40 +0000135
136 /* if realpath and specified path are same, we're done */
Denys Vlasenko29865e72012-03-15 18:03:56 +0100137 if (strcmp(path, rpath) == 0) {
Grant Edwards8a082772011-04-07 20:25:40 +0000138 free(rpath);
Denys Vlasenko7239dbc2013-03-05 15:46:34 +0100139 return;
Grant Edwards8a082772011-04-07 20:25:40 +0000140 }
141
Dmitry V. Levin6c8ef052015-05-25 22:51:19 +0000142 error_msg("Requested path '%s' resolved into '%s'", path, rpath);
Elliott Hughes77c3ff82017-09-08 17:11:00 -0700143 storepath(rpath, set);
Grant Edwards8a082772011-04-07 20:25:40 +0000144}
145
146/*
147 * Return true if syscall accesses a selected path
148 * (or if no paths have been specified for tracing).
149 */
Elliott Hughes77c3ff82017-09-08 17:11:00 -0700150bool
151pathtrace_match_set(struct tcb *tcp, struct path_set *set)
Grant Edwards8a082772011-04-07 20:25:40 +0000152{
Denys Vlasenkoa9fe13c2013-02-22 13:26:10 +0100153 const struct_sysent *s;
Grant Edwards8a082772011-04-07 20:25:40 +0000154
Denys Vlasenko74ec14f2013-02-21 16:13:47 +0100155 s = tcp->s_ent;
Grant Edwards8a082772011-04-07 20:25:40 +0000156
Philippe Ombredanne894c7e32014-02-01 09:57:45 -0800157 if (!(s->sys_flags & (TRACE_FILE | TRACE_DESC | TRACE_NETWORK)))
Elliott Hughes77c3ff82017-09-08 17:11:00 -0700158 return false;
Grant Edwards8a082772011-04-07 20:25:40 +0000159
160 /*
161 * Check for special cases where we need to do something
162 * other than test arg[0].
163 */
164
Elvira Khabirova483c15f2015-07-10 22:24:58 +0300165 switch (s->sen) {
166 case SEN_dup2:
167 case SEN_dup3:
Dmitry V. Levinea197052015-11-22 18:51:05 +0000168 case SEN_kexec_file_load:
Elvira Khabirova483c15f2015-07-10 22:24:58 +0300169 case SEN_sendfile:
170 case SEN_sendfile64:
171 case SEN_tee:
Grant Edwards8a082772011-04-07 20:25:40 +0000172 /* fd, fd */
Elliott Hughes77c3ff82017-09-08 17:11:00 -0700173 return fdmatch(tcp, tcp->u_arg[0], set) ||
174 fdmatch(tcp, tcp->u_arg[1], set);
Grant Edwards8a082772011-04-07 20:25:40 +0000175
Elliott Hughes77c3ff82017-09-08 17:11:00 -0700176 case SEN_execveat:
Elvira Khabirova483c15f2015-07-10 22:24:58 +0300177 case SEN_faccessat:
178 case SEN_fchmodat:
179 case SEN_fchownat:
Dmitry V. Levinc4da4892016-08-23 14:27:49 +0000180 case SEN_fstatat64:
Elvira Khabirova483c15f2015-07-10 22:24:58 +0300181 case SEN_futimesat:
182 case SEN_inotify_add_watch:
183 case SEN_mkdirat:
184 case SEN_mknodat:
Dmitry V. Levin4b3a1702015-11-22 21:29:32 +0000185 case SEN_name_to_handle_at:
Elvira Khabirova483c15f2015-07-10 22:24:58 +0300186 case SEN_newfstatat:
187 case SEN_openat:
Elvira Khabirova483c15f2015-07-10 22:24:58 +0300188 case SEN_readlinkat:
Elliott Hughes39bac052017-05-25 16:56:11 -0700189 case SEN_statx:
Elvira Khabirova483c15f2015-07-10 22:24:58 +0300190 case SEN_unlinkat:
191 case SEN_utimensat:
Grant Edwards8a082772011-04-07 20:25:40 +0000192 /* fd, path */
Elliott Hughes77c3ff82017-09-08 17:11:00 -0700193 return fdmatch(tcp, tcp->u_arg[0], set) ||
194 upathmatch(tcp, tcp->u_arg[1], set);
Grant Edwards8a082772011-04-07 20:25:40 +0000195
Elvira Khabirova483c15f2015-07-10 22:24:58 +0300196 case SEN_link:
197 case SEN_mount:
198 case SEN_pivotroot:
Grant Edwards8a082772011-04-07 20:25:40 +0000199 /* path, path */
Elliott Hughes77c3ff82017-09-08 17:11:00 -0700200 return upathmatch(tcp, tcp->u_arg[0], set) ||
201 upathmatch(tcp, tcp->u_arg[1], set);
Grant Edwards8a082772011-04-07 20:25:40 +0000202
Elvira Khabirova483c15f2015-07-10 22:24:58 +0300203 case SEN_quotactl:
Elliott Hughes77c3ff82017-09-08 17:11:00 -0700204 case SEN_symlink:
Dmitry V. Levin79439662012-10-26 23:43:13 +0000205 /* x, path */
Elliott Hughes77c3ff82017-09-08 17:11:00 -0700206 return upathmatch(tcp, tcp->u_arg[1], set);
Dmitry V. Levin79439662012-10-26 23:43:13 +0000207
Elvira Khabirova483c15f2015-07-10 22:24:58 +0300208 case SEN_linkat:
209 case SEN_renameat2:
210 case SEN_renameat:
Grant Edwards8a082772011-04-07 20:25:40 +0000211 /* fd, path, fd, path */
Elliott Hughes77c3ff82017-09-08 17:11:00 -0700212 return fdmatch(tcp, tcp->u_arg[0], set) ||
213 fdmatch(tcp, tcp->u_arg[2], set) ||
214 upathmatch(tcp, tcp->u_arg[1], set) ||
215 upathmatch(tcp, tcp->u_arg[3], set);
Grant Edwards8a082772011-04-07 20:25:40 +0000216
Elvira Khabirova483c15f2015-07-10 22:24:58 +0300217 case SEN_old_mmap:
Denys Vlasenko1ba85432013-02-19 11:28:20 +0100218#if defined(S390)
Elvira Khabirova483c15f2015-07-10 22:24:58 +0300219 case SEN_old_mmap_pgoff:
Denys Vlasenko1ba85432013-02-19 11:28:20 +0100220#endif
Elvira Khabirova483c15f2015-07-10 22:24:58 +0300221 case SEN_mmap:
222 case SEN_mmap_4koff:
223 case SEN_mmap_pgoff:
Dmitry V. Levindd1a80c2015-12-24 15:40:55 +0000224 case SEN_ARCH_mmap:
Grant Edwards8a082772011-04-07 20:25:40 +0000225 /* x, x, x, x, fd */
Elliott Hughes77c3ff82017-09-08 17:11:00 -0700226 return fdmatch(tcp, tcp->u_arg[4], set);
Grant Edwards8a082772011-04-07 20:25:40 +0000227
Elvira Khabirova483c15f2015-07-10 22:24:58 +0300228 case SEN_symlinkat:
Elliott Hughes77c3ff82017-09-08 17:11:00 -0700229 /* x, fd, path */
230 return fdmatch(tcp, tcp->u_arg[1], set) ||
231 upathmatch(tcp, tcp->u_arg[2], set);
Grant Edwards8a082772011-04-07 20:25:40 +0000232
Dmitry V. Levinc1f99f52016-02-13 03:45:32 +0000233 case SEN_copy_file_range:
Elvira Khabirova483c15f2015-07-10 22:24:58 +0300234 case SEN_splice:
Dmitry V. Levinc1f99f52016-02-13 03:45:32 +0000235 /* fd, x, fd, x, x, x */
Elliott Hughes77c3ff82017-09-08 17:11:00 -0700236 return fdmatch(tcp, tcp->u_arg[0], set) ||
237 fdmatch(tcp, tcp->u_arg[2], set);
Grant Edwards8a082772011-04-07 20:25:40 +0000238
Elvira Khabirova483c15f2015-07-10 22:24:58 +0300239 case SEN_epoll_ctl:
Grant Edwards8a082772011-04-07 20:25:40 +0000240 /* x, x, fd, x */
Elliott Hughes77c3ff82017-09-08 17:11:00 -0700241 return fdmatch(tcp, tcp->u_arg[2], set);
Grant Edwards8a082772011-04-07 20:25:40 +0000242
Elvira Khabirova483c15f2015-07-10 22:24:58 +0300243
244 case SEN_fanotify_mark:
Elliott Hughes77c3ff82017-09-08 17:11:00 -0700245 {
246 /* x, x, mask (64 bit), fd, path */
247 unsigned long long mask = 0;
248 int argn = getllval(tcp, &mask, 2);
249 return fdmatch(tcp, tcp->u_arg[argn], set) ||
250 upathmatch(tcp, tcp->u_arg[argn + 1], set);
251 }
Elvira Khabirova483c15f2015-07-10 22:24:58 +0300252 case SEN_oldselect:
253 case SEN_pselect6:
254 case SEN_select:
Grant Edwards8a082772011-04-07 20:25:40 +0000255 {
Denys Vlasenko79a79ea2011-09-01 16:35:44 +0200256 int i, j;
Denys Vlasenko64778cb2013-11-09 20:46:55 +0100257 int nfds;
Elliott Hughesd35df492017-02-15 15:19:05 -0800258 kernel_ulong_t *args;
259 kernel_ulong_t select_args[5];
260 unsigned int oldselect_args[5];
261 unsigned int fdsize;
Grant Edwards8a082772011-04-07 20:25:40 +0000262 fd_set *fds;
263
Elvira Khabirova483c15f2015-07-10 22:24:58 +0300264 if (SEN_oldselect == s->sen) {
Elliott Hughesd35df492017-02-15 15:19:05 -0800265 if (sizeof(*select_args) == sizeof(*oldselect_args)) {
266 if (umove(tcp, tcp->u_arg[0], &select_args)) {
Elliott Hughes77c3ff82017-09-08 17:11:00 -0700267 return false;
Elliott Hughesd35df492017-02-15 15:19:05 -0800268 }
269 } else {
270 unsigned int n;
271
272 if (umove(tcp, tcp->u_arg[0], &oldselect_args)) {
Elliott Hughes77c3ff82017-09-08 17:11:00 -0700273 return false;
Elliott Hughesd35df492017-02-15 15:19:05 -0800274 }
275
276 for (n = 0; n < 5; ++n) {
277 select_args[n] = oldselect_args[n];
278 }
Grant Edwards8a082772011-04-07 20:25:40 +0000279 }
Elliott Hughesd35df492017-02-15 15:19:05 -0800280 args = select_args;
281 } else {
282 args = tcp->u_arg;
Denys Vlasenko64778cb2013-11-09 20:46:55 +0100283 }
Grant Edwards8a082772011-04-07 20:25:40 +0000284
Denys Vlasenko64778cb2013-11-09 20:46:55 +0100285 /* Kernel truncates arg[0] to int, we do the same. */
286 nfds = (int) args[0];
287 /* Kernel rejects negative nfds, so we don't parse it either. */
288 if (nfds <= 0)
Elliott Hughes77c3ff82017-09-08 17:11:00 -0700289 return false;
Denys Vlasenko79a79ea2011-09-01 16:35:44 +0200290 /* Beware of select(2^31-1, NULL, NULL, NULL) and similar... */
Denys Vlasenko64778cb2013-11-09 20:46:55 +0100291 if (nfds > 1024*1024)
Denys Vlasenko79a79ea2011-09-01 16:35:44 +0200292 nfds = 1024*1024;
Denys Vlasenko64778cb2013-11-09 20:46:55 +0100293 fdsize = (((nfds + 7) / 8) + current_wordsize-1) & -current_wordsize;
Dmitry V. Levin3e9d71f2015-05-25 20:41:02 +0000294 fds = xmalloc(fdsize);
Grant Edwards8a082772011-04-07 20:25:40 +0000295
Denys Vlasenko7b609d52011-06-22 14:32:43 +0200296 for (i = 1; i <= 3; ++i) {
Grant Edwards8a082772011-04-07 20:25:40 +0000297 if (args[i] == 0)
298 continue;
Denys Vlasenko7e69ed92015-03-21 19:50:53 +0100299 if (umoven(tcp, args[i], fdsize, fds) < 0) {
Grant Edwards8a082772011-04-07 20:25:40 +0000300 continue;
301 }
Denys Vlasenko64778cb2013-11-09 20:46:55 +0100302 for (j = 0;; j++) {
303 j = next_set_bit(fds, j, nfds);
304 if (j < 0)
305 break;
Elliott Hughes77c3ff82017-09-08 17:11:00 -0700306 if (fdmatch(tcp, j, set)) {
Grant Edwards8a082772011-04-07 20:25:40 +0000307 free(fds);
Elliott Hughes77c3ff82017-09-08 17:11:00 -0700308 return true;
Grant Edwards8a082772011-04-07 20:25:40 +0000309 }
Denys Vlasenko64778cb2013-11-09 20:46:55 +0100310 }
Grant Edwards8a082772011-04-07 20:25:40 +0000311 }
312 free(fds);
Elliott Hughes77c3ff82017-09-08 17:11:00 -0700313 return false;
Grant Edwards8a082772011-04-07 20:25:40 +0000314 }
315
Elvira Khabirova483c15f2015-07-10 22:24:58 +0300316 case SEN_poll:
317 case SEN_ppoll:
Grant Edwards8a082772011-04-07 20:25:40 +0000318 {
319 struct pollfd fds;
320 unsigned nfds;
Elliott Hughesd35df492017-02-15 15:19:05 -0800321 kernel_ulong_t start, cur, end;
Grant Edwards8a082772011-04-07 20:25:40 +0000322
323 start = tcp->u_arg[0];
324 nfds = tcp->u_arg[1];
325
Elliott Hughes77c3ff82017-09-08 17:11:00 -0700326 if (nfds > 1024 * 1024)
327 nfds = 1024 * 1024;
Grant Edwards8a082772011-04-07 20:25:40 +0000328 end = start + sizeof(fds) * nfds;
329
330 if (nfds == 0 || end < start)
Elliott Hughes77c3ff82017-09-08 17:11:00 -0700331 return false;
Grant Edwards8a082772011-04-07 20:25:40 +0000332
Elliott Hughes77c3ff82017-09-08 17:11:00 -0700333 for (cur = start; cur < end; cur += sizeof(fds)) {
334 if (umove(tcp, cur, &fds))
335 break;
336 if (fdmatch(tcp, fds.fd, set))
337 return true;
338 }
Grant Edwards8a082772011-04-07 20:25:40 +0000339
Elliott Hughes77c3ff82017-09-08 17:11:00 -0700340 return false;
Grant Edwards8a082772011-04-07 20:25:40 +0000341 }
342
Dmitry V. Levinddb53dd2015-07-25 23:55:51 +0000343 case SEN_bpf:
Elvira Khabirova483c15f2015-07-10 22:24:58 +0300344 case SEN_epoll_create:
Dmitry V. Levin27163462015-08-01 23:07:19 +0000345 case SEN_epoll_create1:
Elvira Khabirova483c15f2015-07-10 22:24:58 +0300346 case SEN_eventfd2:
347 case SEN_eventfd:
348 case SEN_fanotify_init:
Elliott Hughes77c3ff82017-09-08 17:11:00 -0700349 case SEN_inotify_init:
Elvira Khabirova483c15f2015-07-10 22:24:58 +0300350 case SEN_inotify_init1:
Dmitry V. Levin95b84ea2015-07-28 23:03:41 +0000351 case SEN_memfd_create:
Elvira Khabirova483c15f2015-07-10 22:24:58 +0300352 case SEN_perf_event_open:
353 case SEN_pipe:
Dmitry V. Levinf9f04f72016-02-12 16:15:23 +0000354 case SEN_pipe2:
Elvira Khabirova483c15f2015-07-10 22:24:58 +0300355 case SEN_printargs:
356 case SEN_socket:
357 case SEN_socketpair:
358 case SEN_timerfd_create:
359 case SEN_timerfd_gettime:
360 case SEN_timerfd_settime:
Dmitry V. Levin87d64ed2015-11-22 19:56:00 +0000361 case SEN_userfaultfd:
Grant Edwards8a082772011-04-07 20:25:40 +0000362 /*
Philippe Ombredanne894c7e32014-02-01 09:57:45 -0800363 * These have TRACE_FILE or TRACE_DESCRIPTOR or TRACE_NETWORK set,
364 * but they don't have any file descriptor or path args to test.
Grant Edwards8a082772011-04-07 20:25:40 +0000365 */
Elliott Hughes77c3ff82017-09-08 17:11:00 -0700366 return false;
Grant Edwards8a082772011-04-07 20:25:40 +0000367 }
Grant Edwards8a082772011-04-07 20:25:40 +0000368
369 /*
370 * Our fallback position for calls that haven't already
371 * been handled is to just check arg[0].
372 */
373
374 if (s->sys_flags & TRACE_FILE)
Elliott Hughes77c3ff82017-09-08 17:11:00 -0700375 return upathmatch(tcp, tcp->u_arg[0], set);
Grant Edwards8a082772011-04-07 20:25:40 +0000376
Philippe Ombredanne894c7e32014-02-01 09:57:45 -0800377 if (s->sys_flags & (TRACE_DESC | TRACE_NETWORK))
Elliott Hughes77c3ff82017-09-08 17:11:00 -0700378 return fdmatch(tcp, tcp->u_arg[0], set);
Grant Edwards8a082772011-04-07 20:25:40 +0000379
Elliott Hughes77c3ff82017-09-08 17:11:00 -0700380 return false;
Grant Edwards8a082772011-04-07 20:25:40 +0000381}