X-Git-Url: http://git.liburcu.org/?a=blobdiff_plain;f=lttng-syscalls.c;h=97a12c4835a896e0a0e050c98d5aa5cd0e25af5a;hb=1efb917a94b34e724a061668f3d722bfcde640c5;hp=26cead68252f336221b31a3e54c9f86aeb8cdf08;hpb=ad594e3a953db1b0c3c059fde45b5a5494f6be78;p=lttng-modules.git diff --git a/lttng-syscalls.c b/lttng-syscalls.c index 26cead68..97a12c48 100644 --- a/lttng-syscalls.c +++ b/lttng-syscalls.c @@ -27,6 +27,7 @@ #include #include #include +#include #ifndef CONFIG_COMPAT # ifndef is_compat_task @@ -36,7 +37,14 @@ /* in_compat_syscall appears in kernel 4.6. */ #ifndef in_compat_syscall - #define in_compat_syscall() is_compat_task() +# define in_compat_syscall() is_compat_task() +#endif + +/* in_x32_syscall appears in kernel 4.7. */ +#if (LTTNG_LINUX_VERSION_CODE < LTTNG_KERNEL_VERSION(4,7,0)) +# ifdef CONFIG_X86_X32_ABI +# define in_x32_syscall() is_x32_task() +# endif #endif enum sc_type { @@ -81,7 +89,7 @@ struct timeval; struct itimerval; struct itimerspec; -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,6,0)) +#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,6,0)) typedef __kernel_old_time_t time_t; #endif @@ -392,6 +400,12 @@ void syscall_entry_probe(void *__data, struct pt_regs *regs, long id) const struct trace_syscall_entry *table, *entry; size_t table_len; +#ifdef CONFIG_X86_X32_ABI + if (in_x32_syscall()) { + /* x32 system calls are not supported. */ + return; + } +#endif if (unlikely(in_compat_syscall())) { struct lttng_syscall_filter *filter = chan->sc_filter; @@ -539,6 +553,12 @@ void syscall_exit_probe(void *__data, struct pt_regs *regs, long ret) size_t table_len; long id; +#ifdef CONFIG_X86_X32_ABI + if (in_x32_syscall()) { + /* x32 system calls are not supported. */ + return; + } +#endif id = syscall_get_nr(current, regs); if (unlikely(in_compat_syscall())) { struct lttng_syscall_filter *filter = chan->sc_filter; @@ -719,7 +739,7 @@ int fill_table(const struct trace_syscall_entry *table, size_t table_len, ev.u.syscall.abi = LTTNG_KERNEL_SYSCALL_ABI_COMPAT; break; } - strncpy(ev.name, desc->name, LTTNG_KERNEL_SYM_NAME_LEN); + strncpy(ev.name, desc->name, LTTNG_KERNEL_SYM_NAME_LEN - 1); ev.name[LTTNG_KERNEL_SYM_NAME_LEN - 1] = '\0'; ev.instrumentation = LTTNG_KERNEL_SYSCALL; chan_table[i] = _lttng_event_create(chan, &ev, filter, @@ -1057,7 +1077,6 @@ int lttng_syscall_filter_enable(struct lttng_channel *chan, if (syscall_nr < 0) return -ENOENT; - switch (event->u.syscall.entryexit) { case LTTNG_SYSCALL_ENTRY: switch (event->u.syscall.abi) { @@ -1067,6 +1086,8 @@ int lttng_syscall_filter_enable(struct lttng_channel *chan, case LTTNG_SYSCALL_ABI_COMPAT: bitmap = filter->sc_compat_entry; break; + default: + return -EINVAL; } break; case LTTNG_SYSCALL_EXIT: @@ -1077,6 +1098,8 @@ int lttng_syscall_filter_enable(struct lttng_channel *chan, case LTTNG_SYSCALL_ABI_COMPAT: bitmap = filter->sc_compat_exit; break; + default: + return -EINVAL; } break; default: @@ -1113,7 +1136,6 @@ int lttng_syscall_filter_disable(struct lttng_channel *chan, if (syscall_nr < 0) return -ENOENT; - switch (event->u.syscall.entryexit) { case LTTNG_SYSCALL_ENTRY: switch (event->u.syscall.abi) { @@ -1123,6 +1145,8 @@ int lttng_syscall_filter_disable(struct lttng_channel *chan, case LTTNG_SYSCALL_ABI_COMPAT: bitmap = filter->sc_compat_entry; break; + default: + return -EINVAL; } break; case LTTNG_SYSCALL_EXIT: @@ -1133,6 +1157,8 @@ int lttng_syscall_filter_disable(struct lttng_channel *chan, case LTTNG_SYSCALL_ABI_COMPAT: bitmap = filter->sc_compat_exit; break; + default: + return -EINVAL; } break; default: