Fix: event notifier unknown syscall match only wildcard all
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 5 Nov 2021 18:32:54 +0000 (14:32 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 5 Nov 2021 18:32:54 +0000 (14:32 -0400)
The unknown system call event should only be generated when matching a
wildcard *all*, otherwise when matching a system call by name we don't
expect to emit a notification for an unknown system call.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ia5b99ac3b15849859519b9484e400ce0de95faeb

src/lttng-syscalls.c

index 9481d4ff8a4b21808d01c790075af6a16f5fa009..af81267138c2b27569bac38ea7c7a14376b72545 100644 (file)
@@ -677,6 +677,20 @@ void lttng_syscall_event_enabler_create_matching_events(struct lttng_event_enabl
        }
 }
 
+static
+bool lttng_syscall_event_enabler_is_wildcard_all(struct lttng_event_enabler_common *event_enabler)
+{
+       if (event_enabler->event_param.instrumentation != LTTNG_KERNEL_ABI_SYSCALL)
+               return false;
+       if (event_enabler->event_param.u.syscall.abi != LTTNG_KERNEL_ABI_SYSCALL_ABI_ALL)
+               return false;
+       if (event_enabler->event_param.u.syscall.match != LTTNG_KERNEL_ABI_SYSCALL_MATCH_NAME)
+               return false;
+       if (strcmp(event_enabler->event_param.name, "*"))
+               return false;
+       return true;
+}
+
 static
 void create_unknown_syscall_event(struct lttng_event_enabler_common *event_enabler, enum sc_type type)
 {
@@ -688,6 +702,18 @@ void create_unknown_syscall_event(struct lttng_event_enabler_common *event_enabl
        bool found = false;
        struct hlist_head *head;
 
+       /*
+        * Considering that currently system calls can only be enabled on a per
+        * name basis (or wildcard based on a name), unknown syscall events are
+        * only used when matching *all* system calls, because this is the only
+        * case which can be associated with an unknown system call.
+        *
+        * When enabling system call on a per system call number basis will be
+        * supported, this will need to be revisited.
+        */
+       if (!lttng_syscall_event_enabler_is_wildcard_all(event_enabler))
+               return;
+
        switch (type) {
        case SC_TYPE_ENTRY:
                desc = &__event_desc___syscall_entry_unknown;
@@ -1192,15 +1218,8 @@ void lttng_syscall_table_set_wildcard_all(struct lttng_event_enabler_common *eve
        enum lttng_kernel_abi_syscall_entryexit entryexit;
        int enabled = event_enabler->enabled;
 
-       if (event_enabler->event_param.instrumentation != LTTNG_KERNEL_ABI_SYSCALL)
-               return;
-       if (event_enabler->event_param.u.syscall.abi != LTTNG_KERNEL_ABI_SYSCALL_ABI_ALL)
+       if (!lttng_syscall_event_enabler_is_wildcard_all(event_enabler))
                return;
-       if (event_enabler->event_param.u.syscall.match != LTTNG_KERNEL_ABI_SYSCALL_MATCH_NAME)
-               return;
-       if (strcmp(event_enabler->event_param.name, "*"))
-               return;
-
        entryexit = event_enabler->event_param.u.syscall.entryexit;
        if (entryexit == LTTNG_KERNEL_ABI_SYSCALL_ENTRY || entryexit == LTTNG_KERNEL_ABI_SYSCALL_ENTRYEXIT)
                WRITE_ONCE(syscall_table->syscall_all_entry, enabled);
This page took 0.02718 seconds and 4 git commands to generate.