X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Flttng-abi.c;h=13d737d95679a57636d26f7b6e5c7bf2efa043b3;hb=437d5aa59380583ce1cd14d394a53b398be1275d;hp=7096daf7a544358202e14f49ae210d13397c48b2;hpb=6657edecc8dd4f294c42339645151006f60b3811;p=lttng-modules.git diff --git a/src/lttng-abi.c b/src/lttng-abi.c index 7096daf7..13d737d9 100644 --- a/src/lttng-abi.c +++ b/src/lttng-abi.c @@ -42,6 +42,7 @@ #include #include #include +#include #include #include #include @@ -54,7 +55,7 @@ static struct proc_dir_entry *lttng_proc_dentry; -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,6,0)) +#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,6,0)) static const struct proc_ops lttng_proc_ops; #else static const struct file_operations lttng_proc_ops; @@ -257,7 +258,7 @@ void lttng_abi_tracer_abi_version(struct lttng_kernel_tracer_abi_version *v) static long lttng_abi_add_context(struct file *file, struct lttng_kernel_context *context_param, - struct lttng_ctx **ctx, struct lttng_session *session) + struct lttng_kernel_ctx **ctx, struct lttng_session *session) { if (session->been_active) @@ -464,7 +465,7 @@ long lttng_ioctl(struct file *file, unsigned int cmd, unsigned long arg) } } -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,6,0)) +#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,6,0)) static const struct proc_ops lttng_proc_ops = { .proc_ioctl = lttng_ioctl, #ifdef CONFIG_COMPAT @@ -1725,8 +1726,8 @@ int lttng_abi_validate_event_param(struct lttng_kernel_event *event_param) switch (event_param->instrumentation) { case LTTNG_KERNEL_SYSCALL: switch (event_param->u.syscall.entryexit) { - case LTTNG_KERNEL_SYSCALL_ENTRY: - case LTTNG_KERNEL_SYSCALL_EXIT: + case LTTNG_KERNEL_SYSCALL_ENTRY: /* Fall-through */ + case LTTNG_KERNEL_SYSCALL_EXIT: /* Fall-through */ case LTTNG_KERNEL_SYSCALL_ENTRYEXIT: break; default: @@ -1746,14 +1747,24 @@ int lttng_abi_validate_event_param(struct lttng_kernel_event *event_param) } break; - case LTTNG_KERNEL_TRACEPOINT: /* Fallthrough */ - case LTTNG_KERNEL_KPROBE: /* Fallthrough */ - case LTTNG_KERNEL_KRETPROBE: /* Fallthrough */ - case LTTNG_KERNEL_NOOP: /* Fallthrough */ + case LTTNG_KERNEL_KRETPROBE: + switch (event_param->u.kretprobe.entryexit) { + case LTTNG_KERNEL_SYSCALL_ENTRYEXIT: + break; + case LTTNG_KERNEL_SYSCALL_ENTRY: /* Fall-through */ + case LTTNG_KERNEL_SYSCALL_EXIT: /* Fall-through */ + default: + return -EINVAL; + } + break; + + case LTTNG_KERNEL_TRACEPOINT: /* Fall-through */ + case LTTNG_KERNEL_KPROBE: /* Fall-through */ case LTTNG_KERNEL_UPROBE: break; - case LTTNG_KERNEL_FUNCTION: /* Fallthrough */ + case LTTNG_KERNEL_FUNCTION: /* Fall-through */ + case LTTNG_KERNEL_NOOP: /* Fall-through */ default: return -EINVAL; } @@ -1804,8 +1815,11 @@ int lttng_abi_create_event(struct file *channel_file, ret = lttng_abi_validate_event_param(event_param); if (ret) goto event_error; - if (event_param->instrumentation == LTTNG_KERNEL_TRACEPOINT - || event_param->instrumentation == LTTNG_KERNEL_SYSCALL) { + + switch (event_param->instrumentation) { + case LTTNG_KERNEL_TRACEPOINT: /* Fall-through */ + case LTTNG_KERNEL_SYSCALL: + { struct lttng_event_enabler *event_enabler; if (strutils_is_star_glob_pattern(event_param->name)) { @@ -1820,7 +1834,13 @@ int lttng_abi_create_event(struct file *channel_file, event_param, channel); } priv = event_enabler; - } else { + break; + } + + case LTTNG_KERNEL_KPROBE: /* Fall-through */ + case LTTNG_KERNEL_KRETPROBE: /* Fall-through */ + case LTTNG_KERNEL_UPROBE: + { struct lttng_event *event; /* @@ -1836,6 +1856,14 @@ int lttng_abi_create_event(struct file *channel_file, goto event_error; } priv = event; + break; + } + + case LTTNG_KERNEL_FUNCTION: /* Fall-through */ + case LTTNG_KERNEL_NOOP: /* Fall-through */ + default: + ret = -EINVAL; + goto event_error; } event_file->private_data = priv; fd_install(event_fd, event_file); @@ -2015,8 +2043,14 @@ int lttng_abi_create_event_notifier(struct file *event_notifier_group_file, goto refcount_error; } - if (event_notifier_param->event.instrumentation == LTTNG_KERNEL_TRACEPOINT - || event_notifier_param->event.instrumentation == LTTNG_KERNEL_SYSCALL) { + ret = lttng_abi_validate_event_param(&event_notifier_param->event); + if (ret) + goto event_notifier_error; + + switch (event_notifier_param->event.instrumentation) { + case LTTNG_KERNEL_TRACEPOINT: /* Fall-through */ + case LTTNG_KERNEL_SYSCALL: + { struct lttng_event_notifier_enabler *enabler; if (strutils_is_star_glob_pattern(event_notifier_param->event.name)) { @@ -2035,7 +2069,13 @@ int lttng_abi_create_event_notifier(struct file *event_notifier_group_file, event_notifier_param); } priv = enabler; - } else { + break; + } + + case LTTNG_KERNEL_KPROBE: /* Fall-through */ + case LTTNG_KERNEL_KRETPROBE: /* Fall-through */ + case LTTNG_KERNEL_UPROBE: + { struct lttng_event_notifier *event_notifier; /* @@ -2054,6 +2094,14 @@ int lttng_abi_create_event_notifier(struct file *event_notifier_group_file, goto event_notifier_error; } priv = event_notifier; + break; + } + + case LTTNG_KERNEL_FUNCTION: /* Fall-through */ + case LTTNG_KERNEL_NOOP: /* Fall-through */ + default: + ret = -EINVAL; + goto event_notifier_error; } event_notifier_file->private_data = priv; fd_install(event_notifier_fd, event_notifier_file);