Sync `show_inode_state()` macro with Ubuntu 4.15 kernel
[lttng-modules.git] / lttng-abi.c
index 64ea99da27fc6e126358f223f25972d74bac301f..18f5123c1f7772de392726f20f5397a6c5511794 100644 (file)
@@ -52,7 +52,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;
@@ -398,7 +398,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
@@ -1264,6 +1264,46 @@ nomem:
        return ret;
 }
 
+static
+int lttng_abi_validate_event_param(struct lttng_kernel_event *event_param)
+{
+       /* Limit ABI to implemented features. */
+       switch (event_param->instrumentation) {
+       case LTTNG_KERNEL_SYSCALL:
+               switch (event_param->u.syscall.entryexit) {
+               case LTTNG_KERNEL_SYSCALL_ENTRYEXIT:
+                       break;
+               default:
+                       return -EINVAL;
+               }
+               switch (event_param->u.syscall.abi) {
+               case LTTNG_KERNEL_SYSCALL_ABI_ALL:
+                       break;
+               default:
+                       return -EINVAL;
+               }
+               switch (event_param->u.syscall.match) {
+               case LTTNG_SYSCALL_MATCH_NAME:
+                       break;
+               default:
+                       return -EINVAL;
+               }
+               break;
+
+       case LTTNG_KERNEL_TRACEPOINT:   /* Fallthrough */
+       case LTTNG_KERNEL_KPROBE:       /* Fallthrough */
+       case LTTNG_KERNEL_KRETPROBE:    /* Fallthrough */
+       case LTTNG_KERNEL_NOOP:         /* Fallthrough */
+       case LTTNG_KERNEL_UPROBE:
+               break;
+
+       case LTTNG_KERNEL_FUNCTION:     /* Fallthrough */
+       default:
+               return -EINVAL;
+       }
+       return 0;
+}
+
 static
 int lttng_abi_create_event(struct file *channel_file,
                           struct lttng_kernel_event *event_param)
@@ -1305,6 +1345,9 @@ int lttng_abi_create_event(struct file *channel_file,
                ret = -EOVERFLOW;
                goto refcount_error;
        }
+       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) {
                struct lttng_enabler *enabler;
This page took 0.023385 seconds and 4 git commands to generate.