| 1 | /* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) */ |
| 2 | |
| 3 | #ifndef CREATE_SYSCALL_TABLE |
| 4 | |
| 5 | #define OVERRIDE_32_execve |
| 6 | #define OVERRIDE_64_execve |
| 7 | SC_LTTNG_TRACEPOINT_EVENT(execve, |
| 8 | TP_PROTO(sc_exit(long ret,) const char *filename, char *const *argv, char *const *envp), |
| 9 | TP_ARGS(sc_exit(ret,) filename, argv, envp), |
| 10 | TP_FIELDS(sc_exit(ctf_integer(long, ret, ret)) |
| 11 | sc_in(ctf_user_string(filename, filename)) |
| 12 | sc_in(ctf_integer_hex(char *const *, argv, argv)) |
| 13 | sc_in(ctf_integer_hex(char *const *, envp, envp)) |
| 14 | ) |
| 15 | ) |
| 16 | |
| 17 | /* |
| 18 | * Clone()'s `flags` field has two parts: |
| 19 | * 1. exit signal: the least significant byte of the `unsigned long` is |
| 20 | * the signal the kernel must send to the parent process on child |
| 21 | * exit, |
| 22 | * 2. clone options: the remaining bytes of the `unsigned long` is used a |
| 23 | * bitwise flag for the clone options. |
| 24 | */ |
| 25 | #define CLONE_EXIT_SIGNAL_FLAG_RESERVED_BITS 8 |
| 26 | #define LTTNG_CLONE_OPTIONS_FLAGS_TO_CTF(x) ((x) >> CLONE_EXIT_SIGNAL_FLAG_RESERVED_BITS) |
| 27 | |
| 28 | SC_LTTNG_TRACEPOINT_ENUM(lttng_clone_exit_signal_flags, |
| 29 | TP_ENUM_VALUES( |
| 30 | ctf_enum_value("SIGHUP", SIGHUP) |
| 31 | ctf_enum_value("SIGINT", SIGINT) |
| 32 | ctf_enum_value("SIGQUIT", SIGQUIT) |
| 33 | ctf_enum_value("SIGILL", SIGILL) |
| 34 | ctf_enum_value("SIGTRAP", SIGTRAP) |
| 35 | ctf_enum_value("SIGABRT", SIGABRT) |
| 36 | ctf_enum_value("SIGIOT", SIGIOT) |
| 37 | ctf_enum_value("SIGBUS", SIGBUS) |
| 38 | #ifdef SIGEMT |
| 39 | ctf_enum_value("SIGEMT", SIGEMT) |
| 40 | #endif /* #ifdef SIGEMT */ |
| 41 | ctf_enum_value("SIGFPE", SIGFPE) |
| 42 | ctf_enum_value("SIGKILL", SIGKILL) |
| 43 | ctf_enum_value("SIGUSR1", SIGUSR1) |
| 44 | ctf_enum_value("SIGSEGV", SIGSEGV) |
| 45 | ctf_enum_value("SIGUSR2", SIGUSR2) |
| 46 | ctf_enum_value("SIGPIPE", SIGPIPE) |
| 47 | ctf_enum_value("SIGALRM", SIGALRM) |
| 48 | ctf_enum_value("SIGTERM", SIGTERM) |
| 49 | #ifdef SIGSTKFLT |
| 50 | ctf_enum_value("SIGSTKFLT", SIGSTKFLT) |
| 51 | #endif /* #ifdef SIGSTKFLT */ |
| 52 | ctf_enum_value("SIGCHLD", SIGCHLD) |
| 53 | #ifdef SIGCLD |
| 54 | ctf_enum_value("SIGCLD", SIGCLD) |
| 55 | #endif /* #ifdef SIGCLD */ |
| 56 | ctf_enum_value("SIGCONT", SIGCONT) |
| 57 | ctf_enum_value("SIGSTOP", SIGSTOP) |
| 58 | ctf_enum_value("SIGTSTP", SIGTSTP) |
| 59 | ctf_enum_value("SIGTTIN", SIGTTIN) |
| 60 | ctf_enum_value("SIGTTOU", SIGTTOU) |
| 61 | ctf_enum_value("SIGURG", SIGURG) |
| 62 | ctf_enum_value("SIGXCPU", SIGXCPU) |
| 63 | ctf_enum_value("SIGXFSZ", SIGXFSZ) |
| 64 | ctf_enum_value("SIGVTALR", SIGVTALRM) |
| 65 | ctf_enum_value("SIGPROF", SIGPROF) |
| 66 | ctf_enum_value("SIGWINCH", SIGWINCH) |
| 67 | ctf_enum_value("SIGIO", SIGIO) |
| 68 | ctf_enum_value("SIGPOLL", SIGPOLL) |
| 69 | ctf_enum_value("SIGPWR", SIGPWR) |
| 70 | #ifdef SIGINFO |
| 71 | ctf_enum_value("SIGINFO", SIGINFO) |
| 72 | #endif /* #ifdef SIGINFO */ |
| 73 | #ifdef SIGLOST |
| 74 | ctf_enum_value("SIGLOST", SIGLOST) |
| 75 | #endif /* #ifdef SIGLOST */ |
| 76 | ctf_enum_value("SIGSYS", SIGSYS) |
| 77 | #ifdef SIGUNUSED |
| 78 | ctf_enum_value("SIGUNUSED", SIGUNUSED) |
| 79 | #endif /* #ifdef SIGUNUSED */ |
| 80 | ) |
| 81 | ) |
| 82 | |
| 83 | SC_LTTNG_TRACEPOINT_ENUM(lttng_clone_option_flags, |
| 84 | TP_ENUM_VALUES( |
| 85 | ctf_enum_value("CLONE_CHILD_CLEARTID", LTTNG_CLONE_OPTIONS_FLAGS_TO_CTF(CLONE_CHILD_CLEARTID)) |
| 86 | ctf_enum_value("CLONE_CHILD_SETTID", LTTNG_CLONE_OPTIONS_FLAGS_TO_CTF(CLONE_CHILD_SETTID)) |
| 87 | #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,5,0)) |
| 88 | ctf_enum_value("CLONE_CLEAR_SIGHAND", LTTNG_CLONE_OPTIONS_FLAGS_TO_CTF(CLONE_CLEAR_SIGHAND)) |
| 89 | #endif /* #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,5,0)) */ |
| 90 | ctf_enum_value("CLONE_DETACHED", LTTNG_CLONE_OPTIONS_FLAGS_TO_CTF(CLONE_DETACHED)) |
| 91 | ctf_enum_value("CLONE_FILES", LTTNG_CLONE_OPTIONS_FLAGS_TO_CTF(CLONE_FILES)) |
| 92 | ctf_enum_value("CLONE_FS", LTTNG_CLONE_OPTIONS_FLAGS_TO_CTF(CLONE_FS)) |
| 93 | ctf_enum_value("CLONE_IO", LTTNG_CLONE_OPTIONS_FLAGS_TO_CTF(CLONE_IO)) |
| 94 | #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,6,0)) |
| 95 | ctf_enum_value("CLONE_NEWCGROUP", LTTNG_CLONE_OPTIONS_FLAGS_TO_CTF(CLONE_NEWCGROUP)) |
| 96 | #endif /* #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,6,0)) */ |
| 97 | ctf_enum_value("CLONE_NEWIPC", LTTNG_CLONE_OPTIONS_FLAGS_TO_CTF(CLONE_NEWIPC)) |
| 98 | ctf_enum_value("CLONE_NEWNET", LTTNG_CLONE_OPTIONS_FLAGS_TO_CTF(CLONE_NEWNET)) |
| 99 | ctf_enum_value("CLONE_NEWNS", LTTNG_CLONE_OPTIONS_FLAGS_TO_CTF(CLONE_NEWNS)) |
| 100 | ctf_enum_value("CLONE_NEWPID", LTTNG_CLONE_OPTIONS_FLAGS_TO_CTF(CLONE_NEWPID)) |
| 101 | ctf_enum_value("CLONE_NEWUSER", LTTNG_CLONE_OPTIONS_FLAGS_TO_CTF(CLONE_NEWUSER)) |
| 102 | ctf_enum_value("CLONE_NEWUTS", LTTNG_CLONE_OPTIONS_FLAGS_TO_CTF(CLONE_NEWUTS)) |
| 103 | ctf_enum_value("CLONE_PARENT", LTTNG_CLONE_OPTIONS_FLAGS_TO_CTF(CLONE_PARENT)) |
| 104 | ctf_enum_value("CLONE_PARENT_SETTID", LTTNG_CLONE_OPTIONS_FLAGS_TO_CTF(CLONE_PARENT_SETTID)) |
| 105 | #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,2,0)) |
| 106 | ctf_enum_value("CLONE_PIDFD", LTTNG_CLONE_OPTIONS_FLAGS_TO_CTF(CLONE_PIDFD)) |
| 107 | #endif /* #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,2,0)) */ |
| 108 | ctf_enum_value("CLONE_PTRACE", LTTNG_CLONE_OPTIONS_FLAGS_TO_CTF(CLONE_PTRACE)) |
| 109 | ctf_enum_value("CLONE_SETTLS", LTTNG_CLONE_OPTIONS_FLAGS_TO_CTF(CLONE_SETTLS)) |
| 110 | ctf_enum_value("CLONE_SIGHAND", LTTNG_CLONE_OPTIONS_FLAGS_TO_CTF(CLONE_SIGHAND)) |
| 111 | ctf_enum_value("CLONE_SYSVSEM", LTTNG_CLONE_OPTIONS_FLAGS_TO_CTF(CLONE_SYSVSEM)) |
| 112 | ctf_enum_value("CLONE_THREAD", LTTNG_CLONE_OPTIONS_FLAGS_TO_CTF(CLONE_THREAD)) |
| 113 | ctf_enum_value("CLONE_UNTRACED", LTTNG_CLONE_OPTIONS_FLAGS_TO_CTF(CLONE_UNTRACED)) |
| 114 | ctf_enum_value("CLONE_VFORK", LTTNG_CLONE_OPTIONS_FLAGS_TO_CTF(CLONE_VFORK)) |
| 115 | ctf_enum_value("CLONE_VM", LTTNG_CLONE_OPTIONS_FLAGS_TO_CTF(CLONE_VM)) |
| 116 | ) |
| 117 | ) |
| 118 | |
| 119 | #define LTTNG_CLONE_FLAGS_EXIT_SIGNAL \ |
| 120 | lttng_kernel_static_event_field("exit_signal", \ |
| 121 | lttng_kernel_static_type_enum(&__enum_lttng_clone_exit_signal_flags, \ |
| 122 | lttng_kernel_static_type_integer(CLONE_EXIT_SIGNAL_FLAG_RESERVED_BITS, \ |
| 123 | 1, 0, __BYTE_ORDER, 16)), \ |
| 124 | false, false, false) |
| 125 | |
| 126 | #define LTTNG_CLONE_FLAGS_OPTIONS \ |
| 127 | lttng_kernel_static_event_field("options", \ |
| 128 | lttng_kernel_static_type_enum(&__enum_lttng_clone_option_flags, \ |
| 129 | lttng_kernel_static_type_integer( \ |
| 130 | sizeof(unsigned long) * CHAR_BIT - CLONE_EXIT_SIGNAL_FLAG_RESERVED_BITS, \ |
| 131 | 1, 0, __BYTE_ORDER, 16)), \ |
| 132 | false, false, false) |
| 133 | |
| 134 | #if (__BYTE_ORDER == __LITTLE_ENDIAN) |
| 135 | #define LTTNG_CLONE_FLAGS \ |
| 136 | lttng_kernel_static_event_field_array( \ |
| 137 | [0] = LTTNG_CLONE_FLAGS_EXIT_SIGNAL, \ |
| 138 | [1] = LTTNG_CLONE_FLAGS_OPTIONS, \ |
| 139 | ) |
| 140 | #else |
| 141 | #define LTTNG_CLONE_FLAGS \ |
| 142 | lttng_kernel_static_event_field_array( \ |
| 143 | [0] = LTTNG_CLONE_FLAGS_OPTIONS, \ |
| 144 | [1] = LTTNG_CLONE_FLAGS_EXIT_SIGNAL, \ |
| 145 | ) |
| 146 | #endif |
| 147 | |
| 148 | |
| 149 | #define OVERRIDE_32_clone |
| 150 | #define OVERRIDE_64_clone |
| 151 | SC_LTTNG_TRACEPOINT_EVENT(clone, |
| 152 | TP_PROTO(sc_exit(long ret,) unsigned long clone_flags, unsigned long newsp, |
| 153 | void __user *parent_tid, |
| 154 | void __user *child_tid), |
| 155 | TP_ARGS(sc_exit(ret,) clone_flags, newsp, parent_tid, child_tid), |
| 156 | TP_FIELDS( |
| 157 | sc_exit(ctf_integer(long, ret, ret)) |
| 158 | sc_in( |
| 159 | ctf_custom_field( |
| 160 | ctf_custom_type( |
| 161 | lttng_kernel_static_type_struct(2, LTTNG_CLONE_FLAGS, lttng_alignof(unsigned long) * CHAR_BIT) |
| 162 | ), |
| 163 | flags, |
| 164 | ctf_custom_code( |
| 165 | ctf_integer_type(unsigned long, clone_flags) |
| 166 | ) |
| 167 | ) |
| 168 | ) |
| 169 | sc_in(ctf_integer_hex(unsigned long, newsp, newsp)) |
| 170 | sc_in(ctf_integer_hex(void *, parent_tid, parent_tid)) |
| 171 | sc_in(ctf_integer_hex(void *, child_tid, child_tid)) |
| 172 | ) |
| 173 | ) |
| 174 | |
| 175 | /* present in 32, missing in 64 due to old kernel headers */ |
| 176 | #define OVERRIDE_32_getcpu |
| 177 | #define OVERRIDE_64_getcpu |
| 178 | SC_LTTNG_TRACEPOINT_EVENT(getcpu, |
| 179 | TP_PROTO(sc_exit(long ret,) unsigned __user *cpup, unsigned __user *nodep, void *tcache), |
| 180 | TP_ARGS(sc_exit(ret,) cpup, nodep, tcache), |
| 181 | TP_FIELDS( |
| 182 | sc_exit(ctf_integer(long, ret, ret)) |
| 183 | sc_out(ctf_integer_hex(unsigned *, cpup, cpup)) |
| 184 | sc_out(ctf_integer_hex(unsigned *, nodep, nodep)) |
| 185 | sc_inout(ctf_integer_hex(void *, tcache, tcache)) |
| 186 | ) |
| 187 | ) |
| 188 | |
| 189 | #define OVERRIDE_32_pipe2 |
| 190 | #define OVERRIDE_64_pipe2 |
| 191 | SC_LTTNG_TRACEPOINT_EVENT(pipe2, |
| 192 | TP_PROTO(sc_exit(long ret,) int * fildes, int flags), |
| 193 | TP_ARGS(sc_exit(ret,) fildes, flags), |
| 194 | TP_FIELDS(sc_exit(ctf_integer(long, ret, ret)) |
| 195 | sc_out(ctf_user_array(int, fildes, fildes, 2)) |
| 196 | sc_in(ctf_integer(int, flags, flags)) |
| 197 | ) |
| 198 | ) |
| 199 | |
| 200 | #define LTTNG_SYSCALL_SELECT_locvar \ |
| 201 | unsigned long *fds_in, *fds_out, *fds_ex; \ |
| 202 | unsigned long nr_bytes, nr_ulong; \ |
| 203 | uint8_t overflow; |
| 204 | |
| 205 | #define LTTNG_SYSCALL_SELECT_code_pre \ |
| 206 | sc_inout( \ |
| 207 | { \ |
| 208 | int err; \ |
| 209 | unsigned int n_in_bytes; \ |
| 210 | \ |
| 211 | tp_locvar->fds_in = NULL; \ |
| 212 | tp_locvar->fds_out = NULL; \ |
| 213 | tp_locvar->fds_ex = NULL; \ |
| 214 | tp_locvar->overflow = 0; \ |
| 215 | \ |
| 216 | sc_out( \ |
| 217 | if (ret <= 0) \ |
| 218 | goto error; \ |
| 219 | ) \ |
| 220 | \ |
| 221 | if (n <= 0) \ |
| 222 | goto error; \ |
| 223 | \ |
| 224 | /* On error or bogus input, don't copy anything. */ \ |
| 225 | if (n >__FD_SETSIZE) \ |
| 226 | goto error; \ |
| 227 | \ |
| 228 | n_in_bytes = DIV_ROUND_UP((unsigned int) n, BITS_PER_BYTE); \ |
| 229 | \ |
| 230 | /* \ |
| 231 | * Limit atomic memory allocation to one page, since n \ |
| 232 | * is limited to 1024 and the smallest page size on Linux \ |
| 233 | * is 4k, this should not happen, don't try to make it work. \ |
| 234 | */ \ |
| 235 | if (n_in_bytes > PAGE_SIZE) { \ |
| 236 | WARN_ON_ONCE(1); \ |
| 237 | /* Inform the user that we did not output everything. */ \ |
| 238 | tp_locvar->overflow = 1; \ |
| 239 | goto error; \ |
| 240 | } else { \ |
| 241 | tp_locvar->nr_bytes = n_in_bytes; \ |
| 242 | tp_locvar->nr_ulong = DIV_ROUND_UP(n_in_bytes, \ |
| 243 | sizeof(unsigned long)); \ |
| 244 | } \ |
| 245 | \ |
| 246 | if (inp) { \ |
| 247 | tp_locvar->fds_in = lttng_tp_mempool_alloc( \ |
| 248 | tp_locvar->nr_ulong * sizeof(unsigned long)); \ |
| 249 | if (!tp_locvar->fds_in) \ |
| 250 | goto error; \ |
| 251 | \ |
| 252 | err = lib_ring_buffer_copy_from_user_check_nofault( \ |
| 253 | tp_locvar->fds_in, inp, \ |
| 254 | tp_locvar->nr_ulong * sizeof(unsigned long)); \ |
| 255 | if (err != 0) \ |
| 256 | goto error; \ |
| 257 | } \ |
| 258 | if (outp) { \ |
| 259 | tp_locvar->fds_out = lttng_tp_mempool_alloc( \ |
| 260 | tp_locvar->nr_ulong * sizeof(unsigned long)); \ |
| 261 | if (!tp_locvar->fds_out) \ |
| 262 | goto error; \ |
| 263 | \ |
| 264 | err = lib_ring_buffer_copy_from_user_check_nofault( \ |
| 265 | tp_locvar->fds_out, outp, \ |
| 266 | tp_locvar->nr_ulong * sizeof(unsigned long)); \ |
| 267 | if (err != 0) \ |
| 268 | goto error; \ |
| 269 | } \ |
| 270 | if (exp) { \ |
| 271 | tp_locvar->fds_ex = lttng_tp_mempool_alloc( \ |
| 272 | tp_locvar->nr_ulong * sizeof(unsigned long)); \ |
| 273 | if (!tp_locvar->fds_ex) \ |
| 274 | goto error; \ |
| 275 | \ |
| 276 | err = lib_ring_buffer_copy_from_user_check_nofault( \ |
| 277 | tp_locvar->fds_ex, exp, \ |
| 278 | tp_locvar->nr_ulong * sizeof(unsigned long)); \ |
| 279 | if (err != 0) \ |
| 280 | goto error; \ |
| 281 | } \ |
| 282 | goto end; \ |
| 283 | \ |
| 284 | error: \ |
| 285 | tp_locvar->nr_bytes = 0; \ |
| 286 | tp_locvar->nr_ulong = 0; \ |
| 287 | end: ; /* Label at end of compound statement. */ \ |
| 288 | } \ |
| 289 | ) |
| 290 | |
| 291 | #define LTTNG_SYSCALL_SELECT_fds_field_LE(name, input) \ |
| 292 | ctf_custom_field( \ |
| 293 | ctf_custom_type( \ |
| 294 | lttng_kernel_static_type_integer_from_type(uint8_t, __BYTE_ORDER, 10) \ |
| 295 | ), \ |
| 296 | _ ## name ## _length, \ |
| 297 | ctf_custom_code( \ |
| 298 | if (input) { \ |
| 299 | ctf_integer_type(uint8_t, tp_locvar->nr_bytes) \ |
| 300 | ctf_align(uint8_t) \ |
| 301 | } else { \ |
| 302 | ctf_integer_type(uint8_t, 0) \ |
| 303 | ctf_align(uint8_t) \ |
| 304 | } \ |
| 305 | ) \ |
| 306 | ) \ |
| 307 | ctf_custom_field( \ |
| 308 | ctf_custom_type( \ |
| 309 | lttng_kernel_static_type_sequence(NULL, \ |
| 310 | lttng_kernel_static_type_integer_from_type(uint8_t, __BYTE_ORDER, 16), \ |
| 311 | 0, \ |
| 312 | none) \ |
| 313 | ), \ |
| 314 | name, \ |
| 315 | ctf_custom_code( \ |
| 316 | unsigned int src; \ |
| 317 | unsigned int nr_bytes_out = 0; \ |
| 318 | \ |
| 319 | if (!input) \ |
| 320 | goto skip_##name; \ |
| 321 | \ |
| 322 | for (src = 0; src < tp_locvar->nr_ulong; src++) { \ |
| 323 | int dst; \ |
| 324 | for (dst = 0; dst < sizeof(long); dst++) { \ |
| 325 | if (nr_bytes_out++ >= tp_locvar->nr_bytes) { \ |
| 326 | goto skip_##name; \ |
| 327 | } \ |
| 328 | ctf_user_integer_type(uint8_t, \ |
| 329 | ((uint8_t __user *) (input->fds_bits + src))[dst]); \ |
| 330 | } \ |
| 331 | } \ |
| 332 | skip_##name: ; \ |
| 333 | ) \ |
| 334 | ) |
| 335 | |
| 336 | #define LTTNG_SYSCALL_SELECT_fds_field_BE(name, input) \ |
| 337 | ctf_custom_field( \ |
| 338 | ctf_custom_type( \ |
| 339 | lttng_kernel_static_type_integer_from_type(uint8_t, __BYTE_ORDER, 10) \ |
| 340 | ), \ |
| 341 | _ ## name ## _length, \ |
| 342 | ctf_custom_code( \ |
| 343 | if (input) { \ |
| 344 | ctf_integer_type(uint8_t, tp_locvar->nr_bytes) \ |
| 345 | ctf_align(uint8_t) \ |
| 346 | } else { \ |
| 347 | ctf_integer_type(uint8_t, 0) \ |
| 348 | ctf_align(uint8_t) \ |
| 349 | } \ |
| 350 | ) \ |
| 351 | ) \ |
| 352 | ctf_custom_field( \ |
| 353 | ctf_custom_type( \ |
| 354 | lttng_kernel_static_type_sequence(NULL, \ |
| 355 | lttng_kernel_static_type_integer_from_type(uint8_t, __BYTE_ORDER, 16), \ |
| 356 | 0, \ |
| 357 | none) \ |
| 358 | ), \ |
| 359 | name, \ |
| 360 | ctf_custom_code( \ |
| 361 | unsigned int src, nr_bytes_out = 0; \ |
| 362 | \ |
| 363 | if (!input) \ |
| 364 | goto skip_##name; \ |
| 365 | \ |
| 366 | for (src = 0; src < tp_locvar->nr_ulong; src++) { \ |
| 367 | int dst; \ |
| 368 | for (dst = sizeof(long); dst >= 0; dst--) { \ |
| 369 | if (nr_bytes_out++ >= tp_locvar->nr_bytes) { \ |
| 370 | goto skip_##name; \ |
| 371 | } \ |
| 372 | ctf_user_integer_type(uint8_t, \ |
| 373 | ((uint8_t __user *) (input->fds_bits + src))[dst]); \ |
| 374 | } \ |
| 375 | } \ |
| 376 | skip_##name: ; \ |
| 377 | ) \ |
| 378 | ) |
| 379 | |
| 380 | #define LTTNG_SYSCALL_SELECT_code_post \ |
| 381 | lttng_tp_mempool_free(tp_locvar->fds_in); \ |
| 382 | lttng_tp_mempool_free(tp_locvar->fds_out); \ |
| 383 | lttng_tp_mempool_free(tp_locvar->fds_ex); |
| 384 | |
| 385 | #if defined(CONFIG_X86_32) || defined(CONFIG_X86_64) || defined(CONFIG_ARM) |
| 386 | #define OVERRIDE_32_select |
| 387 | #define OVERRIDE_64_select |
| 388 | SC_LTTNG_TRACEPOINT_EVENT_CODE(select, |
| 389 | TP_PROTO(sc_exit(long ret,) int n, fd_set __user *inp, fd_set __user *outp, |
| 390 | fd_set __user *exp, struct timeval *tvp), |
| 391 | TP_ARGS(sc_exit(ret,) n, inp, outp, exp, tvp), |
| 392 | TP_locvar( |
| 393 | LTTNG_SYSCALL_SELECT_locvar |
| 394 | ), |
| 395 | TP_code_pre( |
| 396 | LTTNG_SYSCALL_SELECT_code_pre |
| 397 | ), |
| 398 | TP_FIELDS( |
| 399 | sc_exit(ctf_integer(long, ret, ret)) |
| 400 | sc_in(ctf_integer(int, n, n)) |
| 401 | sc_inout(ctf_integer(uint8_t, overflow, tp_locvar->overflow)) |
| 402 | sc_inout(ctf_integer(struct timeval *, tvp, tvp)) |
| 403 | |
| 404 | sc_inout( |
| 405 | #if (__BYTE_ORDER == __LITTLE_ENDIAN) |
| 406 | LTTNG_SYSCALL_SELECT_fds_field_LE(readfds, inp) |
| 407 | LTTNG_SYSCALL_SELECT_fds_field_LE(writefds, outp) |
| 408 | LTTNG_SYSCALL_SELECT_fds_field_LE(exceptfds, exp) |
| 409 | #else |
| 410 | LTTNG_SYSCALL_SELECT_fds_field_BE(readfds, inp) |
| 411 | LTTNG_SYSCALL_SELECT_fds_field_BE(writefds, outp) |
| 412 | LTTNG_SYSCALL_SELECT_fds_field_BE(exceptfds, exp) |
| 413 | #endif |
| 414 | ) |
| 415 | ), |
| 416 | TP_code_post( |
| 417 | LTTNG_SYSCALL_SELECT_code_post |
| 418 | ) |
| 419 | ) |
| 420 | #endif /* defined(CONFIG_X86_32) || defined(CONFIG_X86_64) || defined(CONFIG_ARM) */ |
| 421 | |
| 422 | #if defined(CONFIG_X86_32) || defined(CONFIG_X86_64) || defined(CONFIG_ARM64) || defined(CONFIG_ARM) |
| 423 | #define OVERRIDE_32_pselect6 |
| 424 | #define OVERRIDE_64_pselect6 |
| 425 | SC_LTTNG_TRACEPOINT_EVENT_CODE(pselect6, |
| 426 | TP_PROTO(sc_exit(long ret,) int n, fd_set __user * inp, fd_set __user * outp, |
| 427 | fd_set __user * exp, struct timeval __user * tvp, void __user * sig), |
| 428 | TP_ARGS(sc_exit(ret,) n, inp, outp, exp, tvp, sig), |
| 429 | TP_locvar( |
| 430 | LTTNG_SYSCALL_SELECT_locvar |
| 431 | ), |
| 432 | TP_code_pre( |
| 433 | LTTNG_SYSCALL_SELECT_code_pre |
| 434 | ), |
| 435 | TP_FIELDS( |
| 436 | sc_exit(ctf_integer(long, ret, ret)) |
| 437 | sc_in(ctf_integer(int, n, n)) |
| 438 | sc_inout(ctf_integer(uint8_t, overflow, tp_locvar->overflow)) |
| 439 | sc_inout(ctf_integer(struct timeval *, tvp, tvp)) |
| 440 | sc_in(ctf_integer_hex(void *, sig, sig)) |
| 441 | |
| 442 | sc_inout( |
| 443 | #if (__BYTE_ORDER == __LITTLE_ENDIAN) |
| 444 | LTTNG_SYSCALL_SELECT_fds_field_LE(readfds, inp) |
| 445 | LTTNG_SYSCALL_SELECT_fds_field_LE(writefds, outp) |
| 446 | LTTNG_SYSCALL_SELECT_fds_field_LE(exceptfds, exp) |
| 447 | #else |
| 448 | LTTNG_SYSCALL_SELECT_fds_field_BE(readfds, inp) |
| 449 | LTTNG_SYSCALL_SELECT_fds_field_BE(writefds, outp) |
| 450 | LTTNG_SYSCALL_SELECT_fds_field_BE(exceptfds, exp) |
| 451 | #endif |
| 452 | ) |
| 453 | ), |
| 454 | TP_code_post( |
| 455 | LTTNG_SYSCALL_SELECT_code_post |
| 456 | ) |
| 457 | ) |
| 458 | #endif /* defined(CONFIG_X86_32) || defined(CONFIG_X86_64) || defined(CONFIG_ARM64) || defined(CONFIG_ARM) */ |
| 459 | |
| 460 | #ifdef LTTNG_CREATE_FIELD_METADATA |
| 461 | #ifndef ONCE_LTTNG_TRACE_POLL_H |
| 462 | #define ONCE_LTTNG_TRACE_POLL_H |
| 463 | |
| 464 | #define LTTNG_POLL_NRFLAGS (POLLNVAL + 1) |
| 465 | #define POLL_FLAGS_PADDING_SIZE (sizeof(uint8_t) * BITS_PER_BYTE) - \ |
| 466 | ilog2(LTTNG_POLL_NRFLAGS - 1) |
| 467 | |
| 468 | #ifndef LTTNG_TRACEPOINT_TYPE_EXTERN |
| 469 | /* |
| 470 | * Only extract the values specified by iBCS2 for now. |
| 471 | */ |
| 472 | static const struct lttng_kernel_event_field *lttng_pollfd_flag_fields[] = { |
| 473 | [ilog2(POLLIN)] = lttng_kernel_static_event_field("POLLIN", |
| 474 | lttng_kernel_static_type_integer(1, 1, 0, __LITTLE_ENDIAN, 10), |
| 475 | false, false, false), |
| 476 | [ilog2(POLLPRI)] = lttng_kernel_static_event_field("POLLPRI", |
| 477 | lttng_kernel_static_type_integer(1, 1, 0, __LITTLE_ENDIAN, 10), |
| 478 | false, false, false), |
| 479 | [ilog2(POLLOUT)] = lttng_kernel_static_event_field("POLLOUT", |
| 480 | lttng_kernel_static_type_integer(1, 1, 0, __LITTLE_ENDIAN, 10), |
| 481 | false, false, false), |
| 482 | [ilog2(POLLERR)] = lttng_kernel_static_event_field("POLLERR", |
| 483 | lttng_kernel_static_type_integer(1, 1, 0, __LITTLE_ENDIAN, 10), |
| 484 | false, false, false), |
| 485 | [ilog2(POLLHUP)] = lttng_kernel_static_event_field("POLLHUP", |
| 486 | lttng_kernel_static_type_integer(1, 1, 0, __LITTLE_ENDIAN, 10), |
| 487 | false, false, false), |
| 488 | [ilog2(POLLNVAL)] = lttng_kernel_static_event_field("POLLNVAL", |
| 489 | lttng_kernel_static_type_integer(1, 1, 0, __LITTLE_ENDIAN, 10), |
| 490 | false, false, false), |
| 491 | [ilog2(LTTNG_POLL_NRFLAGS)] = lttng_kernel_static_event_field("padding", |
| 492 | lttng_kernel_static_type_integer(POLL_FLAGS_PADDING_SIZE, 1, 0, __LITTLE_ENDIAN, 10), |
| 493 | false, false, false), |
| 494 | }; |
| 495 | |
| 496 | static_assert(((ARRAY_SIZE(lttng_pollfd_flag_fields) - 1) + POLL_FLAGS_PADDING_SIZE) == sizeof(uint8_t) * BITS_PER_BYTE); |
| 497 | |
| 498 | #endif /* LTTNG_TRACEPOINT_TYPE_EXTERN */ |
| 499 | |
| 500 | LTTNG_TRACEPOINT_TYPE(PARAMS(const struct lttng_kernel_type_struct lttng_pollfd_flag_fields_struct), |
| 501 | PARAMS(lttng_kernel_static_type_struct_init( ARRAY_SIZE(lttng_pollfd_flag_fields), lttng_pollfd_flag_fields, 0))) |
| 502 | |
| 503 | #ifndef LTTNG_TRACEPOINT_TYPE_EXTERN |
| 504 | static const struct lttng_kernel_event_field *lttng_pollfd_fields[] = { |
| 505 | [0] = lttng_kernel_static_event_field("fd", lttng_kernel_static_type_integer_from_type(int, __BYTE_ORDER, 10), |
| 506 | false, false, false), |
| 507 | [1] = lttng_kernel_static_event_field("raw_events", lttng_kernel_static_type_integer_from_type(uint16_t, __BYTE_ORDER, 16), |
| 508 | false, false, false), |
| 509 | [2] = lttng_kernel_static_event_field("events", |
| 510 | (const struct lttng_kernel_type_common *) <tng_pollfd_flag_fields_struct, |
| 511 | false, false, false), |
| 512 | }; |
| 513 | #endif /* LTTNG_TRACEPOINT_TYPE_EXTERN */ |
| 514 | |
| 515 | LTTNG_TRACEPOINT_TYPE(PARAMS(const struct lttng_kernel_type_struct lttng_pollfd_fields_struct), |
| 516 | PARAMS(lttng_kernel_static_type_struct_init(ARRAY_SIZE(lttng_pollfd_fields), lttng_pollfd_fields, 0))) |
| 517 | |
| 518 | #endif /* ONCE_LTTNG_TRACE_POLL_H */ |
| 519 | #endif /* LTTNG_CREATE_FIELD_METADATA */ |
| 520 | |
| 521 | #define LTTNG_SYSCALL_POLL_locvar \ |
| 522 | unsigned int fds_length, fds_max_len, alloc_fds; \ |
| 523 | struct pollfd *fds; \ |
| 524 | uint8_t overflow; |
| 525 | |
| 526 | #define LTTNG_SYSCALL_POLL_code_pre \ |
| 527 | tp_locvar->fds = NULL; \ |
| 528 | tp_locvar->overflow = 0; \ |
| 529 | \ |
| 530 | sc_in( \ |
| 531 | if (nfds > PAGE_SIZE / sizeof(struct pollfd)) { \ |
| 532 | tp_locvar->fds_length = PAGE_SIZE / sizeof(struct pollfd); \ |
| 533 | tp_locvar->fds_max_len = PAGE_SIZE / sizeof(struct pollfd); \ |
| 534 | tp_locvar->overflow = 1; \ |
| 535 | } else { \ |
| 536 | tp_locvar->fds_length = nfds; \ |
| 537 | tp_locvar->fds_max_len = nfds; \ |
| 538 | } \ |
| 539 | tp_locvar->alloc_fds = tp_locvar->fds_length * sizeof(struct pollfd); \ |
| 540 | ) \ |
| 541 | /* \ |
| 542 | * On exit, the number of active FDs is determined by ret, \ |
| 543 | * nfds stays the same as the entry, but we only want to \ |
| 544 | * output the FDs that are relevant. \ |
| 545 | */ \ |
| 546 | sc_out( \ |
| 547 | if (ret <= 0 || ret > nfds) \ |
| 548 | goto error; \ |
| 549 | \ |
| 550 | if (nfds > PAGE_SIZE / sizeof(struct pollfd)) { \ |
| 551 | tp_locvar->fds_length = PAGE_SIZE / sizeof(struct pollfd); \ |
| 552 | tp_locvar->fds_max_len = PAGE_SIZE / sizeof(struct pollfd); \ |
| 553 | tp_locvar->overflow = 1; \ |
| 554 | } else { \ |
| 555 | tp_locvar->fds_length = ret; \ |
| 556 | tp_locvar->fds_max_len = nfds; \ |
| 557 | } \ |
| 558 | tp_locvar->alloc_fds = tp_locvar->fds_max_len * sizeof(struct pollfd); \ |
| 559 | ) \ |
| 560 | { \ |
| 561 | int err; \ |
| 562 | \ |
| 563 | tp_locvar->fds = lttng_tp_mempool_alloc(tp_locvar->alloc_fds); \ |
| 564 | if (!tp_locvar->fds) \ |
| 565 | goto error; \ |
| 566 | err = lib_ring_buffer_copy_from_user_check_nofault( \ |
| 567 | tp_locvar->fds, ufds, tp_locvar->alloc_fds); \ |
| 568 | if (err != 0) \ |
| 569 | goto error; \ |
| 570 | } \ |
| 571 | goto end; \ |
| 572 | \ |
| 573 | error: \ |
| 574 | tp_locvar->fds_length = 0; \ |
| 575 | tp_locvar->fds_max_len = 0; \ |
| 576 | end: \ |
| 577 | ; |
| 578 | |
| 579 | #define LTTNG_SYSCALL_POLL_fds_field \ |
| 580 | sc_in( \ |
| 581 | ctf_custom_field( \ |
| 582 | ctf_custom_type( \ |
| 583 | lttng_kernel_static_type_sequence("fds_length", \ |
| 584 | (const struct lttng_kernel_type_common *) <tng_pollfd_fields_struct, \ |
| 585 | 0, \ |
| 586 | none) \ |
| 587 | ), \ |
| 588 | fds, \ |
| 589 | ctf_custom_code( \ |
| 590 | uint32_t i; \ |
| 591 | \ |
| 592 | ctf_align(int) /* Align on largest field in struct. */ \ |
| 593 | for (i = 0; i < tp_locvar->fds_length; i++) { \ |
| 594 | ctf_integer_type(int, tp_locvar->fds[i].fd) \ |
| 595 | ctf_integer_type(short, tp_locvar->fds[i].events) \ |
| 596 | ctf_integer_bitfield_type(uint8_t, \ |
| 597 | (uint8_t) tp_locvar->fds[i].events) \ |
| 598 | } \ |
| 599 | ) \ |
| 600 | ) \ |
| 601 | ) \ |
| 602 | sc_out( \ |
| 603 | ctf_custom_field( \ |
| 604 | ctf_custom_type( \ |
| 605 | lttng_kernel_static_type_sequence("fds_length", \ |
| 606 | (const struct lttng_kernel_type_common *) <tng_pollfd_fields_struct, \ |
| 607 | 0, \ |
| 608 | none) \ |
| 609 | ), \ |
| 610 | fds, \ |
| 611 | ctf_custom_code( \ |
| 612 | unsigned int i, nr = 0; \ |
| 613 | \ |
| 614 | ctf_align(int) /* Align on largest field in struct. */ \ |
| 615 | /* \ |
| 616 | * Iterate over the complete array, but only output \ |
| 617 | * "ret" active FDs. \ |
| 618 | */ \ |
| 619 | for (i = 0; i < tp_locvar->fds_max_len; i++) { \ |
| 620 | if (!tp_locvar->fds[i].revents) \ |
| 621 | continue; \ |
| 622 | if (nr++ >= tp_locvar->fds_length) \ |
| 623 | break; \ |
| 624 | ctf_integer_type(int, tp_locvar->fds[i].fd) \ |
| 625 | ctf_integer_type(short, tp_locvar->fds[i].revents) \ |
| 626 | ctf_integer_bitfield_type(uint8_t, \ |
| 627 | (uint8_t) tp_locvar->fds[i].revents) \ |
| 628 | } \ |
| 629 | /* \ |
| 630 | * If there is a discrepancy between ret and the \ |
| 631 | * content of revents (e.g. caused by userspace corrupting \ |
| 632 | * the array from a concurrent thread), we have to output \ |
| 633 | * zeros to keep the trace readable. \ |
| 634 | */ \ |
| 635 | for (i = nr; i < tp_locvar->fds_length; i++) { \ |
| 636 | ctf_integer_type(int, 0) \ |
| 637 | ctf_integer_type(short, 0) \ |
| 638 | ctf_integer_bitfield_type(uint8_t, 0) \ |
| 639 | } \ |
| 640 | ) \ |
| 641 | ) \ |
| 642 | ) |
| 643 | |
| 644 | #define LTTNG_SYSCALL_POLL_code_post \ |
| 645 | lttng_tp_mempool_free(tp_locvar->fds); |
| 646 | |
| 647 | #if defined(CONFIG_X86_32) || defined(CONFIG_X86_64) || defined(CONFIG_ARM) |
| 648 | #define OVERRIDE_32_poll |
| 649 | #define OVERRIDE_64_poll |
| 650 | SC_LTTNG_TRACEPOINT_EVENT_CODE(poll, |
| 651 | TP_PROTO(sc_exit(long ret,) struct pollfd __user * ufds, |
| 652 | unsigned int nfds, int timeout_msecs), |
| 653 | TP_ARGS(sc_exit(ret,) ufds, nfds, timeout_msecs), |
| 654 | TP_locvar( |
| 655 | LTTNG_SYSCALL_POLL_locvar |
| 656 | ), |
| 657 | TP_code_pre( |
| 658 | LTTNG_SYSCALL_POLL_code_pre |
| 659 | ), |
| 660 | TP_FIELDS( |
| 661 | sc_exit(ctf_integer(long, ret, ret)) |
| 662 | sc_in(ctf_integer(int, timeout_msecs, timeout_msecs)) |
| 663 | sc_inout(ctf_integer(unsigned int, nfds, nfds)) |
| 664 | sc_inout(ctf_integer(unsigned int, fds_length, tp_locvar->fds_length)) |
| 665 | sc_in(ctf_integer(uint8_t, overflow, tp_locvar->overflow)) |
| 666 | LTTNG_SYSCALL_POLL_fds_field |
| 667 | ), |
| 668 | TP_code_post( |
| 669 | LTTNG_SYSCALL_POLL_code_post |
| 670 | ) |
| 671 | ) |
| 672 | #endif /* defined(CONFIG_X86_32) || defined(CONFIG_X86_64) || defined(CONFIG_ARM) */ |
| 673 | |
| 674 | #if defined(CONFIG_X86_32) || defined(CONFIG_X86_64) || defined(CONFIG_ARM64) || defined(CONFIG_ARM) |
| 675 | #define OVERRIDE_32_ppoll |
| 676 | #define OVERRIDE_64_ppoll |
| 677 | SC_LTTNG_TRACEPOINT_EVENT_CODE(ppoll, |
| 678 | TP_PROTO(sc_exit(long ret,) struct pollfd __user * ufds, |
| 679 | unsigned int nfds, struct timespec * tsp, const sigset_t * sigmask, size_t sigsetsize), |
| 680 | TP_ARGS(sc_exit(ret,) ufds, nfds, tsp, sigmask, sigsetsize), |
| 681 | TP_locvar( |
| 682 | LTTNG_SYSCALL_POLL_locvar |
| 683 | ), |
| 684 | TP_code_pre( |
| 685 | LTTNG_SYSCALL_POLL_code_pre |
| 686 | ), |
| 687 | TP_FIELDS( |
| 688 | sc_exit(ctf_integer(long, ret, ret)) |
| 689 | sc_in(ctf_integer(struct timespec *, tsp, tsp)) |
| 690 | sc_in(ctf_integer(const sigset_t *, sigmask, sigmask)) |
| 691 | sc_in(ctf_integer(size_t, sigsetsize, sigsetsize)) |
| 692 | sc_inout(ctf_integer(unsigned int, nfds, nfds)) |
| 693 | sc_inout(ctf_integer(unsigned int, fds_length, tp_locvar->fds_length)) |
| 694 | sc_inout(ctf_integer(uint8_t, overflow, tp_locvar->overflow)) |
| 695 | LTTNG_SYSCALL_POLL_fds_field |
| 696 | ), |
| 697 | TP_code_post( |
| 698 | LTTNG_SYSCALL_POLL_code_post |
| 699 | ) |
| 700 | ) |
| 701 | #endif /* defined(CONFIG_X86_32) || defined(CONFIG_X86_64) || defined(CONFIG_ARM64) || defined(CONFIG_ARM) */ |
| 702 | |
| 703 | #include <linux/eventpoll.h> |
| 704 | |
| 705 | SC_LTTNG_TRACEPOINT_ENUM(lttng_epoll_op, |
| 706 | TP_ENUM_VALUES( |
| 707 | ctf_enum_value("EPOLL_CTL_ADD", EPOLL_CTL_ADD) |
| 708 | ctf_enum_value("EPOLL_CTL_DEL", EPOLL_CTL_DEL) |
| 709 | ctf_enum_value("EPOLL_CTL_MOD", EPOLL_CTL_MOD) |
| 710 | ) |
| 711 | ) |
| 712 | |
| 713 | #ifdef LTTNG_CREATE_FIELD_METADATA |
| 714 | |
| 715 | #ifndef ONCE_LTTNG_TRACE_EPOLL_CTL_H |
| 716 | #define ONCE_LTTNG_TRACE_EPOLL_CTL_H |
| 717 | |
| 718 | #define LTTNG_EPOLL_NRFLAGS (POLLHUP + 1) |
| 719 | #define EPOLL_FLAGS_PADDING_SIZE (sizeof(uint8_t) * BITS_PER_BYTE) - \ |
| 720 | ilog2(LTTNG_EPOLL_NRFLAGS - 1) |
| 721 | |
| 722 | #ifndef LTTNG_TRACEPOINT_TYPE_EXTERN |
| 723 | /* |
| 724 | * Only extract the values specified by iBCS2 for now. |
| 725 | */ |
| 726 | static const struct lttng_kernel_event_field *lttng_epoll_ctl_events_fields[] = { |
| 727 | /* 0x0001 */ |
| 728 | [ilog2(POLLIN)] = lttng_kernel_static_event_field("EPOLLIN", |
| 729 | lttng_kernel_static_type_integer(1, 1, 0, __LITTLE_ENDIAN, 10), |
| 730 | false, false, false), |
| 731 | /* 0x0002 */ |
| 732 | [ilog2(POLLPRI)] = lttng_kernel_static_event_field("EPOLLPRI", |
| 733 | lttng_kernel_static_type_integer(1, 1, 0, __LITTLE_ENDIAN, 10), |
| 734 | false, false, false), |
| 735 | /* 0x0004 */ |
| 736 | [ilog2(POLLOUT)] = lttng_kernel_static_event_field("EPOLLOUT", |
| 737 | lttng_kernel_static_type_integer(1, 1, 0, __LITTLE_ENDIAN, 10), |
| 738 | false, false, false), |
| 739 | /* 0x0008 */ |
| 740 | [ilog2(POLLERR)] = lttng_kernel_static_event_field("EPOLLERR", |
| 741 | lttng_kernel_static_type_integer(1, 1, 0, __LITTLE_ENDIAN, 10), |
| 742 | false, false, false), |
| 743 | /* 0x0010 */ |
| 744 | [ilog2(POLLHUP)] = lttng_kernel_static_event_field("EPOLLHUP", |
| 745 | lttng_kernel_static_type_integer(1, 1, 0, __LITTLE_ENDIAN, 10), |
| 746 | false, false, false), |
| 747 | [ilog2(LTTNG_EPOLL_NRFLAGS)] = lttng_kernel_static_event_field("padding", |
| 748 | lttng_kernel_static_type_integer(EPOLL_FLAGS_PADDING_SIZE, 1, 0, __LITTLE_ENDIAN, 10), |
| 749 | false, false, false), |
| 750 | }; |
| 751 | #endif /* LTTNG_TRACEPOINT_TYPE_EXTERN */ |
| 752 | |
| 753 | LTTNG_TRACEPOINT_TYPE(PARAMS(const struct lttng_kernel_type_struct lttng_epoll_ctl_events_fields_struct), |
| 754 | PARAMS(lttng_kernel_static_type_struct_init(ARRAY_SIZE(lttng_epoll_ctl_events_fields), lttng_epoll_ctl_events_fields, 0))) |
| 755 | |
| 756 | #ifndef LTTNG_TRACEPOINT_TYPE_EXTERN |
| 757 | static const struct lttng_kernel_event_field *lttng_epoll_data_fields[] = { |
| 758 | [0] = lttng_kernel_static_event_field("u64", |
| 759 | lttng_kernel_static_type_integer_from_type(uint64_t, __BYTE_ORDER, 16), |
| 760 | false, false, false), |
| 761 | [1] = lttng_kernel_static_event_field("fd", |
| 762 | lttng_kernel_static_type_integer_from_type(int, __BYTE_ORDER, 10), |
| 763 | false, false, false), |
| 764 | }; |
| 765 | #endif /* LTTNG_TRACEPOINT_TYPE_EXTERN */ |
| 766 | |
| 767 | LTTNG_TRACEPOINT_TYPE(PARAMS(const struct lttng_kernel_type_struct lttng_epoll_data_fields_struct), |
| 768 | PARAMS(lttng_kernel_static_type_struct_init(ARRAY_SIZE(lttng_epoll_data_fields), lttng_epoll_data_fields, 0))) |
| 769 | |
| 770 | #ifndef LTTNG_TRACEPOINT_TYPE_EXTERN |
| 771 | static const struct lttng_kernel_event_field *epoll_ctl_fields[] = { |
| 772 | [0] = lttng_kernel_static_event_field("data_union", |
| 773 | (const struct lttng_kernel_type_common *) <tng_epoll_data_fields_struct, |
| 774 | false, false, false), |
| 775 | [1] = lttng_kernel_static_event_field("raw_events", |
| 776 | lttng_kernel_static_type_integer_from_type(uint32_t, __BYTE_ORDER, 16), |
| 777 | false, false, false), |
| 778 | [2] = lttng_kernel_static_event_field("events", |
| 779 | (const struct lttng_kernel_type_common *) <tng_epoll_ctl_events_fields_struct, |
| 780 | false, false, false), |
| 781 | }; |
| 782 | #endif /* LTTNG_TRACEPOINT_TYPE_EXTERN */ |
| 783 | |
| 784 | LTTNG_TRACEPOINT_TYPE(PARAMS(const struct lttng_kernel_type_struct epoll_ctl_fields_struct), |
| 785 | PARAMS(lttng_kernel_static_type_struct_init(ARRAY_SIZE(epoll_ctl_fields), epoll_ctl_fields, 0))) |
| 786 | |
| 787 | #endif /* ONCE_LTTNG_TRACE_EPOLL_CTL_H */ |
| 788 | #endif /* LTTNG_CREATE_FIELD_METADATA */ |
| 789 | |
| 790 | #if defined(CONFIG_X86_32) || defined(CONFIG_X86_64) || defined(CONFIG_ARM64) || defined(CONFIG_ARM) |
| 791 | #define OVERRIDE_32_epoll_ctl |
| 792 | #define OVERRIDE_64_epoll_ctl |
| 793 | SC_LTTNG_TRACEPOINT_EVENT_CODE(epoll_ctl, |
| 794 | TP_PROTO(sc_exit(long ret,) int epfd, int op, int fd, |
| 795 | struct epoll_event __user * uevent), |
| 796 | TP_ARGS(sc_exit(ret,) epfd, op, fd, uevent), |
| 797 | TP_locvar( |
| 798 | struct epoll_event event; |
| 799 | int err; |
| 800 | ), |
| 801 | TP_code_pre( |
| 802 | tp_locvar->err = lib_ring_buffer_copy_from_user_check_nofault( |
| 803 | &tp_locvar->event, uevent, sizeof(struct epoll_event)); |
| 804 | ), |
| 805 | TP_FIELDS( |
| 806 | sc_exit(ctf_integer(long, ret, ret)) |
| 807 | sc_in(ctf_integer(int, epfd, epfd)) |
| 808 | sc_in(ctf_enum(lttng_epoll_op, int, op_enum, op)) |
| 809 | sc_in(ctf_integer(int, fd, fd)) |
| 810 | sc_in( |
| 811 | ctf_custom_field( |
| 812 | ctf_custom_type( |
| 813 | (const struct lttng_kernel_type_common *) &epoll_ctl_fields_struct |
| 814 | ), |
| 815 | event, |
| 816 | ctf_custom_code( |
| 817 | ctf_align(uint64_t) |
| 818 | if (!tp_locvar->err) { |
| 819 | ctf_integer_type(uint64_t, tp_locvar->event.data) |
| 820 | ctf_integer_type(int, tp_locvar->event.data) |
| 821 | ctf_integer_bitfield_type(uint32_t, |
| 822 | tp_locvar->event.events) |
| 823 | ctf_integer_bitfield_type(uint8_t, |
| 824 | (uint8_t) tp_locvar->event.events) |
| 825 | } else { |
| 826 | ctf_integer_type(uint64_t, 0) |
| 827 | ctf_integer_type(int, 0) |
| 828 | ctf_integer_bitfield_type(uint32_t, 0) |
| 829 | ctf_integer_bitfield_type(uint8_t, 0) |
| 830 | } |
| 831 | ) |
| 832 | ) |
| 833 | ) |
| 834 | ), |
| 835 | TP_code_post() |
| 836 | ) |
| 837 | #endif /* defined(CONFIG_X86_32) || defined(CONFIG_X86_64) || defined(CONFIG_ARM64) || defined(CONFIG_ARM) */ |
| 838 | |
| 839 | #ifdef LTTNG_CREATE_FIELD_METADATA |
| 840 | #ifndef ONCE_LTTNG_TRACE_EPOLL_H |
| 841 | #define ONCE_LTTNG_TRACE_EPOLL_H |
| 842 | |
| 843 | #ifndef LTTNG_TRACEPOINT_TYPE_EXTERN |
| 844 | static const struct lttng_kernel_event_field *lttng_epoll_wait_fields[] = lttng_kernel_static_event_field_array( |
| 845 | [0] = lttng_kernel_static_event_field("data_union", |
| 846 | (const struct lttng_kernel_type_common *) <tng_epoll_data_fields_struct, |
| 847 | false, false, false), |
| 848 | [1] = lttng_kernel_static_event_field("raw_events", lttng_kernel_static_type_integer_from_type(uint32_t, __BYTE_ORDER, 16), |
| 849 | false, false, false), |
| 850 | [2] = lttng_kernel_static_event_field("events", |
| 851 | (const struct lttng_kernel_type_common *) <tng_epoll_ctl_events_fields_struct, |
| 852 | false, false, false), |
| 853 | ); |
| 854 | |
| 855 | static_assert(((ARRAY_SIZE(lttng_epoll_ctl_events_fields) - 1) + EPOLL_FLAGS_PADDING_SIZE) == sizeof(uint8_t) * BITS_PER_BYTE); |
| 856 | |
| 857 | #endif /* LTTNG_TRACEPOINT_TYPE_EXTERN */ |
| 858 | |
| 859 | LTTNG_TRACEPOINT_TYPE(PARAMS(const struct lttng_kernel_type_struct lttng_epoll_wait_fields_struct), |
| 860 | PARAMS(lttng_kernel_static_type_struct_init(ARRAY_SIZE(lttng_epoll_wait_fields), lttng_epoll_wait_fields, 0))) |
| 861 | |
| 862 | #endif /* ONCE_LTTNG_TRACE_EPOLL_H */ |
| 863 | #endif /* LTTNG_CREATE_FIELD_METADATA */ |
| 864 | |
| 865 | #define LTTNG_SYSCALL_EPOLL_WAIT_locvar \ |
| 866 | sc_out( \ |
| 867 | unsigned int fds_length; \ |
| 868 | uint8_t overflow; \ |
| 869 | struct epoll_event *events; \ |
| 870 | ) |
| 871 | |
| 872 | #define LTTNG_SYSCALL_EPOLL_WAIT_code_pre \ |
| 873 | sc_out({ \ |
| 874 | int err; \ |
| 875 | unsigned long maxalloc; \ |
| 876 | \ |
| 877 | tp_locvar->fds_length = 0; \ |
| 878 | tp_locvar->events = NULL; \ |
| 879 | tp_locvar->overflow = 0; \ |
| 880 | \ |
| 881 | if (maxevents <= 0 || ret <= 0 || ret > maxevents) \ |
| 882 | goto skip_code; \ |
| 883 | \ |
| 884 | if (maxevents > PAGE_SIZE / sizeof(struct epoll_event)) { \ |
| 885 | maxalloc = PAGE_SIZE / sizeof(struct epoll_event); \ |
| 886 | } else { \ |
| 887 | maxalloc = maxevents; \ |
| 888 | } \ |
| 889 | \ |
| 890 | if (ret > maxalloc) { \ |
| 891 | tp_locvar->fds_length = maxalloc; \ |
| 892 | tp_locvar->overflow = 1; \ |
| 893 | } else { \ |
| 894 | tp_locvar->fds_length = ret; \ |
| 895 | } \ |
| 896 | \ |
| 897 | tp_locvar->events = lttng_tp_mempool_alloc( \ |
| 898 | maxalloc * sizeof(struct epoll_event)); \ |
| 899 | if (!tp_locvar->events) { \ |
| 900 | tp_locvar->fds_length = 0; \ |
| 901 | goto skip_code; \ |
| 902 | } \ |
| 903 | \ |
| 904 | err = lib_ring_buffer_copy_from_user_check_nofault( \ |
| 905 | tp_locvar->events, uevents, \ |
| 906 | maxalloc * sizeof(struct epoll_event)); \ |
| 907 | if (err != 0) \ |
| 908 | tp_locvar->fds_length = 0; \ |
| 909 | } \ |
| 910 | skip_code: \ |
| 911 | ) |
| 912 | |
| 913 | #define LTTNG_SYSCALL_EPOLL_WAIT_fds_field \ |
| 914 | ctf_custom_field( \ |
| 915 | ctf_custom_type( \ |
| 916 | lttng_kernel_static_type_sequence("fds_length", \ |
| 917 | (const struct lttng_kernel_type_common *) <tng_epoll_wait_fields_struct, \ |
| 918 | 0, \ |
| 919 | none) \ |
| 920 | ), \ |
| 921 | fds, \ |
| 922 | ctf_custom_code( \ |
| 923 | uint32_t i; \ |
| 924 | \ |
| 925 | ctf_align(uint64_t) \ |
| 926 | for (i = 0; i < tp_locvar->fds_length; i++) { \ |
| 927 | ctf_integer_type(uint64_t, tp_locvar->events[i].data) \ |
| 928 | ctf_integer_type(int, tp_locvar->events[i].data) \ |
| 929 | ctf_integer_bitfield_type(uint32_t, \ |
| 930 | tp_locvar->events[i].events) \ |
| 931 | ctf_integer_bitfield_type(uint8_t, \ |
| 932 | (uint8_t) tp_locvar->events[i].events) \ |
| 933 | } \ |
| 934 | ) \ |
| 935 | ) |
| 936 | |
| 937 | #define LTTNG_SYSCALL_EPOLL_WAIT_code_post \ |
| 938 | sc_out( \ |
| 939 | lttng_tp_mempool_free(tp_locvar->events); \ |
| 940 | ) |
| 941 | |
| 942 | |
| 943 | #if defined(CONFIG_X86_32) || defined(CONFIG_X86_64) || defined(CONFIG_ARM) |
| 944 | #define OVERRIDE_32_epoll_wait |
| 945 | #define OVERRIDE_64_epoll_wait |
| 946 | SC_LTTNG_TRACEPOINT_EVENT_CODE(epoll_wait, |
| 947 | TP_PROTO(sc_exit(long ret,) int epfd, struct epoll_event __user * uevents, |
| 948 | int maxevents, int timeout), |
| 949 | TP_ARGS(sc_exit(ret,) epfd, uevents, maxevents, timeout), |
| 950 | TP_locvar( |
| 951 | LTTNG_SYSCALL_EPOLL_WAIT_locvar |
| 952 | ), |
| 953 | TP_code_pre( |
| 954 | LTTNG_SYSCALL_EPOLL_WAIT_code_pre |
| 955 | ), |
| 956 | TP_FIELDS( |
| 957 | sc_exit(ctf_integer(long, ret, ret)) |
| 958 | sc_in(ctf_integer(int, epfd, epfd)) |
| 959 | sc_in(ctf_integer(int, maxevents, maxevents)) |
| 960 | sc_in(ctf_integer(int, timeout, timeout)) |
| 961 | sc_out(ctf_integer(unsigned int, fds_length, tp_locvar->fds_length)) |
| 962 | sc_out(ctf_integer(uint8_t, overflow, tp_locvar->overflow)) |
| 963 | sc_out( |
| 964 | LTTNG_SYSCALL_EPOLL_WAIT_fds_field |
| 965 | ) |
| 966 | ), |
| 967 | TP_code_post( |
| 968 | LTTNG_SYSCALL_EPOLL_WAIT_code_post |
| 969 | ) |
| 970 | ) |
| 971 | #endif /* defined(CONFIG_X86_32) || defined(CONFIG_X86_64) || defined(CONFIG_ARM) */ |
| 972 | |
| 973 | #if defined(CONFIG_X86_32) || defined(CONFIG_X86_64) || defined(CONFIG_ARM64) || defined(CONFIG_ARM) |
| 974 | #define OVERRIDE_32_epoll_pwait |
| 975 | #define OVERRIDE_64_epoll_pwait |
| 976 | SC_LTTNG_TRACEPOINT_EVENT_CODE(epoll_pwait, |
| 977 | TP_PROTO(sc_exit(long ret,) int epfd, struct epoll_event __user * uevents, |
| 978 | int maxevents, int timeout, const sigset_t __user * sigmask, size_t sigsetsize), |
| 979 | TP_ARGS(sc_exit(ret,) epfd, uevents, maxevents, timeout, sigmask, sigsetsize), |
| 980 | TP_locvar( |
| 981 | LTTNG_SYSCALL_EPOLL_WAIT_locvar |
| 982 | ), |
| 983 | TP_code_pre( |
| 984 | LTTNG_SYSCALL_EPOLL_WAIT_code_pre |
| 985 | ), |
| 986 | TP_FIELDS( |
| 987 | sc_exit(ctf_integer(long, ret, ret)) |
| 988 | sc_in(ctf_integer(int, epfd, epfd)) |
| 989 | sc_in(ctf_integer(int, maxevents, maxevents)) |
| 990 | sc_in(ctf_integer(int, timeout, timeout)) |
| 991 | sc_in(ctf_integer_hex(const sigset_t *, sigmask, sigmask)) |
| 992 | sc_in(ctf_integer(size_t, sigsetsize, sigsetsize)) |
| 993 | sc_out(ctf_integer(unsigned int, fds_length, tp_locvar->fds_length)) |
| 994 | sc_out(ctf_integer(uint8_t, overflow, tp_locvar->overflow)) |
| 995 | sc_out( |
| 996 | LTTNG_SYSCALL_EPOLL_WAIT_fds_field |
| 997 | ) |
| 998 | ), |
| 999 | TP_code_post( |
| 1000 | LTTNG_SYSCALL_EPOLL_WAIT_code_post |
| 1001 | ) |
| 1002 | ) |
| 1003 | #endif /* defined(CONFIG_X86_32) || defined(CONFIG_X86_64) || defined(CONFIG_ARM64) || defined(CONFIG_ARM) */ |
| 1004 | |
| 1005 | #if (defined(CONFIG_X86_64) && !defined(LTTNG_SC_COMPAT)) || defined(CONFIG_ARM64) || defined(CONFIG_ARM) |
| 1006 | #define OVERRIDE_32_socketpair |
| 1007 | #define OVERRIDE_64_socketpair |
| 1008 | SC_LTTNG_TRACEPOINT_EVENT(socketpair, |
| 1009 | TP_PROTO(sc_exit(long ret,) int family, int type, int protocol, int *usockvec), |
| 1010 | TP_ARGS(sc_exit(ret,) family, type, protocol, usockvec), |
| 1011 | TP_FIELDS( |
| 1012 | sc_exit(ctf_integer(long, ret, ret)) |
| 1013 | sc_in(ctf_integer(int, family, family)) |
| 1014 | sc_in(ctf_integer(int, type, type)) |
| 1015 | sc_in(ctf_integer(int, protocol, protocol)) |
| 1016 | sc_out(ctf_user_array(int, socket, usockvec, 2)) |
| 1017 | ) |
| 1018 | ) |
| 1019 | #endif /* (defined(CONFIG_X86_64) && !defined(LTTNG_SC_COMPAT)) || defined(CONFIG_ARM64) || defined(CONFIG_ARM) */ |
| 1020 | |
| 1021 | /* |
| 1022 | * Enumeration of the open flags, as described in the 'open' |
| 1023 | * system call man page. |
| 1024 | */ |
| 1025 | SC_LTTNG_TRACEPOINT_ENUM(lttng_file_status_flags, |
| 1026 | TP_ENUM_VALUES( |
| 1027 | ctf_enum_value("O_RDONLY", O_RDONLY) |
| 1028 | ctf_enum_value("O_WRONLY", O_WRONLY) |
| 1029 | ctf_enum_value("O_RDWR", O_RDWR) |
| 1030 | ctf_enum_value("O_CREAT", O_CREAT) |
| 1031 | ctf_enum_value("O_EXCL", O_EXCL) |
| 1032 | ctf_enum_value("O_NOCTTY", O_NOCTTY) |
| 1033 | ctf_enum_value("O_TRUNC", O_TRUNC) |
| 1034 | ctf_enum_value("O_APPEND", O_APPEND) |
| 1035 | ctf_enum_value("O_NONBLOCK", O_NONBLOCK) |
| 1036 | ctf_enum_value("O_DSYNC", O_DSYNC) |
| 1037 | ctf_enum_value("FASYNC", FASYNC) |
| 1038 | ctf_enum_value("O_DIRECT", O_DIRECT) |
| 1039 | ctf_enum_value("O_LARGEFILE", O_LARGEFILE) |
| 1040 | ctf_enum_value("O_DIRECTORY", O_DIRECTORY) |
| 1041 | ctf_enum_value("O_NOFOLLOW", O_NOFOLLOW) |
| 1042 | ctf_enum_value("O_NOATIME", O_NOATIME) |
| 1043 | ctf_enum_value("O_CLOEXEC", O_CLOEXEC) |
| 1044 | ctf_enum_value("O_SYNC", __O_SYNC) |
| 1045 | ctf_enum_value("O_PATH", O_PATH) |
| 1046 | #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,11,0)) |
| 1047 | ctf_enum_value("O_TMPFILE", __O_TMPFILE) |
| 1048 | #endif /* #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,11,0)) */ |
| 1049 | ) |
| 1050 | ) |
| 1051 | |
| 1052 | /* |
| 1053 | * Enumeration of the open flags, as described in the 'open' |
| 1054 | * system call man page. |
| 1055 | */ |
| 1056 | SC_LTTNG_TRACEPOINT_ENUM(lttng_file_mode, |
| 1057 | TP_ENUM_VALUES( |
| 1058 | ctf_enum_value("S_IRWXU", S_IRWXU) |
| 1059 | ctf_enum_value("S_IRUSR", S_IRUSR) |
| 1060 | ctf_enum_value("S_IWUSR", S_IWUSR) |
| 1061 | ctf_enum_value("S_IXUSR", S_IXUSR) |
| 1062 | ctf_enum_value("S_IRWXG", S_IRWXG) |
| 1063 | ctf_enum_value("S_IRGRP", S_IRGRP) |
| 1064 | ctf_enum_value("S_IWGRP", S_IWGRP) |
| 1065 | ctf_enum_value("S_IXGRP", S_IXGRP) |
| 1066 | ctf_enum_value("S_IRWXO", S_IRWXO) |
| 1067 | ctf_enum_value("S_IROTH", S_IROTH) |
| 1068 | ctf_enum_value("S_IWOTH", S_IWOTH) |
| 1069 | ctf_enum_value("S_IXOTH", S_IXOTH) |
| 1070 | ctf_enum_value("S_ISUID", S_ISUID) |
| 1071 | ctf_enum_value("S_ISGID", S_ISGID) |
| 1072 | ctf_enum_value("S_ISVTX", S_ISVTX) |
| 1073 | ) |
| 1074 | ) |
| 1075 | |
| 1076 | #define OVERRIDE_32_openat |
| 1077 | #define OVERRIDE_64_openat |
| 1078 | SC_LTTNG_TRACEPOINT_EVENT(openat, |
| 1079 | TP_PROTO(sc_exit(long ret,) int dfd, const char * filename, int flags, umode_t mode), |
| 1080 | TP_ARGS(sc_exit(ret,) dfd, filename, flags, mode), |
| 1081 | TP_FIELDS( |
| 1082 | sc_exit(ctf_integer(long, ret, ret)) |
| 1083 | sc_in(ctf_integer(int, dfd, dfd)) |
| 1084 | sc_in(ctf_user_string(filename, filename)) |
| 1085 | sc_in(ctf_enum(lttng_file_status_flags, int, flags, flags)) |
| 1086 | sc_in(ctf_enum(lttng_file_mode, umode_t, mode, mode)) |
| 1087 | ) |
| 1088 | ) |
| 1089 | |
| 1090 | #define OVERRIDE_32_open |
| 1091 | #define OVERRIDE_64_open |
| 1092 | SC_LTTNG_TRACEPOINT_EVENT(open, |
| 1093 | TP_PROTO(sc_exit(long ret,) const char * filename, int flags, umode_t mode), |
| 1094 | TP_ARGS(sc_exit(ret,) filename, flags, mode), |
| 1095 | TP_FIELDS( |
| 1096 | sc_exit(ctf_integer(long, ret, ret)) |
| 1097 | sc_in(ctf_user_string(filename, filename)) |
| 1098 | sc_in(ctf_enum(lttng_file_status_flags, int, flags, flags)) |
| 1099 | sc_in(ctf_enum(lttng_file_mode, umode_t, mode, mode)) |
| 1100 | ) |
| 1101 | ) |
| 1102 | |
| 1103 | #endif /* CREATE_SYSCALL_TABLE */ |