DECLARE_BITMAP(sc_compat_exit, NR_compat_syscalls);
};
-static
-int lttng_syscalls_create_matching_event_notifiers(struct lttng_event_enabler_common *event_enabler);
-
static void syscall_entry_event_unknown(struct hlist_head *unknown_action_list_head,
struct pt_regs *regs, long id)
{
if (!event_recorder_enabler)
return;
event = _lttng_kernel_event_create(&event_recorder_enabler->parent, desc);
- WARN_ON_ONCE(!event || IS_ERR(event));
+ WARN_ON_ONCE(IS_ERR(event));
lttng_event_enabler_destroy(&event_recorder_enabler->parent);
- if (!event || IS_ERR(event)) {
+ if (IS_ERR(event)) {
printk(KERN_INFO "Unable to create event recorder %s\n", desc->event_name);
return;
}
+ event->priv->u.syscall.syscall_id = syscall_nr;
if (dispatch_table)
- hlist_add_head_rcu(&event->priv->u.syscall.node, &dispatch_table[syscall_nr]);
+ hlist_add_head_rcu(&event->priv->u.syscall.node, dispatch_table);
break;
}
case LTTNG_EVENT_ENABLER_TYPE_NOTIFIER:
&event_notifier_param, syscall_event_notifier_enabler->group);
WARN_ON_ONCE(!event_notifier_enabler);
event = _lttng_kernel_event_create(&event_notifier_enabler->parent, desc);
- WARN_ON_ONCE(!event || IS_ERR(event));
+ WARN_ON_ONCE(IS_ERR(event));
lttng_event_enabler_destroy(&event_notifier_enabler->parent);
- if (!event || IS_ERR(event)) {
+ if (IS_ERR(event)) {
printk(KERN_INFO "Unable to create event notifier %s\n", desc->event_name);
return;
}
}
static
-void lttng_syscall_event_enabler_create_matching_events(struct lttng_event_enabler_common *syscall_event_enabler_common,
- const struct trace_syscall_entry *table,
- size_t table_len,
- struct hlist_head *dispatch_table,
- enum sc_type type)
+void lttng_syscall_event_enabler_create_matching_syscall_table_events(struct lttng_event_enabler_common *syscall_event_enabler_common,
+ const struct trace_syscall_entry *table, size_t table_len, enum sc_type type)
{
struct lttng_event_ht *events_ht = lttng_get_event_ht_from_enabler(syscall_event_enabler_common);
const struct lttng_kernel_event_desc *desc;
unsigned int i;
- /* iterate over all syscall and create event_notifier that match */
+ if (!IS_ENABLED(CONFIG_COMPAT) && (type == SC_TYPE_COMPAT_ENTRY || type == SC_TYPE_COMPAT_EXIT))
+ return;
+
+ /* iterate over all syscall and create event that match */
for (i = 0; i < table_len; i++) {
struct lttng_kernel_event_common_private *event_priv;
struct hlist_head *head;
if (found)
continue;
- lttng_syscall_event_enabler_create_event(syscall_event_enabler_common, desc, dispatch_table, type, i);
+ lttng_syscall_event_enabler_create_event(syscall_event_enabler_common, desc, NULL, type, i);
}
}
+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)
{
bool found = false;
struct hlist_head *head;
+ if (!IS_ENABLED(CONFIG_COMPAT) && (type == SC_TYPE_COMPAT_ENTRY || type == SC_TYPE_COMPAT_EXIT))
+ return;
+
+ /*
+ * 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;
}
static
-int lttng_syscalls_populate_events(struct lttng_event_enabler_common *syscall_event_enabler)
+void lttng_syscall_event_enabler_create_matching_events(struct lttng_event_enabler_common *event_enabler)
{
- struct lttng_kernel_syscall_table *syscall_table = get_syscall_table_from_enabler(syscall_event_enabler);
- struct lttng_event_recorder_enabler *event_recorder_enabler;
- struct lttng_kernel_channel_buffer *chan;
- int ret;
+ enum lttng_kernel_abi_syscall_entryexit entryexit = event_enabler->event_param.u.syscall.entryexit;
- if (syscall_event_enabler->enabler_type != LTTNG_EVENT_ENABLER_TYPE_RECORDER)
- return 0;
- event_recorder_enabler = container_of(syscall_event_enabler, struct lttng_event_recorder_enabler, parent);
- chan = event_recorder_enabler->chan;
-
- lttng_syscall_event_enabler_create_matching_events(&event_recorder_enabler->parent, sc_table.table, sc_table.len,
- syscall_table->syscall_dispatch, SC_TYPE_ENTRY);
- lttng_syscall_event_enabler_create_matching_events(&event_recorder_enabler->parent, sc_exit_table.table, sc_exit_table.len,
- syscall_table->syscall_exit_dispatch, SC_TYPE_EXIT);
- create_unknown_syscall_event(syscall_event_enabler, SC_TYPE_ENTRY);
- create_unknown_syscall_event(syscall_event_enabler, SC_TYPE_EXIT);
+ if (entryexit == LTTNG_KERNEL_ABI_SYSCALL_ENTRY || entryexit == LTTNG_KERNEL_ABI_SYSCALL_ENTRYEXIT) {
+ lttng_syscall_event_enabler_create_matching_syscall_table_events(event_enabler,
+ sc_table.table, sc_table.len, SC_TYPE_ENTRY);
+ lttng_syscall_event_enabler_create_matching_syscall_table_events(event_enabler,
+ compat_sc_table.table, compat_sc_table.len, SC_TYPE_COMPAT_ENTRY);
+ create_unknown_syscall_event(event_enabler, SC_TYPE_ENTRY);
+ create_unknown_syscall_event(event_enabler, SC_TYPE_COMPAT_ENTRY);
+ }
-#ifdef CONFIG_COMPAT
- lttng_syscall_event_enabler_create_matching_events(&event_recorder_enabler->parent, compat_sc_table.table, compat_sc_table.len,
- syscall_table->compat_syscall_dispatch, SC_TYPE_COMPAT_ENTRY);
- lttng_syscall_event_enabler_create_matching_events(&event_recorder_enabler->parent, compat_sc_exit_table.table, compat_sc_exit_table.len,
- syscall_table->compat_syscall_exit_dispatch, SC_TYPE_COMPAT_EXIT);
- create_unknown_syscall_event(syscall_event_enabler, SC_TYPE_COMPAT_ENTRY);
- create_unknown_syscall_event(syscall_event_enabler, SC_TYPE_COMPAT_EXIT);
-#endif
- return ret;
+ if (entryexit == LTTNG_KERNEL_ABI_SYSCALL_EXIT || entryexit == LTTNG_KERNEL_ABI_SYSCALL_ENTRYEXIT) {
+ lttng_syscall_event_enabler_create_matching_syscall_table_events(event_enabler,
+ sc_exit_table.table, sc_exit_table.len, SC_TYPE_EXIT);
+ lttng_syscall_event_enabler_create_matching_syscall_table_events(event_enabler,
+ compat_sc_exit_table.table, compat_sc_exit_table.len, SC_TYPE_COMPAT_EXIT);
+ create_unknown_syscall_event(event_enabler, SC_TYPE_EXIT);
+ create_unknown_syscall_event(event_enabler, SC_TYPE_COMPAT_EXIT);
+ }
}
/*
return -ENOMEM;
}
-
#ifdef CONFIG_COMPAT
if (!syscall_table->compat_syscall_dispatch) {
/* create syscall table mapping compat syscall to events */
return -ENOMEM;
}
- ret = lttng_syscalls_populate_events(syscall_event_enabler);
- if (ret)
- return ret;
-
- ret = lttng_syscalls_create_matching_event_notifiers(syscall_event_enabler);
- if (ret)
- return ret;
-
if (!syscall_table->sys_enter_registered) {
ret = lttng_wrapper_tracepoint_probe_register("sys_enter",
(void *) syscall_entry_event_probe, syscall_table);
syscall_table->sys_exit_registered = 1;
}
- return ret;
-}
-
-static
-int lttng_syscalls_create_matching_event_notifiers(struct lttng_event_enabler_common *event_enabler)
-{
- int ret;
- enum lttng_kernel_abi_syscall_entryexit entryexit =
- event_enabler->event_param.u.syscall.entryexit;
- struct lttng_event_notifier_enabler *event_notifier_enabler;
-
- if (event_enabler->enabler_type != LTTNG_EVENT_ENABLER_TYPE_NOTIFIER)
- return 0;
- event_notifier_enabler = container_of(event_enabler, struct lttng_event_notifier_enabler, parent);
+ lttng_syscall_event_enabler_create_matching_events(syscall_event_enabler);
- if (entryexit == LTTNG_KERNEL_ABI_SYSCALL_ENTRY || entryexit == LTTNG_KERNEL_ABI_SYSCALL_ENTRYEXIT) {
- lttng_syscall_event_enabler_create_matching_events(&event_notifier_enabler->parent,
- sc_table.table, sc_table.len, NULL, SC_TYPE_ENTRY);
- lttng_syscall_event_enabler_create_matching_events(&event_notifier_enabler->parent,
- compat_sc_table.table, compat_sc_table.len, NULL, SC_TYPE_COMPAT_ENTRY);
- create_unknown_syscall_event(event_enabler, SC_TYPE_ENTRY);
- create_unknown_syscall_event(event_enabler, SC_TYPE_COMPAT_ENTRY);
- }
-
- if (entryexit == LTTNG_KERNEL_ABI_SYSCALL_EXIT || entryexit == LTTNG_KERNEL_ABI_SYSCALL_ENTRYEXIT) {
- lttng_syscall_event_enabler_create_matching_events(&event_notifier_enabler->parent,
- sc_exit_table.table, sc_exit_table.len, NULL, SC_TYPE_EXIT);
- lttng_syscall_event_enabler_create_matching_events(&event_notifier_enabler->parent,
- compat_sc_exit_table.table, compat_sc_exit_table.len, NULL, SC_TYPE_COMPAT_EXIT);
- create_unknown_syscall_event(event_enabler, SC_TYPE_EXIT);
- create_unknown_syscall_event(event_enabler, SC_TYPE_COMPAT_EXIT);
- }
return ret;
}
int lttng_syscall_filter_enable_event(struct lttng_kernel_event_common *event)
{
struct lttng_kernel_syscall_table *syscall_table = get_syscall_table_from_event(event);
+ unsigned int syscall_id = event->priv->u.syscall.syscall_id;
+ struct hlist_head *dispatch_list;
int ret;
WARN_ON_ONCE(event->priv->instrumentation != LTTNG_KERNEL_ABI_SYSCALL);
if (ret)
return ret;
- switch (event->type) {
- case LTTNG_KERNEL_EVENT_TYPE_RECORDER:
+ switch (event->priv->u.syscall.entryexit) {
+ case LTTNG_SYSCALL_ENTRY:
+ switch (event->priv->u.syscall.abi) {
+ case LTTNG_SYSCALL_ABI_NATIVE:
+ dispatch_list = &syscall_table->syscall_dispatch[syscall_id];
+ break;
+ case LTTNG_SYSCALL_ABI_COMPAT:
+ dispatch_list = &syscall_table->compat_syscall_dispatch[syscall_id];
+ break;
+ default:
+ ret = -EINVAL;
+ goto end;
+ }
break;
- case LTTNG_KERNEL_EVENT_TYPE_NOTIFIER:
- {
- unsigned int syscall_id = event->priv->u.syscall.syscall_id;
- struct hlist_head *dispatch_list;
-
- switch (event->priv->u.syscall.entryexit) {
- case LTTNG_SYSCALL_ENTRY:
- switch (event->priv->u.syscall.abi) {
- case LTTNG_SYSCALL_ABI_NATIVE:
- dispatch_list = &syscall_table->syscall_dispatch[syscall_id];
- break;
- case LTTNG_SYSCALL_ABI_COMPAT:
- dispatch_list = &syscall_table->compat_syscall_dispatch[syscall_id];
- break;
- default:
- ret = -EINVAL;
- goto end;
- }
+ case LTTNG_SYSCALL_EXIT:
+ switch (event->priv->u.syscall.abi) {
+ case LTTNG_SYSCALL_ABI_NATIVE:
+ dispatch_list = &syscall_table->syscall_exit_dispatch[syscall_id];
break;
- case LTTNG_SYSCALL_EXIT:
- switch (event->priv->u.syscall.abi) {
- case LTTNG_SYSCALL_ABI_NATIVE:
- dispatch_list = &syscall_table->syscall_exit_dispatch[syscall_id];
- break;
- case LTTNG_SYSCALL_ABI_COMPAT:
- dispatch_list = &syscall_table->compat_syscall_exit_dispatch[syscall_id];
- break;
- default:
- ret = -EINVAL;
- goto end;
- }
+ case LTTNG_SYSCALL_ABI_COMPAT:
+ dispatch_list = &syscall_table->compat_syscall_exit_dispatch[syscall_id];
break;
default:
ret = -EINVAL;
goto end;
}
-
- hlist_add_head_rcu(&event->priv->u.syscall.node, dispatch_list);
break;
- }
default:
- WARN_ON_ONCE(1);
- return -ENOSYS;
+ ret = -EINVAL;
+ goto end;
}
+
+ hlist_add_head_rcu(&event->priv->u.syscall.node, dispatch_list);
end:
return ret;
}
event->priv->u.syscall.entryexit);
if (ret)
return ret;
-
- switch (event->type) {
- case LTTNG_KERNEL_EVENT_TYPE_RECORDER:
- break;
- case LTTNG_KERNEL_EVENT_TYPE_NOTIFIER:
- {
- hlist_del_rcu(&event->priv->u.syscall.node);
- break;
- }
- default:
- WARN_ON_ONCE(1);
- return -ENOSYS;
- }
+ hlist_del_rcu(&event->priv->u.syscall.node);
return 0;
}
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)
- return;
- if (event_enabler->event_param.u.syscall.match != LTTNG_KERNEL_ABI_SYSCALL_MATCH_NAME)
+ if (!lttng_syscall_event_enabler_is_wildcard_all(event_enabler))
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);