#include <wrapper/rcu.h>
#include <wrapper/syscall.h>
#include <lttng/events.h>
+#include <lttng/events-internal.h>
#include <lttng/utils.h>
+#include "lttng-syscalls.h"
+
#ifndef CONFIG_COMPAT
# ifndef is_compat_task
# define is_compat_task() (0)
#define SYSCALL_EXIT_STR __stringify(SYSCALL_EXIT_TOK)
#define COMPAT_SYSCALL_EXIT_STR __stringify(COMPAT_SYSCALL_EXIT_TOK)
-static
void syscall_entry_event_probe(void *__data, struct pt_regs *regs, long id);
-static
void syscall_exit_event_probe(void *__data, struct pt_regs *regs, long ret);
-static
-void syscall_entry_event_notifier_probe(void *__data, struct pt_regs *regs,
- long id);
-static
-void syscall_exit_event_notifier_probe(void *__data, struct pt_regs *regs,
- long ret);
-
/*
* Forward declarations for old kernels.
*/
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
#include <instrumentation/syscalls/headers/syscalls_unknown.h>
#undef TRACE_SYSTEM
-#define SC_ENTER
-
-#undef sc_exit
-#define sc_exit(...)
-#undef sc_in
-#define sc_in(...) __VA_ARGS__
-#undef sc_out
-#define sc_out(...)
-#undef sc_inout
-#define sc_inout(...) __VA_ARGS__
-
-/* Hijack probe callback for system call enter */
-#undef TP_PROBE_CB
-#define TP_PROBE_CB(_template) &syscall_entry_event_probe
-#define SC_LTTNG_TRACEPOINT_EVENT(_name, _proto, _args, _fields) \
- LTTNG_TRACEPOINT_EVENT(syscall_entry_##_name, PARAMS(_proto), PARAMS(_args), \
- PARAMS(_fields))
-#define SC_LTTNG_TRACEPOINT_EVENT_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
- LTTNG_TRACEPOINT_EVENT_CODE(syscall_entry_##_name, PARAMS(_proto), PARAMS(_args), \
- PARAMS(_locvar), PARAMS(_code_pre), \
- PARAMS(_fields), PARAMS(_code_post))
-#define SC_LTTNG_TRACEPOINT_EVENT_CLASS_NOARGS(_name, _fields) \
- LTTNG_TRACEPOINT_EVENT_CLASS_NOARGS(syscall_entry_##_name, PARAMS(_fields))
-#define SC_LTTNG_TRACEPOINT_EVENT_INSTANCE_NOARGS(_template, _name) \
- LTTNG_TRACEPOINT_EVENT_INSTANCE_NOARGS(syscall_entry_##_template, syscall_entry_##_name)
-/* Enumerations only defined at first inclusion. */
-#define SC_LTTNG_TRACEPOINT_ENUM(_name, _values) \
- LTTNG_TRACEPOINT_ENUM(_name, PARAMS(_values))
-#undef TRACE_SYSTEM
-#define TRACE_SYSTEM syscall_entry_integers
-#define TRACE_INCLUDE_FILE syscalls_integers
-#include <instrumentation/syscalls/headers/syscalls_integers.h>
-#undef TRACE_INCLUDE_FILE
-#undef TRACE_SYSTEM
-#define TRACE_SYSTEM syscall_entry_pointers
-#define TRACE_INCLUDE_FILE syscalls_pointers
-#include <instrumentation/syscalls/headers/syscalls_pointers.h>
-#undef TRACE_INCLUDE_FILE
-#undef TRACE_SYSTEM
-#undef SC_LTTNG_TRACEPOINT_ENUM
-#undef SC_LTTNG_TRACEPOINT_EVENT_CODE
-#undef SC_LTTNG_TRACEPOINT_EVENT
-#undef SC_LTTNG_TRACEPOINT_EVENT_CLASS_NOARGS
-#undef SC_LTTNG_TRACEPOINT_EVENT_INSTANCE_NOARGS
-#undef TP_PROBE_CB
-#undef _TRACE_SYSCALLS_INTEGERS_H
-#undef _TRACE_SYSCALLS_POINTERS_H
-
-/* Hijack probe callback for compat system call enter */
-#define TP_PROBE_CB(_template) &syscall_entry_event_probe
-#define LTTNG_SC_COMPAT
-#define SC_LTTNG_TRACEPOINT_EVENT(_name, _proto, _args, _fields) \
- LTTNG_TRACEPOINT_EVENT(compat_syscall_entry_##_name, PARAMS(_proto), PARAMS(_args), \
- PARAMS(_fields))
-#define SC_LTTNG_TRACEPOINT_EVENT_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
- LTTNG_TRACEPOINT_EVENT_CODE(compat_syscall_entry_##_name, PARAMS(_proto), PARAMS(_args), \
- PARAMS(_locvar), PARAMS(_code_pre), PARAMS(_fields), PARAMS(_code_post))
-#define SC_LTTNG_TRACEPOINT_EVENT_CLASS_NOARGS(_name, _fields) \
- LTTNG_TRACEPOINT_EVENT_CLASS_NOARGS(compat_syscall_entry_##_name, PARAMS(_fields))
-#define SC_LTTNG_TRACEPOINT_EVENT_INSTANCE_NOARGS(_template, _name) \
- LTTNG_TRACEPOINT_EVENT_INSTANCE_NOARGS(compat_syscall_entry_##_template, \
- compat_syscall_entry_##_name)
-/* Enumerations only defined at inital inclusion (not here). */
-#define SC_LTTNG_TRACEPOINT_ENUM(_name, _values)
-#define TRACE_SYSTEM compat_syscall_entry_integers
-#define TRACE_INCLUDE_FILE compat_syscalls_integers
-#include <instrumentation/syscalls/headers/compat_syscalls_integers.h>
-#undef TRACE_INCLUDE_FILE
-#undef TRACE_SYSTEM
-#define TRACE_SYSTEM compat_syscall_entry_pointers
-#define TRACE_INCLUDE_FILE compat_syscalls_pointers
-#include <instrumentation/syscalls/headers/compat_syscalls_pointers.h>
-#undef TRACE_INCLUDE_FILE
-#undef TRACE_SYSTEM
-#undef SC_LTTNG_TRACEPOINT_ENUM
-#undef SC_LTTNG_TRACEPOINT_EVENT_CODE
-#undef SC_LTTNG_TRACEPOINT_EVENT
-#undef SC_LTTNG_TRACEPOINT_EVENT_CLASS_NOARGS
-#undef SC_LTTNG_TRACEPOINT_EVENT_INSTANCE_NOARGS
-#undef TP_PROBE_CB
-#undef _TRACE_SYSCALLS_INTEGERS_H
-#undef _TRACE_SYSCALLS_POINTERS_H
-#undef LTTNG_SC_COMPAT
-
-#undef SC_ENTER
-
-#define SC_EXIT
-
-#undef sc_exit
-#define sc_exit(...) __VA_ARGS__
-#undef sc_in
-#define sc_in(...)
-#undef sc_out
-#define sc_out(...) __VA_ARGS__
-#undef sc_inout
-#define sc_inout(...) __VA_ARGS__
-
-/* Hijack probe callback for system call exit */
-#define TP_PROBE_CB(_template) &syscall_exit_event_probe
-#define SC_LTTNG_TRACEPOINT_EVENT(_name, _proto, _args, _fields) \
- LTTNG_TRACEPOINT_EVENT(syscall_exit_##_name, PARAMS(_proto), PARAMS(_args), \
- PARAMS(_fields))
-#define SC_LTTNG_TRACEPOINT_EVENT_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
- LTTNG_TRACEPOINT_EVENT_CODE(syscall_exit_##_name, PARAMS(_proto), PARAMS(_args), \
- PARAMS(_locvar), PARAMS(_code_pre), PARAMS(_fields), PARAMS(_code_post))
-#define SC_LTTNG_TRACEPOINT_EVENT_CLASS_NOARGS(_name, _fields) \
- LTTNG_TRACEPOINT_EVENT_CLASS_NOARGS(syscall_exit_##_name, PARAMS(_fields))
-#define SC_LTTNG_TRACEPOINT_EVENT_INSTANCE_NOARGS(_template, _name) \
- LTTNG_TRACEPOINT_EVENT_INSTANCE_NOARGS(syscall_exit_##_template, \
- syscall_exit_##_name)
-/* Enumerations only defined at inital inclusion (not here). */
-#define SC_LTTNG_TRACEPOINT_ENUM(_name, _values)
-#define TRACE_SYSTEM syscall_exit_integers
-#define TRACE_INCLUDE_FILE syscalls_integers
-#include <instrumentation/syscalls/headers/syscalls_integers.h>
-#undef TRACE_INCLUDE_FILE
-#undef TRACE_SYSTEM
-#define TRACE_SYSTEM syscall_exit_pointers
-#define TRACE_INCLUDE_FILE syscalls_pointers
-#include <instrumentation/syscalls/headers/syscalls_pointers.h>
-#undef TRACE_INCLUDE_FILE
-#undef TRACE_SYSTEM
-#undef SC_LTTNG_TRACEPOINT_ENUM
-#undef SC_LTTNG_TRACEPOINT_EVENT_CODE
-#undef SC_LTTNG_TRACEPOINT_EVENT
-#undef SC_LTTNG_TRACEPOINT_EVENT_CLASS_NOARGS
-#undef SC_LTTNG_TRACEPOINT_EVENT_INSTANCE_NOARGS
-#undef TP_PROBE_CB
-#undef _TRACE_SYSCALLS_INTEGERS_H
-#undef _TRACE_SYSCALLS_POINTERS_H
-
-
-/* Hijack probe callback for compat system call exit */
-#define TP_PROBE_CB(_template) &syscall_exit_event_probe
-#define LTTNG_SC_COMPAT
-#define SC_LTTNG_TRACEPOINT_EVENT(_name, _proto, _args, _fields) \
- LTTNG_TRACEPOINT_EVENT(compat_syscall_exit_##_name, PARAMS(_proto), PARAMS(_args), \
- PARAMS(_fields))
-#define SC_LTTNG_TRACEPOINT_EVENT_CODE(_name, _proto, _args, _locvar, _code_pre, _fields, _code_post) \
- LTTNG_TRACEPOINT_EVENT_CODE(compat_syscall_exit_##_name, PARAMS(_proto), PARAMS(_args), \
- PARAMS(_locvar), PARAMS(_code_pre), PARAMS(_fields), PARAMS(_code_post))
-#define SC_LTTNG_TRACEPOINT_EVENT_CLASS_NOARGS(_name, _fields) \
- LTTNG_TRACEPOINT_EVENT_CLASS_NOARGS(compat_syscall_exit_##_name, PARAMS(_fields))
-#define SC_LTTNG_TRACEPOINT_EVENT_INSTANCE_NOARGS(_template, _name) \
- LTTNG_TRACEPOINT_EVENT_INSTANCE_NOARGS(compat_syscall_exit_##_template, \
- compat_syscall_exit_##_name)
-/* Enumerations only defined at inital inclusion (not here). */
-#define SC_LTTNG_TRACEPOINT_ENUM(_name, _values)
-#define TRACE_SYSTEM compat_syscall_exit_integers
-#define TRACE_INCLUDE_FILE compat_syscalls_integers
-#include <instrumentation/syscalls/headers/compat_syscalls_integers.h>
-#undef TRACE_INCLUDE_FILE
-#undef TRACE_SYSTEM
-#define TRACE_SYSTEM compat_syscall_exit_pointers
-#define TRACE_INCLUDE_FILE compat_syscalls_pointers
-#include <instrumentation/syscalls/headers/compat_syscalls_pointers.h>
-#undef TRACE_INCLUDE_FILE
-#undef TRACE_SYSTEM
-#undef SC_LTTNG_TRACEPOINT_ENUM
-#undef SC_LTTNG_TRACEPOINT_EVENT_CODE
-#undef SC_LTTNG_TRACEPOINT_EVENT
-#undef SC_LTTNG_TRACEPOINT_EVENT_CLASS_NOARGS
-#undef SC_LTTNG_TRACEPOINT_EVENT_INSTANCE_NOARGS
#undef TP_PROBE_CB
-#undef _TRACE_SYSCALLS_INTEGERS_H
-#undef _TRACE_SYSCALLS_POINTERS_H
-#undef LTTNG_SC_COMPAT
-
-#undef SC_EXIT
-
-#undef TP_MODULE_NOINIT
-#undef LTTNG_PACKAGE_BUILD
-#undef CREATE_TRACE_POINTS
-
-struct trace_syscall_entry {
- void *event_func;
- void *event_notifier_func;
- const struct lttng_event_desc *desc;
- const struct lttng_event_field *fields;
- unsigned int nrargs;
-};
-
-#define CREATE_SYSCALL_TABLE
-
-#define SC_ENTER
-
-#undef sc_exit
-#define sc_exit(...)
-
-#undef TRACE_SYSCALL_TABLE
-#define TRACE_SYSCALL_TABLE(_template, _name, _nr, _nrargs) \
- [ _nr ] = { \
- .event_func = __event_probe__syscall_entry_##_template, \
- .event_notifier_func = __event_notifier_probe__syscall_entry_##_template, \
- .nrargs = (_nrargs), \
- .fields = __event_fields___syscall_entry_##_template, \
- .desc = &__event_desc___syscall_entry_##_name, \
- },
-
-/* Event syscall enter tracing table */
-static const struct trace_syscall_entry sc_table[] = {
-#include <instrumentation/syscalls/headers/syscalls_integers.h>
-#include <instrumentation/syscalls/headers/syscalls_pointers.h>
-};
-#undef TRACE_SYSCALL_TABLE
-#define TRACE_SYSCALL_TABLE(_template, _name, _nr, _nrargs) \
- [ _nr ] = { \
- .event_func = __event_probe__compat_syscall_entry_##_template, \
- .event_notifier_func = __event_notifier_probe__compat_syscall_entry_##_template, \
- .nrargs = (_nrargs), \
- .fields = __event_fields___compat_syscall_entry_##_template, \
- .desc = &__event_desc___compat_syscall_entry_##_name, \
- },
-
-/* Event compat syscall enter table */
-const struct trace_syscall_entry compat_sc_table[] = {
-#include <instrumentation/syscalls/headers/compat_syscalls_integers.h>
-#include <instrumentation/syscalls/headers/compat_syscalls_pointers.h>
-};
-
-#undef SC_ENTER
-
-#define SC_EXIT
-
-#undef sc_exit
-#define sc_exit(...) __VA_ARGS__
-
-#undef TRACE_SYSCALL_TABLE
-#define TRACE_SYSCALL_TABLE(_template, _name, _nr, _nrargs) \
- [ _nr ] = { \
- .event_func = __event_probe__syscall_exit_##_template, \
- .event_notifier_func = __event_notifier_probe__syscall_exit_##_template, \
- .nrargs = (_nrargs), \
- .fields = __event_fields___syscall_exit_##_template, \
- .desc = &__event_desc___syscall_exit_##_name, \
- },
+extern const struct trace_syscall_table sc_table;
+extern const struct trace_syscall_table compat_sc_table;
/* Event syscall exit table */
-static const struct trace_syscall_entry sc_exit_table[] = {
-#include <instrumentation/syscalls/headers/syscalls_integers.h>
-#include <instrumentation/syscalls/headers/syscalls_pointers.h>
-};
+extern const struct trace_syscall_table sc_exit_table;
+extern const struct trace_syscall_table compat_sc_exit_table;
-#undef TRACE_SYSCALL_TABLE
-#define TRACE_SYSCALL_TABLE(_template, _name, _nr, _nrargs) \
- [ _nr ] = { \
- .event_func = __event_probe__compat_syscall_exit_##_template, \
- .event_notifier_func = __event_notifier_probe__compat_syscall_exit_##_template, \
- .nrargs = (_nrargs), \
- .fields = __event_fields___compat_syscall_exit_##_template, \
- .desc = &__event_desc___compat_syscall_exit_##_name, \
- },
-
-/* Event compat syscall exit table */
-const struct trace_syscall_entry compat_sc_exit_table[] = {
-#include <instrumentation/syscalls/headers/compat_syscalls_integers.h>
-#include <instrumentation/syscalls/headers/compat_syscalls_pointers.h>
-};
#undef SC_EXIT
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)
{
unsigned long args[LTTNG_SYSCALL_NR_ARGS];
- struct lttng_event *event;
-
- lttng_syscall_get_arguments(current, regs, args);
- lttng_hlist_for_each_entry_rcu(event, unknown_action_list_head, u.syscall.node) {
- if (unlikely(in_compat_syscall()))
- __event_probe__compat_syscall_entry_unknown(event, id, args);
- else
- __event_probe__syscall_entry_unknown(event, id, args);
- }
-}
-
-static void syscall_entry_event_notifier_unknown(
- struct hlist_head *unknown_dispatch_list_head,
- struct pt_regs *regs, long id)
-{
- unsigned long args[LTTNG_SYSCALL_NR_ARGS];
- struct lttng_event_notifier *notifier;
-
- lttng_syscall_get_arguments(current, regs, args);
- lttng_hlist_for_each_entry_rcu(notifier, unknown_dispatch_list_head, u.syscall.node) {
- if (unlikely(in_compat_syscall()))
- __event_notifier_probe__compat_syscall_entry_unknown(notifier, id, args);
- else
- __event_notifier_probe__syscall_entry_unknown(notifier, id, args);
- }
-}
-
-static void syscall_exit_event_notifier_unknown(
- struct hlist_head *unknown_dispatch_list_head,
- struct pt_regs *regs, long id, long ret)
-{
- unsigned long args[LTTNG_SYSCALL_NR_ARGS];
- struct lttng_event_notifier *notifier;
+ struct lttng_kernel_event_common_private *event_priv;
lttng_syscall_get_arguments(current, regs, args);
- lttng_hlist_for_each_entry_rcu(notifier, unknown_dispatch_list_head, u.syscall.node) {
+ lttng_hlist_for_each_entry_rcu(event_priv, unknown_action_list_head, u.syscall.node) {
if (unlikely(in_compat_syscall()))
- __event_notifier_probe__compat_syscall_exit_unknown(notifier, id, ret, args);
+ __event_probe__compat_syscall_entry_unknown(event_priv->pub, id, args);
else
- __event_notifier_probe__syscall_exit_unknown(notifier, id, ret, args);
+ __event_probe__syscall_entry_unknown(event_priv->pub, id, args);
}
}
static __always_inline
-void syscall_entry_call_func(struct hlist_head *action_list,
+void syscall_entry_event_call_func(struct hlist_head *action_list,
void *func, unsigned int nrargs,
struct pt_regs *regs)
{
- struct lttng_event *event;
+ struct lttng_kernel_event_common_private *event_priv;
switch (nrargs) {
case 0:
{
void (*fptr)(void *__data) = func;
- lttng_hlist_for_each_entry_rcu(event, action_list, u.syscall.node)
- fptr(event);
+ lttng_hlist_for_each_entry_rcu(event_priv, action_list, u.syscall.node)
+ fptr(event_priv->pub);
break;
}
case 1:
unsigned long args[LTTNG_SYSCALL_NR_ARGS];
lttng_syscall_get_arguments(current, regs, args);
- lttng_hlist_for_each_entry_rcu(event, action_list, u.syscall.node)
- fptr(event, args[0]);
+ lttng_hlist_for_each_entry_rcu(event_priv, action_list, u.syscall.node)
+ fptr(event_priv->pub, args[0]);
break;
}
case 2:
unsigned long args[LTTNG_SYSCALL_NR_ARGS];
lttng_syscall_get_arguments(current, regs, args);
- lttng_hlist_for_each_entry_rcu(event, action_list, u.syscall.node)
- fptr(event, args[0], args[1]);
+ lttng_hlist_for_each_entry_rcu(event_priv, action_list, u.syscall.node)
+ fptr(event_priv->pub, args[0], args[1]);
break;
}
case 3:
unsigned long args[LTTNG_SYSCALL_NR_ARGS];
lttng_syscall_get_arguments(current, regs, args);
- lttng_hlist_for_each_entry_rcu(event, action_list, u.syscall.node)
- fptr(event, args[0], args[1], args[2]);
+ lttng_hlist_for_each_entry_rcu(event_priv, action_list, u.syscall.node)
+ fptr(event_priv->pub, args[0], args[1], args[2]);
break;
}
case 4:
unsigned long args[LTTNG_SYSCALL_NR_ARGS];
lttng_syscall_get_arguments(current, regs, args);
- lttng_hlist_for_each_entry_rcu(event, action_list, u.syscall.node)
- fptr(event, args[0], args[1], args[2], args[3]);
+ lttng_hlist_for_each_entry_rcu(event_priv, action_list, u.syscall.node)
+ fptr(event_priv->pub, args[0], args[1], args[2], args[3]);
break;
}
case 5:
unsigned long args[LTTNG_SYSCALL_NR_ARGS];
lttng_syscall_get_arguments(current, regs, args);
- lttng_hlist_for_each_entry_rcu(event, action_list, u.syscall.node)
- fptr(event, args[0], args[1], args[2], args[3], args[4]);
+ lttng_hlist_for_each_entry_rcu(event_priv, action_list, u.syscall.node)
+ fptr(event_priv->pub, args[0], args[1], args[2], args[3], args[4]);
break;
}
case 6:
unsigned long args[LTTNG_SYSCALL_NR_ARGS];
lttng_syscall_get_arguments(current, regs, args);
- lttng_hlist_for_each_entry_rcu(event, action_list, u.syscall.node)
- fptr(event, args[0], args[1], args[2],
+ lttng_hlist_for_each_entry_rcu(event_priv, action_list, u.syscall.node)
+ fptr(event_priv->pub, args[0], args[1], args[2],
args[3], args[4], args[5]);
break;
}
}
}
-static __always_inline
-void syscall_entry_event_notifier_call_func(struct hlist_head *dispatch_list,
- void *func, unsigned int nrargs, struct pt_regs *regs)
-{
- struct lttng_event_notifier *notifier;
-
- switch (nrargs) {
- case 0:
- {
- void (*fptr)(void *__data) = func;
-
- lttng_hlist_for_each_entry_rcu(notifier, dispatch_list, u.syscall.node)
- fptr(notifier);
- break;
- }
- case 1:
- {
- void (*fptr)(void *__data, unsigned long arg0) = func;
- unsigned long args[LTTNG_SYSCALL_NR_ARGS];
-
- lttng_syscall_get_arguments(current, regs, args);
- lttng_hlist_for_each_entry_rcu(notifier, dispatch_list, u.syscall.node)
- fptr(notifier, args[0]);
- break;
- }
- case 2:
- {
- void (*fptr)(void *__data,
- unsigned long arg0,
- unsigned long arg1) = func;
- unsigned long args[LTTNG_SYSCALL_NR_ARGS];
-
- lttng_syscall_get_arguments(current, regs, args);
- lttng_hlist_for_each_entry_rcu(notifier, dispatch_list, u.syscall.node)
- fptr(notifier, args[0], args[1]);
- break;
- }
- case 3:
- {
- void (*fptr)(void *__data,
- unsigned long arg0,
- unsigned long arg1,
- unsigned long arg2) = func;
- unsigned long args[LTTNG_SYSCALL_NR_ARGS];
-
- lttng_syscall_get_arguments(current, regs, args);
- lttng_hlist_for_each_entry_rcu(notifier, dispatch_list, u.syscall.node)
- fptr(notifier, args[0], args[1], args[2]);
- break;
- }
- case 4:
- {
- void (*fptr)(void *__data,
- unsigned long arg0,
- unsigned long arg1,
- unsigned long arg2,
- unsigned long arg3) = func;
- unsigned long args[LTTNG_SYSCALL_NR_ARGS];
-
- lttng_syscall_get_arguments(current, regs, args);
- lttng_hlist_for_each_entry_rcu(notifier, dispatch_list, u.syscall.node)
- fptr(notifier, args[0], args[1], args[2], args[3]);
- break;
- }
- case 5:
- {
- void (*fptr)(void *__data,
- unsigned long arg0,
- unsigned long arg1,
- unsigned long arg2,
- unsigned long arg3,
- unsigned long arg4) = func;
- unsigned long args[LTTNG_SYSCALL_NR_ARGS];
-
- lttng_syscall_get_arguments(current, regs, args);
- lttng_hlist_for_each_entry_rcu(notifier, dispatch_list, u.syscall.node)
- fptr(notifier, args[0], args[1], args[2], args[3], args[4]);
- break;
- }
- case 6:
- {
- void (*fptr)(void *__data,
- unsigned long arg0,
- unsigned long arg1,
- unsigned long arg2,
- unsigned long arg3,
- unsigned long arg4,
- unsigned long arg5) = func;
- unsigned long args[LTTNG_SYSCALL_NR_ARGS];
-
- lttng_syscall_get_arguments(current, regs, args);
- lttng_hlist_for_each_entry_rcu(notifier, dispatch_list, u.syscall.node)
- fptr(notifier, args[0], args[1], args[2], args[3], args[4], args[5]);
- break;
- }
- default:
- break;
- }
-}
-
void syscall_entry_event_probe(void *__data, struct pt_regs *regs, long id)
{
- struct lttng_channel *chan = __data;
+ struct lttng_kernel_syscall_table *syscall_table = __data;
struct hlist_head *action_list, *unknown_action_list;
const struct trace_syscall_entry *table, *entry;
size_t table_len;
if (unlikely(in_compat_syscall())) {
- struct lttng_syscall_filter *filter = chan->sc_filter;
+ struct lttng_syscall_filter *filter = syscall_table->sc_filter;
if (id < 0 || id >= NR_compat_syscalls
- || (!READ_ONCE(chan->syscall_all_entry) && !test_bit(id, filter->sc_compat_entry))) {
+ || (!READ_ONCE(syscall_table->syscall_all_entry) && !test_bit(id, filter->sc_compat_entry))) {
/* System call filtered out. */
return;
}
- table = compat_sc_table;
- table_len = ARRAY_SIZE(compat_sc_table);
- unknown_action_list = &chan->sc_compat_unknown;
+ table = compat_sc_table.table;
+ table_len = compat_sc_table.len;
+ unknown_action_list = &syscall_table->compat_unknown_syscall_dispatch;
} else {
- struct lttng_syscall_filter *filter = chan->sc_filter;
+ struct lttng_syscall_filter *filter = syscall_table->sc_filter;
if (id < 0 || id >= NR_syscalls
- || (!READ_ONCE(chan->syscall_all_entry) && !test_bit(id, filter->sc_entry))) {
+ || (!READ_ONCE(syscall_table->syscall_all_entry) && !test_bit(id, filter->sc_entry))) {
/* System call filtered out. */
return;
}
- table = sc_table;
- table_len = ARRAY_SIZE(sc_table);
- unknown_action_list = &chan->sc_unknown;
+ table = sc_table.table;
+ table_len = sc_table.len;
+ unknown_action_list = &syscall_table->unknown_syscall_dispatch;
}
if (unlikely(id < 0 || id >= table_len)) {
syscall_entry_event_unknown(unknown_action_list, regs, id);
}
if (unlikely(in_compat_syscall())) {
- action_list = &chan->compat_sc_table[id];
+ action_list = &syscall_table->compat_syscall_dispatch[id];
} else {
- action_list = &chan->sc_table[id];
+ action_list = &syscall_table->syscall_dispatch[id];
}
if (unlikely(hlist_empty(action_list)))
return;
- syscall_entry_call_func(action_list, entry->event_func, entry->nrargs, regs);
-}
-
-void syscall_entry_event_notifier_probe(void *__data, struct pt_regs *regs,
- long id)
-{
- struct lttng_event_notifier_group *group = __data;
- const struct trace_syscall_entry *table, *entry;
- struct hlist_head *dispatch_list, *unknown_dispatch_list;
- size_t table_len;
-
- if (unlikely(in_compat_syscall())) {
- struct lttng_syscall_filter *filter = group->sc_filter;
-
- if (id < 0 || id >= NR_compat_syscalls
- || (!READ_ONCE(group->syscall_all_entry) &&
- !test_bit(id, filter->sc_compat_entry))) {
- /* System call filtered out. */
- return;
- }
- table = compat_sc_table;
- table_len = ARRAY_SIZE(compat_sc_table);
- unknown_dispatch_list = &group->event_notifier_compat_unknown_syscall_dispatch;
- } else {
- struct lttng_syscall_filter *filter = group->sc_filter;
-
- if (id < 0 || id >= NR_syscalls
- || (!READ_ONCE(group->syscall_all_entry) &&
- !test_bit(id, filter->sc_entry))) {
- /* System call filtered out. */
- return;
- }
- table = sc_table;
- table_len = ARRAY_SIZE(sc_table);
- unknown_dispatch_list = &group->event_notifier_unknown_syscall_dispatch;
- }
- /* Check if the syscall id is out of bound. */
- if (unlikely(id < 0 || id >= table_len)) {
- syscall_entry_event_notifier_unknown(unknown_dispatch_list,
- regs, id);
- return;
- }
-
- entry = &table[id];
- if (!entry->event_notifier_func) {
- syscall_entry_event_notifier_unknown(unknown_dispatch_list,
- regs, id);
- return;
- }
-
- if (unlikely(in_compat_syscall())) {
- dispatch_list = &group->event_notifier_compat_syscall_dispatch[id];
- } else {
- dispatch_list = &group->event_notifier_syscall_dispatch[id];
- }
- if (unlikely(hlist_empty(dispatch_list)))
- return;
-
- syscall_entry_event_notifier_call_func(dispatch_list,
- entry->event_notifier_func, entry->nrargs, regs);
+ syscall_entry_event_call_func(action_list, entry->event_func, entry->nrargs, regs);
}
static void syscall_exit_event_unknown(struct hlist_head *unknown_action_list_head,
struct pt_regs *regs, long id, long ret)
{
unsigned long args[LTTNG_SYSCALL_NR_ARGS];
- struct lttng_event *event;
+ struct lttng_kernel_event_common_private *event_priv;
lttng_syscall_get_arguments(current, regs, args);
- lttng_hlist_for_each_entry_rcu(event, unknown_action_list_head, u.syscall.node) {
+ lttng_hlist_for_each_entry_rcu(event_priv, unknown_action_list_head, u.syscall.node) {
if (unlikely(in_compat_syscall()))
- __event_probe__compat_syscall_exit_unknown(event, id, ret,
+ __event_probe__compat_syscall_exit_unknown(event_priv->pub, id, ret,
args);
else
- __event_probe__syscall_exit_unknown(event, id, ret, args);
+ __event_probe__syscall_exit_unknown(event_priv->pub, id, ret, args);
}
}
static __always_inline
-void syscall_exit_call_func(struct hlist_head *action_list,
+void syscall_exit_event_call_func(struct hlist_head *action_list,
void *func, unsigned int nrargs,
struct pt_regs *regs, long ret)
{
- struct lttng_event *event;
+ struct lttng_kernel_event_common_private *event_priv;
switch (nrargs) {
case 0:
{
void (*fptr)(void *__data, long ret) = func;
- lttng_hlist_for_each_entry_rcu(event, action_list, u.syscall.node)
- fptr(event, ret);
+ lttng_hlist_for_each_entry_rcu(event_priv, action_list, u.syscall.node)
+ fptr(event_priv->pub, ret);
break;
}
case 1:
unsigned long args[LTTNG_SYSCALL_NR_ARGS];
lttng_syscall_get_arguments(current, regs, args);
- lttng_hlist_for_each_entry_rcu(event, action_list, u.syscall.node)
- fptr(event, ret, args[0]);
+ lttng_hlist_for_each_entry_rcu(event_priv, action_list, u.syscall.node)
+ fptr(event_priv->pub, ret, args[0]);
break;
}
case 2:
unsigned long args[LTTNG_SYSCALL_NR_ARGS];
lttng_syscall_get_arguments(current, regs, args);
- lttng_hlist_for_each_entry_rcu(event, action_list, u.syscall.node)
- fptr(event, ret, args[0], args[1]);
+ lttng_hlist_for_each_entry_rcu(event_priv, action_list, u.syscall.node)
+ fptr(event_priv->pub, ret, args[0], args[1]);
break;
}
case 3:
unsigned long args[LTTNG_SYSCALL_NR_ARGS];
lttng_syscall_get_arguments(current, regs, args);
- lttng_hlist_for_each_entry_rcu(event, action_list, u.syscall.node)
- fptr(event, ret, args[0], args[1], args[2]);
+ lttng_hlist_for_each_entry_rcu(event_priv, action_list, u.syscall.node)
+ fptr(event_priv->pub, ret, args[0], args[1], args[2]);
break;
}
case 4:
unsigned long args[LTTNG_SYSCALL_NR_ARGS];
lttng_syscall_get_arguments(current, regs, args);
- lttng_hlist_for_each_entry_rcu(event, action_list, u.syscall.node)
- fptr(event, ret, args[0], args[1], args[2], args[3]);
+ lttng_hlist_for_each_entry_rcu(event_priv, action_list, u.syscall.node)
+ fptr(event_priv->pub, ret, args[0], args[1], args[2], args[3]);
break;
}
case 5:
unsigned long args[LTTNG_SYSCALL_NR_ARGS];
lttng_syscall_get_arguments(current, regs, args);
- lttng_hlist_for_each_entry_rcu(event, action_list, u.syscall.node)
- fptr(event, ret, args[0], args[1], args[2], args[3], args[4]);
+ lttng_hlist_for_each_entry_rcu(event_priv, action_list, u.syscall.node)
+ fptr(event_priv->pub, ret, args[0], args[1], args[2], args[3], args[4]);
break;
}
case 6:
unsigned long args[LTTNG_SYSCALL_NR_ARGS];
lttng_syscall_get_arguments(current, regs, args);
- lttng_hlist_for_each_entry_rcu(event, action_list, u.syscall.node)
- fptr(event, ret, args[0], args[1], args[2],
+ lttng_hlist_for_each_entry_rcu(event_priv, action_list, u.syscall.node)
+ fptr(event_priv->pub, ret, args[0], args[1], args[2],
args[3], args[4], args[5]);
break;
}
void syscall_exit_event_probe(void *__data, struct pt_regs *regs, long ret)
{
- struct lttng_channel *chan = __data;
+ struct lttng_kernel_syscall_table *syscall_table = __data;
struct hlist_head *action_list, *unknown_action_list;
const struct trace_syscall_entry *table, *entry;
size_t table_len;
id = syscall_get_nr(current, regs);
if (unlikely(in_compat_syscall())) {
- struct lttng_syscall_filter *filter = chan->sc_filter;
+ struct lttng_syscall_filter *filter = syscall_table->sc_filter;
if (id < 0 || id >= NR_compat_syscalls
- || (!READ_ONCE(chan->syscall_all_exit) && !test_bit(id, filter->sc_compat_exit))) {
+ || (!READ_ONCE(syscall_table->syscall_all_exit) && !test_bit(id, filter->sc_compat_exit))) {
/* System call filtered out. */
return;
}
- table = compat_sc_exit_table;
- table_len = ARRAY_SIZE(compat_sc_exit_table);
- unknown_action_list = &chan->compat_sc_exit_unknown;
+ table = compat_sc_exit_table.table;
+ table_len = compat_sc_exit_table.len;
+ unknown_action_list = &syscall_table->compat_unknown_syscall_exit_dispatch;
} else {
- struct lttng_syscall_filter *filter = chan->sc_filter;
+ struct lttng_syscall_filter *filter = syscall_table->sc_filter;
if (id < 0 || id >= NR_syscalls
- || (!READ_ONCE(chan->syscall_all_exit) && !test_bit(id, filter->sc_exit))) {
+ || (!READ_ONCE(syscall_table->syscall_all_exit) && !test_bit(id, filter->sc_exit))) {
/* System call filtered out. */
return;
}
- table = sc_exit_table;
- table_len = ARRAY_SIZE(sc_exit_table);
- unknown_action_list = &chan->sc_exit_unknown;
+ table = sc_exit_table.table;
+ table_len = sc_exit_table.len;
+ unknown_action_list = &syscall_table->unknown_syscall_exit_dispatch;
}
if (unlikely(id < 0 || id >= table_len)) {
syscall_exit_event_unknown(unknown_action_list, regs, id, ret);
}
if (unlikely(in_compat_syscall())) {
- action_list = &chan->compat_sc_exit_table[id];
+ action_list = &syscall_table->compat_syscall_exit_dispatch[id];
} else {
- action_list = &chan->sc_exit_table[id];
+ action_list = &syscall_table->syscall_exit_dispatch[id];
}
if (unlikely(hlist_empty(action_list)))
return;
- syscall_exit_call_func(action_list, entry->event_func, entry->nrargs,
+ syscall_exit_event_call_func(action_list, entry->event_func, entry->nrargs,
regs, ret);
}
-static __always_inline
-void syscall_exit_event_notifier_call_func(struct hlist_head *dispatch_list,
- void *func, unsigned int nrargs, struct pt_regs *regs, long ret)
+static
+struct lttng_kernel_syscall_table *get_syscall_table_from_enabler(struct lttng_event_enabler_common *event_enabler)
{
- struct lttng_event_notifier *notifier;
-
- switch (nrargs) {
- case 0:
- {
- void (*fptr)(void *__data, long ret) = func;
-
- lttng_hlist_for_each_entry_rcu(notifier, dispatch_list, u.syscall.node)
- fptr(notifier, ret);
- break;
- }
- case 1:
+ switch (event_enabler->enabler_type) {
+ case LTTNG_EVENT_ENABLER_TYPE_RECORDER:
{
- void (*fptr)(void *__data, long ret, unsigned long arg0) = func;
- unsigned long args[LTTNG_SYSCALL_NR_ARGS];
-
- lttng_syscall_get_arguments(current, regs, args);
- lttng_hlist_for_each_entry_rcu(notifier, dispatch_list, u.syscall.node)
- fptr(notifier, ret, args[0]);
- break;
+ struct lttng_event_recorder_enabler *event_recorder_enabler =
+ container_of(event_enabler, struct lttng_event_recorder_enabler, parent);
+ return &event_recorder_enabler->chan->priv->parent.syscall_table;
}
- case 2:
+ case LTTNG_EVENT_ENABLER_TYPE_NOTIFIER:
{
- void (*fptr)(void *__data,
- long ret,
- unsigned long arg0,
- unsigned long arg1) = func;
- unsigned long args[LTTNG_SYSCALL_NR_ARGS];
-
- lttng_syscall_get_arguments(current, regs, args);
- lttng_hlist_for_each_entry_rcu(notifier, dispatch_list, u.syscall.node)
- fptr(notifier, ret, args[0], args[1]);
- break;
+ struct lttng_event_notifier_enabler *event_notifier_enabler =
+ container_of(event_enabler, struct lttng_event_notifier_enabler, parent);
+ return &event_notifier_enabler->group->syscall_table;
}
- case 3:
- {
- void (*fptr)(void *__data,
- long ret,
- unsigned long arg0,
- unsigned long arg1,
- unsigned long arg2) = func;
- unsigned long args[LTTNG_SYSCALL_NR_ARGS];
-
- lttng_syscall_get_arguments(current, regs, args);
- lttng_hlist_for_each_entry_rcu(notifier, dispatch_list, u.syscall.node)
- fptr(notifier, ret, args[0], args[1], args[2]);
- break;
+ default:
+ return NULL;
}
- case 4:
- {
- void (*fptr)(void *__data,
- long ret,
- unsigned long arg0,
- unsigned long arg1,
- unsigned long arg2,
- unsigned long arg3) = func;
- unsigned long args[LTTNG_SYSCALL_NR_ARGS];
+}
- lttng_syscall_get_arguments(current, regs, args);
- lttng_hlist_for_each_entry_rcu(notifier, dispatch_list, u.syscall.node)
- fptr(notifier, ret, args[0], args[1], args[2], args[3]);
- break;
- }
- case 5:
+static
+struct lttng_kernel_syscall_table *get_syscall_table_from_event(struct lttng_kernel_event_common *event)
+{
+ switch (event->type) {
+ case LTTNG_KERNEL_EVENT_TYPE_RECORDER:
{
- void (*fptr)(void *__data,
- long ret,
- unsigned long arg0,
- unsigned long arg1,
- unsigned long arg2,
- unsigned long arg3,
- unsigned long arg4) = func;
- unsigned long args[LTTNG_SYSCALL_NR_ARGS];
-
- lttng_syscall_get_arguments(current, regs, args);
- lttng_hlist_for_each_entry_rcu(notifier, dispatch_list, u.syscall.node)
- fptr(notifier, ret, args[0], args[1], args[2], args[3], args[4]);
- break;
+ struct lttng_kernel_event_recorder *event_recorder =
+ container_of(event, struct lttng_kernel_event_recorder, parent);
+ return &event_recorder->chan->priv->parent.syscall_table;
}
- case 6:
+ case LTTNG_KERNEL_EVENT_TYPE_NOTIFIER:
{
- void (*fptr)(void *__data,
- long ret,
- unsigned long arg0,
- unsigned long arg1,
- unsigned long arg2,
- unsigned long arg3,
- unsigned long arg4,
- unsigned long arg5) = func;
- unsigned long args[LTTNG_SYSCALL_NR_ARGS];
-
- lttng_syscall_get_arguments(current, regs, args);
- lttng_hlist_for_each_entry_rcu(notifier, dispatch_list, u.syscall.node)
- fptr(notifier, ret, args[0], args[1], args[2], args[3], args[4], args[5]);
- break;
+ struct lttng_kernel_event_notifier *event_notifier =
+ container_of(event, struct lttng_kernel_event_notifier, parent);
+ return &event_notifier->priv->group->syscall_table;
}
default:
- break;
+ return NULL;
}
}
static
-void syscall_exit_event_notifier_probe(void *__data, struct pt_regs *regs,
- long ret)
+void lttng_syscall_event_enabler_create_event(struct lttng_event_enabler_common *syscall_event_enabler,
+ const struct lttng_kernel_event_desc *desc, struct hlist_head *dispatch_table,
+ enum sc_type type, unsigned int syscall_nr)
{
- struct lttng_event_notifier_group *group = __data;
- const struct trace_syscall_entry *table, *entry;
- struct hlist_head *dispatch_list, *unknown_dispatch_list;
- size_t table_len;
- long id;
+ struct lttng_kernel_event_common *event;
- id = syscall_get_nr(current, regs);
+ switch (syscall_event_enabler->enabler_type) {
+ case LTTNG_EVENT_ENABLER_TYPE_RECORDER:
+ {
+ struct lttng_event_recorder_enabler *syscall_event_recorder_enabler =
+ container_of(syscall_event_enabler, struct lttng_event_recorder_enabler, parent);
+ struct lttng_event_recorder_enabler *event_recorder_enabler;
+ struct lttng_kernel_abi_event ev;
- if (unlikely(in_compat_syscall())) {
- struct lttng_syscall_filter *filter = group->sc_filter;
-
- if (id < 0 || id >= NR_compat_syscalls
- || (!READ_ONCE(group->syscall_all_exit) &&
- !test_bit(id, filter->sc_compat_exit))) {
- /* System call filtered out. */
- return;
+ /* We need to create an event for this syscall/enabler. */
+ memset(&ev, 0, sizeof(ev));
+ switch (type) {
+ case SC_TYPE_ENTRY:
+ ev.u.syscall.entryexit = LTTNG_KERNEL_ABI_SYSCALL_ENTRY;
+ ev.u.syscall.abi = LTTNG_KERNEL_ABI_SYSCALL_ABI_NATIVE;
+ break;
+ case SC_TYPE_EXIT:
+ ev.u.syscall.entryexit = LTTNG_KERNEL_ABI_SYSCALL_EXIT;
+ ev.u.syscall.abi = LTTNG_KERNEL_ABI_SYSCALL_ABI_NATIVE;
+ break;
+ case SC_TYPE_COMPAT_ENTRY:
+ ev.u.syscall.entryexit = LTTNG_KERNEL_ABI_SYSCALL_ENTRY;
+ ev.u.syscall.abi = LTTNG_KERNEL_ABI_SYSCALL_ABI_COMPAT;
+ break;
+ case SC_TYPE_COMPAT_EXIT:
+ ev.u.syscall.entryexit = LTTNG_KERNEL_ABI_SYSCALL_EXIT;
+ ev.u.syscall.abi = LTTNG_KERNEL_ABI_SYSCALL_ABI_COMPAT;
+ break;
}
- table = compat_sc_exit_table;
- table_len = ARRAY_SIZE(compat_sc_exit_table);
- unknown_dispatch_list = &group->event_notifier_exit_compat_unknown_syscall_dispatch;
- } else {
- struct lttng_syscall_filter *filter = group->sc_filter;
-
- if (id < 0 || id >= NR_syscalls
- || (!READ_ONCE(group->syscall_all_exit) &&
- !test_bit(id, filter->sc_exit))) {
- /* System call filtered out. */
+ strncpy(ev.name, desc->event_name, LTTNG_KERNEL_ABI_SYM_NAME_LEN - 1);
+ ev.name[LTTNG_KERNEL_ABI_SYM_NAME_LEN - 1] = '\0';
+ ev.instrumentation = LTTNG_KERNEL_ABI_SYSCALL;
+ event_recorder_enabler = lttng_event_recorder_enabler_create(LTTNG_ENABLER_FORMAT_NAME, &ev,
+ syscall_event_recorder_enabler->chan);
+ WARN_ON_ONCE(!event_recorder_enabler);
+ if (!event_recorder_enabler)
+ return;
+ event = _lttng_kernel_event_create(&event_recorder_enabler->parent, desc);
+ WARN_ON_ONCE(!event || IS_ERR(event));
+ lttng_event_enabler_destroy(&event_recorder_enabler->parent);
+ if (!event || IS_ERR(event)) {
+ printk(KERN_INFO "Unable to create event recorder %s\n", desc->event_name);
return;
}
- table = sc_exit_table;
- table_len = ARRAY_SIZE(sc_exit_table);
- unknown_dispatch_list = &group->event_notifier_exit_unknown_syscall_dispatch;
- }
- /* Check if the syscall id is out of bound. */
- if (unlikely(id < 0 || id >= table_len)) {
- syscall_exit_event_notifier_unknown(unknown_dispatch_list,
- regs, id, ret);
- return;
- }
-
- entry = &table[id];
- if (!entry->event_notifier_func) {
- syscall_entry_event_notifier_unknown(unknown_dispatch_list,
- regs, id);
- return;
- }
-
- if (unlikely(in_compat_syscall())) {
- dispatch_list = &group->event_notifier_exit_compat_syscall_dispatch[id];
- } else {
- dispatch_list = &group->event_notifier_exit_syscall_dispatch[id];
+ event->priv->u.syscall.syscall_id = syscall_nr;
+ if (dispatch_table)
+ hlist_add_head_rcu(&event->priv->u.syscall.node, dispatch_table);
+ break;
}
- if (unlikely(hlist_empty(dispatch_list)))
- return;
-
- syscall_exit_event_notifier_call_func(dispatch_list,
- entry->event_notifier_func, entry->nrargs, regs, ret);
-}
-/*
- * noinline to diminish caller stack size.
- * Should be called with sessions lock held.
- */
-static
-int lttng_create_syscall_event_if_missing(const struct trace_syscall_entry *table, size_t table_len,
- struct hlist_head *chan_table, struct lttng_event_enabler *event_enabler,
- void *filter, enum sc_type type)
-{
- struct lttng_channel *chan = event_enabler->chan;
- struct lttng_session *session = chan->session;
- unsigned int i;
-
- /* Allocate events for each syscall matching enabler, insert into table */
- for (i = 0; i < table_len; i++) {
- const struct lttng_event_desc *desc = table[i].desc;
- struct lttng_kernel_event ev;
- struct lttng_event *event;
- struct hlist_head *head;
- bool found = false;
-
- if (!desc) {
- /* Unknown syscall */
- continue;
- }
- if (lttng_desc_match_enabler(desc,
- lttng_event_enabler_as_enabler(event_enabler)) <= 0)
- continue;
- /*
- * Check if already created.
- */
- head = utils_borrow_hash_table_bucket(
- session->events_ht.table, LTTNG_EVENT_HT_SIZE,
- desc->name);
- lttng_hlist_for_each_entry(event, head, hlist) {
- if (event->desc == desc
- && event->chan == event_enabler->chan)
- found = true;
- }
- if (found)
- continue;
+ case LTTNG_EVENT_ENABLER_TYPE_NOTIFIER:
+ {
+ struct lttng_event_notifier_enabler *syscall_event_notifier_enabler =
+ container_of(syscall_event_enabler, struct lttng_event_notifier_enabler, parent);
+ struct lttng_event_notifier_enabler *event_notifier_enabler;
+ struct lttng_kernel_abi_event_notifier event_notifier_param;
+ uint64_t user_token = syscall_event_enabler->user_token;
+ uint64_t error_counter_index = syscall_event_notifier_enabler->error_counter_index;
- /* We need to create an event for this syscall/enabler. */
- memset(&ev, 0, sizeof(ev));
+ memset(&event_notifier_param, 0, sizeof(event_notifier_param));
switch (type) {
case SC_TYPE_ENTRY:
- ev.u.syscall.entryexit = LTTNG_KERNEL_SYSCALL_ENTRY;
- ev.u.syscall.abi = LTTNG_KERNEL_SYSCALL_ABI_NATIVE;
+ event_notifier_param.event.u.syscall.entryexit = LTTNG_KERNEL_ABI_SYSCALL_ENTRY;
+ event_notifier_param.event.u.syscall.abi = LTTNG_KERNEL_ABI_SYSCALL_ABI_NATIVE;
break;
case SC_TYPE_EXIT:
- ev.u.syscall.entryexit = LTTNG_KERNEL_SYSCALL_EXIT;
- ev.u.syscall.abi = LTTNG_KERNEL_SYSCALL_ABI_NATIVE;
+ event_notifier_param.event.u.syscall.entryexit = LTTNG_KERNEL_ABI_SYSCALL_EXIT;
+ event_notifier_param.event.u.syscall.abi = LTTNG_KERNEL_ABI_SYSCALL_ABI_NATIVE;
break;
case SC_TYPE_COMPAT_ENTRY:
- ev.u.syscall.entryexit = LTTNG_KERNEL_SYSCALL_ENTRY;
- ev.u.syscall.abi = LTTNG_KERNEL_SYSCALL_ABI_COMPAT;
+ event_notifier_param.event.u.syscall.entryexit = LTTNG_KERNEL_ABI_SYSCALL_ENTRY;
+ event_notifier_param.event.u.syscall.abi = LTTNG_KERNEL_ABI_SYSCALL_ABI_COMPAT;
break;
case SC_TYPE_COMPAT_EXIT:
- ev.u.syscall.entryexit = LTTNG_KERNEL_SYSCALL_EXIT;
- ev.u.syscall.abi = LTTNG_KERNEL_SYSCALL_ABI_COMPAT;
+ event_notifier_param.event.u.syscall.entryexit = LTTNG_KERNEL_ABI_SYSCALL_EXIT;
+ event_notifier_param.event.u.syscall.abi = LTTNG_KERNEL_ABI_SYSCALL_ABI_COMPAT;
break;
}
- 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;
- event = _lttng_event_create(chan, &ev, filter,
- desc, ev.instrumentation);
- WARN_ON_ONCE(!event);
- if (IS_ERR(event)) {
- /*
- * If something goes wrong in event registration
- * after the first one, we have no choice but to
- * leave the previous events in there, until
- * deleted by session teardown.
- */
- return PTR_ERR(event);
+ strncat(event_notifier_param.event.name, desc->event_name,
+ LTTNG_KERNEL_ABI_SYM_NAME_LEN - strlen(event_notifier_param.event.name) - 1);
+ event_notifier_param.event.name[LTTNG_KERNEL_ABI_SYM_NAME_LEN - 1] = '\0';
+ event_notifier_param.event.instrumentation = LTTNG_KERNEL_ABI_SYSCALL;
+ event_notifier_param.event.token = user_token;
+ event_notifier_param.error_counter_index = error_counter_index;
+
+ event_notifier_enabler = lttng_event_notifier_enabler_create(LTTNG_ENABLER_FORMAT_NAME,
+ &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));
+ lttng_event_enabler_destroy(&event_notifier_enabler->parent);
+ if (!event || IS_ERR(event)) {
+ printk(KERN_INFO "Unable to create event notifier %s\n", desc->event_name);
+ return;
}
- hlist_add_head(&event->u.syscall.node, &chan_table[i]);
+ event->priv->u.syscall.syscall_id = syscall_nr;
+ if (dispatch_table)
+ hlist_add_head_rcu(&event->priv->u.syscall.node, dispatch_table);
+ break;
+ }
+ default:
+ break;
}
- return 0;
}
-/*
- * Should be called with sessions lock held.
- */
-int lttng_syscalls_register_event(struct lttng_event_enabler *event_enabler, void *filter)
+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,
+ enum sc_type type)
{
- struct lttng_channel *chan = event_enabler->chan;
- struct lttng_kernel_event ev;
- int ret;
-
- wrapper_vmalloc_sync_mappings();
-
- if (!chan->sc_table) {
- /* create syscall table mapping syscall to events */
- chan->sc_table = kzalloc(sizeof(struct lttng_event *)
- * ARRAY_SIZE(sc_table), GFP_KERNEL);
- if (!chan->sc_table)
- return -ENOMEM;
- }
- if (!chan->sc_exit_table) {
- /* create syscall table mapping syscall to events */
- chan->sc_exit_table = kzalloc(sizeof(struct lttng_event *)
- * ARRAY_SIZE(sc_exit_table), GFP_KERNEL);
- if (!chan->sc_exit_table)
- return -ENOMEM;
- }
-
-
-#ifdef CONFIG_COMPAT
- if (!chan->compat_sc_table) {
- /* create syscall table mapping compat syscall to events */
- chan->compat_sc_table = kzalloc(sizeof(struct lttng_event *)
- * ARRAY_SIZE(compat_sc_table), GFP_KERNEL);
- if (!chan->compat_sc_table)
- return -ENOMEM;
- }
-
- if (!chan->compat_sc_exit_table) {
- /* create syscall table mapping compat syscall to events */
- chan->compat_sc_exit_table = kzalloc(sizeof(struct lttng_event *)
- * ARRAY_SIZE(compat_sc_exit_table), GFP_KERNEL);
- if (!chan->compat_sc_exit_table)
- return -ENOMEM;
- }
-#endif
- if (hlist_empty(&chan->sc_unknown)) {
- const struct lttng_event_desc *desc =
- &__event_desc___syscall_entry_unknown;
- struct lttng_event *event;
-
- memset(&ev, 0, sizeof(ev));
- strncpy(ev.name, desc->name, LTTNG_KERNEL_SYM_NAME_LEN);
- ev.name[LTTNG_KERNEL_SYM_NAME_LEN - 1] = '\0';
- ev.instrumentation = LTTNG_KERNEL_SYSCALL;
- ev.u.syscall.entryexit = LTTNG_KERNEL_SYSCALL_ENTRY;
- ev.u.syscall.abi = LTTNG_KERNEL_SYSCALL_ABI_NATIVE;
- event = _lttng_event_create(chan, &ev, filter, desc,
- ev.instrumentation);
- WARN_ON_ONCE(!event);
- if (IS_ERR(event)) {
- return PTR_ERR(event);
- }
- hlist_add_head(&event->u.syscall.node, &chan->sc_unknown);
- }
-
- if (hlist_empty(&chan->sc_compat_unknown)) {
- const struct lttng_event_desc *desc =
- &__event_desc___compat_syscall_entry_unknown;
- struct lttng_event *event;
+ 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;
- memset(&ev, 0, sizeof(ev));
- strncpy(ev.name, desc->name, LTTNG_KERNEL_SYM_NAME_LEN);
- ev.name[LTTNG_KERNEL_SYM_NAME_LEN - 1] = '\0';
- ev.instrumentation = LTTNG_KERNEL_SYSCALL;
- ev.u.syscall.entryexit = LTTNG_KERNEL_SYSCALL_ENTRY;
- ev.u.syscall.abi = LTTNG_KERNEL_SYSCALL_ABI_COMPAT;
- event = _lttng_event_create(chan, &ev, filter, desc,
- ev.instrumentation);
- WARN_ON_ONCE(!event);
- if (IS_ERR(event)) {
- return PTR_ERR(event);
- }
- hlist_add_head(&event->u.syscall.node, &chan->sc_compat_unknown);
- }
+ if (!IS_ENABLED(CONFIG_COMPAT) && (type == SC_TYPE_COMPAT_ENTRY || type == SC_TYPE_COMPAT_EXIT))
+ return;
- if (hlist_empty(&chan->compat_sc_exit_unknown)) {
- const struct lttng_event_desc *desc =
- &__event_desc___compat_syscall_exit_unknown;
- struct lttng_event *event;
+ /* iterate over all syscall and create event_notifier that match */
+ for (i = 0; i < table_len; i++) {
+ struct lttng_kernel_event_common_private *event_priv;
+ struct hlist_head *head;
+ int found = 0;
- memset(&ev, 0, sizeof(ev));
- strncpy(ev.name, desc->name, LTTNG_KERNEL_SYM_NAME_LEN);
- ev.name[LTTNG_KERNEL_SYM_NAME_LEN - 1] = '\0';
- ev.instrumentation = LTTNG_KERNEL_SYSCALL;
- ev.u.syscall.entryexit = LTTNG_KERNEL_SYSCALL_EXIT;
- ev.u.syscall.abi = LTTNG_KERNEL_SYSCALL_ABI_COMPAT;
- event = _lttng_event_create(chan, &ev, filter, desc,
- ev.instrumentation);
- WARN_ON_ONCE(!event);
- if (IS_ERR(event)) {
- return PTR_ERR(event);
+ desc = table[i].desc;
+ if (!desc) {
+ /* Unknown syscall */
+ continue;
}
- hlist_add_head(&event->u.syscall.node, &chan->compat_sc_exit_unknown);
- }
- if (hlist_empty(&chan->sc_exit_unknown)) {
- const struct lttng_event_desc *desc =
- &__event_desc___syscall_exit_unknown;
- struct lttng_event *event;
+ if (!lttng_desc_match_enabler(desc, syscall_event_enabler_common))
+ continue;
- memset(&ev, 0, sizeof(ev));
- strncpy(ev.name, desc->name, LTTNG_KERNEL_SYM_NAME_LEN);
- ev.name[LTTNG_KERNEL_SYM_NAME_LEN - 1] = '\0';
- ev.instrumentation = LTTNG_KERNEL_SYSCALL;
- ev.u.syscall.entryexit = LTTNG_KERNEL_SYSCALL_EXIT;
- ev.u.syscall.abi = LTTNG_KERNEL_SYSCALL_ABI_NATIVE;
- event = _lttng_event_create(chan, &ev, filter, desc,
- ev.instrumentation);
- WARN_ON_ONCE(!event);
- if (IS_ERR(event)) {
- return PTR_ERR(event);
+ /*
+ * Check if already created.
+ */
+ head = utils_borrow_hash_table_bucket(events_ht->table, LTTNG_EVENT_HT_SIZE, desc->event_name);
+ lttng_hlist_for_each_entry(event_priv, head, hlist_node) {
+ if (lttng_event_enabler_desc_match_event(syscall_event_enabler_common, desc, event_priv->pub))
+ found = 1;
}
- hlist_add_head(&event->u.syscall.node, &chan->sc_exit_unknown);
- }
-
- ret = lttng_create_syscall_event_if_missing(sc_table, ARRAY_SIZE(sc_table),
- chan->sc_table, event_enabler, filter, SC_TYPE_ENTRY);
- if (ret)
- return ret;
- ret = lttng_create_syscall_event_if_missing(sc_exit_table, ARRAY_SIZE(sc_exit_table),
- chan->sc_exit_table, event_enabler, filter, SC_TYPE_EXIT);
- if (ret)
- return ret;
-
-#ifdef CONFIG_COMPAT
- ret = lttng_create_syscall_event_if_missing(compat_sc_table, ARRAY_SIZE(compat_sc_table),
- chan->compat_sc_table, event_enabler, filter,
- SC_TYPE_COMPAT_ENTRY);
- if (ret)
- return ret;
- ret = lttng_create_syscall_event_if_missing(compat_sc_exit_table, ARRAY_SIZE(compat_sc_exit_table),
- chan->compat_sc_exit_table, event_enabler, filter,
- SC_TYPE_COMPAT_EXIT);
- if (ret)
- return ret;
-#endif
-
- if (!chan->sc_filter) {
- chan->sc_filter = kzalloc(sizeof(struct lttng_syscall_filter),
- GFP_KERNEL);
- if (!chan->sc_filter)
- return -ENOMEM;
- }
+ if (found)
+ continue;
- if (!chan->sys_enter_registered) {
- ret = lttng_wrapper_tracepoint_probe_register("sys_enter",
- (void *) syscall_entry_event_probe, chan);
- if (ret)
- return ret;
- chan->sys_enter_registered = 1;
- }
- /*
- * We change the name of sys_exit tracepoint due to namespace
- * conflict with sys_exit syscall entry.
- */
- if (!chan->sys_exit_registered) {
- ret = lttng_wrapper_tracepoint_probe_register("sys_exit",
- (void *) syscall_exit_event_probe, chan);
- if (ret) {
- WARN_ON_ONCE(lttng_wrapper_tracepoint_probe_unregister("sys_enter",
- (void *) syscall_entry_event_probe, chan));
- return ret;
- }
- chan->sys_exit_registered = 1;
+ lttng_syscall_event_enabler_create_event(syscall_event_enabler_common, desc, NULL, type, i);
}
- return ret;
}
-/*
- * Should be called with sessions lock held.
- */
-int lttng_syscalls_register_event_notifier(
- struct lttng_event_notifier_enabler *event_notifier_enabler,
- void *filter)
+static
+bool lttng_syscall_event_enabler_is_wildcard_all(struct lttng_event_enabler_common *event_enabler)
{
- struct lttng_event_notifier_group *group = event_notifier_enabler->group;
- unsigned int i;
- int ret = 0;
-
- wrapper_vmalloc_sync_mappings();
-
- if (!group->event_notifier_syscall_dispatch) {
- group->event_notifier_syscall_dispatch =
- kzalloc(sizeof(struct hlist_head) * ARRAY_SIZE(sc_table),
- GFP_KERNEL);
- if (!group->event_notifier_syscall_dispatch)
- return -ENOMEM;
-
- /* Initialize all list_head */
- for (i = 0; i < ARRAY_SIZE(sc_table); i++)
- INIT_HLIST_HEAD(&group->event_notifier_syscall_dispatch[i]);
-
- /* Init the unknown syscall notifier list. */
- INIT_HLIST_HEAD(&group->event_notifier_unknown_syscall_dispatch);
- }
-
- if (!group->event_notifier_exit_syscall_dispatch) {
- group->event_notifier_exit_syscall_dispatch =
- kzalloc(sizeof(struct hlist_head) * ARRAY_SIZE(sc_table),
- GFP_KERNEL);
- if (!group->event_notifier_exit_syscall_dispatch)
- return -ENOMEM;
-
- /* Initialize all list_head */
- for (i = 0; i < ARRAY_SIZE(sc_table); i++)
- INIT_HLIST_HEAD(&group->event_notifier_exit_syscall_dispatch[i]);
-
- /* Init the unknown exit syscall notifier list. */
- INIT_HLIST_HEAD(&group->event_notifier_exit_unknown_syscall_dispatch);
- }
-
-#ifdef CONFIG_COMPAT
- if (!group->event_notifier_compat_syscall_dispatch) {
- group->event_notifier_compat_syscall_dispatch =
- kzalloc(sizeof(struct hlist_head) * ARRAY_SIZE(compat_sc_table),
- GFP_KERNEL);
- if (!group->event_notifier_syscall_dispatch)
- return -ENOMEM;
-
- /* Initialize all list_head */
- for (i = 0; i < ARRAY_SIZE(compat_sc_table); i++)
- INIT_HLIST_HEAD(&group->event_notifier_compat_syscall_dispatch[i]);
-
- /* Init the unknown syscall notifier list. */
- INIT_HLIST_HEAD(&group->event_notifier_compat_unknown_syscall_dispatch);
- }
-
- if (!group->event_notifier_exit_compat_syscall_dispatch) {
- group->event_notifier_exit_compat_syscall_dispatch =
- kzalloc(sizeof(struct hlist_head) * ARRAY_SIZE(compat_sc_exit_table),
- GFP_KERNEL);
- if (!group->event_notifier_exit_syscall_dispatch)
- return -ENOMEM;
-
- /* Initialize all list_head */
- for (i = 0; i < ARRAY_SIZE(compat_sc_exit_table); i++)
- INIT_HLIST_HEAD(&group->event_notifier_exit_compat_syscall_dispatch[i]);
-
- /* Init the unknown exit syscall notifier list. */
- INIT_HLIST_HEAD(&group->event_notifier_exit_compat_unknown_syscall_dispatch);
- }
-#endif
-
- if (!group->sc_filter) {
- group->sc_filter = kzalloc(sizeof(struct lttng_syscall_filter),
- GFP_KERNEL);
- if (!group->sc_filter)
- return -ENOMEM;
- }
-
- if (!group->sys_enter_registered) {
- ret = lttng_wrapper_tracepoint_probe_register("sys_enter",
- (void *) syscall_entry_event_notifier_probe, group);
- if (ret)
- return ret;
- group->sys_enter_registered = 1;
- }
-
- if (!group->sys_exit_registered) {
- ret = lttng_wrapper_tracepoint_probe_register("sys_exit",
- (void *) syscall_exit_event_notifier_probe, group);
- if (ret) {
- WARN_ON_ONCE(lttng_wrapper_tracepoint_probe_unregister("sys_enter",
- (void *) syscall_entry_event_notifier_probe, group));
- return ret;
- }
- group->sys_exit_registered = 1;
- }
-
- return ret;
+ 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
-int create_unknown_event_notifier(
- struct lttng_event_notifier_enabler *event_notifier_enabler,
- enum sc_type type)
+void create_unknown_syscall_event(struct lttng_event_enabler_common *event_enabler, enum sc_type type)
{
- struct lttng_event_notifier *notifier;
- const struct lttng_event_desc *desc;
- struct lttng_event_notifier_group *group = event_notifier_enabler->group;
- struct lttng_kernel_event_notifier event_notifier_param;
- uint64_t user_token = event_notifier_enabler->base.user_token;
- uint64_t error_counter_index = event_notifier_enabler->error_counter_index;
- struct lttng_enabler *base_enabler = lttng_event_notifier_enabler_as_enabler(
- event_notifier_enabler);
+ struct lttng_kernel_syscall_table *syscall_table = get_syscall_table_from_enabler(event_enabler);
+ struct lttng_event_ht *events_ht = lttng_get_event_ht_from_enabler(event_enabler);
+ struct lttng_kernel_event_common_private *event_priv;
+ const struct lttng_kernel_event_desc *desc;
struct hlist_head *unknown_dispatch_list;
- int ret = 0;
bool found = false;
- enum lttng_kernel_syscall_abi abi;
- enum lttng_kernel_syscall_entryexit entryexit;
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;
- unknown_dispatch_list = &group->event_notifier_unknown_syscall_dispatch;
- entryexit = LTTNG_KERNEL_SYSCALL_ENTRY;
- abi = LTTNG_KERNEL_SYSCALL_ABI_NATIVE;
+ unknown_dispatch_list = &syscall_table->unknown_syscall_dispatch;
break;
case SC_TYPE_EXIT:
desc = &__event_desc___syscall_exit_unknown;
- unknown_dispatch_list = &group->event_notifier_exit_unknown_syscall_dispatch;
- entryexit = LTTNG_KERNEL_SYSCALL_EXIT;
- abi = LTTNG_KERNEL_SYSCALL_ABI_NATIVE;
+ unknown_dispatch_list = &syscall_table->unknown_syscall_exit_dispatch;
break;
case SC_TYPE_COMPAT_ENTRY:
desc = &__event_desc___compat_syscall_entry_unknown;
- unknown_dispatch_list = &group->event_notifier_compat_unknown_syscall_dispatch;
- entryexit = LTTNG_KERNEL_SYSCALL_ENTRY;
- abi = LTTNG_KERNEL_SYSCALL_ABI_COMPAT;
+ unknown_dispatch_list = &syscall_table->compat_unknown_syscall_dispatch;
break;
case SC_TYPE_COMPAT_EXIT:
desc = &__event_desc___compat_syscall_exit_unknown;
- unknown_dispatch_list = &group->event_notifier_exit_compat_unknown_syscall_dispatch;
- entryexit = LTTNG_KERNEL_SYSCALL_EXIT;
- abi = LTTNG_KERNEL_SYSCALL_ABI_COMPAT;
+ unknown_dispatch_list = &syscall_table->compat_unknown_syscall_exit_dispatch;
break;
default:
- BUG_ON(1);
+ WARN_ON_ONCE(1);
}
/*
* Check if already created.
*/
- head = utils_borrow_hash_table_bucket(group->event_notifiers_ht.table,
- LTTNG_EVENT_NOTIFIER_HT_SIZE, desc->name);
- lttng_hlist_for_each_entry(notifier, head, hlist) {
- if (notifier->desc == desc &&
- notifier->user_token == base_enabler->user_token)
+ head = utils_borrow_hash_table_bucket(events_ht->table, LTTNG_EVENT_HT_SIZE, desc->event_name);
+ lttng_hlist_for_each_entry(event_priv, head, hlist_node) {
+ if (lttng_event_enabler_desc_match_event(event_enabler, desc, event_priv->pub))
found = true;
}
- if (found)
- goto end;
-
- memset(&event_notifier_param, 0, sizeof(event_notifier_param));
- strncat(event_notifier_param.event.name, desc->name,
- LTTNG_KERNEL_SYM_NAME_LEN - strlen(event_notifier_param.event.name) - 1);
-
- event_notifier_param.event.name[LTTNG_KERNEL_SYM_NAME_LEN - 1] = '\0';
-
- event_notifier_param.event.instrumentation = LTTNG_KERNEL_SYSCALL;
- event_notifier_param.event.u.syscall.abi = abi;
- event_notifier_param.event.u.syscall.entryexit = entryexit;
-
- notifier = _lttng_event_notifier_create(desc, user_token,
- error_counter_index, group, &event_notifier_param, NULL,
- event_notifier_param.event.instrumentation);
- if (IS_ERR(notifier)) {
- printk(KERN_INFO "Unable to create unknown notifier %s\n",
- desc->name);
- ret = -ENOMEM;
- goto end;
- }
-
- hlist_add_head_rcu(¬ifier->u.syscall.node, unknown_dispatch_list);
-
-end:
- return ret;
+ if (!found)
+ lttng_syscall_event_enabler_create_event(event_enabler, desc, unknown_dispatch_list, type, -1U);
}
-static int create_matching_event_notifiers(
- struct lttng_event_notifier_enabler *event_notifier_enabler,
- void *filter, const struct trace_syscall_entry *table,
- size_t table_len, enum sc_type type)
+static
+int lttng_syscalls_populate_events(struct lttng_event_enabler_common *syscall_event_enabler)
{
- struct lttng_event_notifier_group *group = event_notifier_enabler->group;
- const struct lttng_event_desc *desc;
- uint64_t user_token = event_notifier_enabler->base.user_token;
- uint64_t error_counter_index = event_notifier_enabler->error_counter_index;
- unsigned int i;
- int ret = 0;
-
- /* iterate over all syscall and create event_notifier that match */
- for (i = 0; i < table_len; i++) {
- struct lttng_event_notifier *event_notifier;
- struct lttng_kernel_event_notifier event_notifier_param;
- struct hlist_head *head;
- int found = 0;
+ struct lttng_event_recorder_enabler *event_recorder_enabler;
+ struct lttng_kernel_channel_buffer *chan;
+ int ret;
- desc = table[i].desc;
- if (!desc) {
- /* Unknown syscall */
- continue;
- }
+ 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;
- if (!lttng_desc_match_enabler(desc,
- lttng_event_notifier_enabler_as_enabler(event_notifier_enabler)))
- continue;
+ lttng_syscall_event_enabler_create_matching_events(&event_recorder_enabler->parent, sc_table.table, sc_table.len, SC_TYPE_ENTRY);
+ lttng_syscall_event_enabler_create_matching_events(&event_recorder_enabler->parent, sc_exit_table.table, sc_exit_table.len, SC_TYPE_EXIT);
+ create_unknown_syscall_event(syscall_event_enabler, SC_TYPE_ENTRY);
+ create_unknown_syscall_event(syscall_event_enabler, SC_TYPE_EXIT);
- /*
- * Check if already created.
- */
- head = utils_borrow_hash_table_bucket(group->event_notifiers_ht.table,
- LTTNG_EVENT_NOTIFIER_HT_SIZE, desc->name);
- lttng_hlist_for_each_entry(event_notifier, head, hlist) {
- if (event_notifier->desc == desc
- && event_notifier->user_token == event_notifier_enabler->base.user_token)
- found = 1;
- }
- if (found)
- continue;
+ lttng_syscall_event_enabler_create_matching_events(&event_recorder_enabler->parent, compat_sc_table.table, compat_sc_table.len, 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, 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);
- memset(&event_notifier_param, 0, sizeof(event_notifier_param));
- switch (type) {
- case SC_TYPE_ENTRY:
- event_notifier_param.event.u.syscall.entryexit = LTTNG_KERNEL_SYSCALL_ENTRY;
- event_notifier_param.event.u.syscall.abi = LTTNG_KERNEL_SYSCALL_ABI_NATIVE;
- break;
- case SC_TYPE_EXIT:
- event_notifier_param.event.u.syscall.entryexit = LTTNG_KERNEL_SYSCALL_EXIT;
- event_notifier_param.event.u.syscall.abi = LTTNG_KERNEL_SYSCALL_ABI_NATIVE;
- break;
- case SC_TYPE_COMPAT_ENTRY:
- event_notifier_param.event.u.syscall.entryexit = LTTNG_KERNEL_SYSCALL_ENTRY;
- event_notifier_param.event.u.syscall.abi = LTTNG_KERNEL_SYSCALL_ABI_COMPAT;
- break;
- case SC_TYPE_COMPAT_EXIT:
- event_notifier_param.event.u.syscall.entryexit = LTTNG_KERNEL_SYSCALL_EXIT;
- event_notifier_param.event.u.syscall.abi = LTTNG_KERNEL_SYSCALL_ABI_COMPAT;
- break;
- }
- strncat(event_notifier_param.event.name, desc->name,
- LTTNG_KERNEL_SYM_NAME_LEN - strlen(event_notifier_param.event.name) - 1);
- event_notifier_param.event.name[LTTNG_KERNEL_SYM_NAME_LEN - 1] = '\0';
- event_notifier_param.event.instrumentation = LTTNG_KERNEL_SYSCALL;
-
- event_notifier = _lttng_event_notifier_create(desc, user_token,
- error_counter_index, group, &event_notifier_param,
- filter, event_notifier_param.event.instrumentation);
- if (IS_ERR(event_notifier)) {
- printk(KERN_INFO "Unable to create event_notifier %s\n",
- desc->name);
- ret = -ENOMEM;
- goto end;
- }
-
- event_notifier->u.syscall.syscall_id = i;
- }
-
-end:
return ret;
-
}
-int lttng_syscals_create_matching_event_notifiers(
- struct lttng_event_notifier_enabler *event_notifier_enabler,
- void *filter)
+/*
+ * Should be called with sessions lock held.
+ */
+int lttng_event_enabler_create_syscall_events_if_missing(struct lttng_event_enabler_common *syscall_event_enabler)
{
+ struct lttng_kernel_syscall_table *syscall_table = get_syscall_table_from_enabler(syscall_event_enabler);
int ret;
- struct lttng_enabler *base_enabler =
- lttng_event_notifier_enabler_as_enabler(event_notifier_enabler);
- enum lttng_kernel_syscall_entryexit entryexit =
- base_enabler->event_param.u.syscall.entryexit;
-
- if (entryexit == LTTNG_KERNEL_SYSCALL_ENTRY || entryexit == LTTNG_KERNEL_SYSCALL_ENTRYEXIT) {
- ret = create_matching_event_notifiers(event_notifier_enabler,
- filter, sc_table, ARRAY_SIZE(sc_table), SC_TYPE_ENTRY);
- if (ret)
- goto end;
-
- ret = create_matching_event_notifiers(event_notifier_enabler,
- filter, compat_sc_table, ARRAY_SIZE(compat_sc_table),
- SC_TYPE_COMPAT_ENTRY);
- if (ret)
- goto end;
- ret = create_unknown_event_notifier(event_notifier_enabler,
- SC_TYPE_ENTRY);
- if (ret)
- goto end;
+ if (!syscall_table->syscall_dispatch) {
+ /* create syscall table mapping syscall to events */
+ syscall_table->syscall_dispatch = kzalloc(sizeof(struct hlist_head) * sc_table.len, GFP_KERNEL);
+ if (!syscall_table->syscall_dispatch)
+ return -ENOMEM;
+ }
+ if (!syscall_table->syscall_exit_dispatch) {
+ /* create syscall table mapping syscall to events */
+ syscall_table->syscall_exit_dispatch = kzalloc(sizeof(struct hlist_head) * sc_exit_table.len, GFP_KERNEL);
+ if (!syscall_table->syscall_exit_dispatch)
+ return -ENOMEM;
+ }
- ret = create_unknown_event_notifier(event_notifier_enabler,
- SC_TYPE_COMPAT_ENTRY);
- if (ret)
- goto end;
+#ifdef CONFIG_COMPAT
+ if (!syscall_table->compat_syscall_dispatch) {
+ /* create syscall table mapping compat syscall to events */
+ syscall_table->compat_syscall_dispatch = kzalloc(sizeof(struct hlist_head) * compat_sc_table.len, GFP_KERNEL);
+ if (!syscall_table->compat_syscall_dispatch)
+ return -ENOMEM;
}
- if (entryexit == LTTNG_KERNEL_SYSCALL_EXIT || entryexit == LTTNG_KERNEL_SYSCALL_ENTRYEXIT) {
- ret = create_matching_event_notifiers(event_notifier_enabler,
- filter, sc_exit_table, ARRAY_SIZE(sc_exit_table),
- SC_TYPE_EXIT);
- if (ret)
- goto end;
+ if (!syscall_table->compat_syscall_exit_dispatch) {
+ /* create syscall table mapping compat syscall to events */
+ syscall_table->compat_syscall_exit_dispatch = kzalloc(sizeof(struct hlist_head) * compat_sc_exit_table.len, GFP_KERNEL);
+ if (!syscall_table->compat_syscall_exit_dispatch)
+ return -ENOMEM;
+ }
+#endif
+ if (!syscall_table->sc_filter) {
+ syscall_table->sc_filter = kzalloc(sizeof(struct lttng_syscall_filter),
+ GFP_KERNEL);
+ if (!syscall_table->sc_filter)
+ return -ENOMEM;
+ }
- ret = create_unknown_event_notifier(event_notifier_enabler,
- SC_TYPE_EXIT);
- if (ret)
- goto end;
+ ret = lttng_syscalls_populate_events(syscall_event_enabler);
+ if (ret)
+ return ret;
- ret = create_matching_event_notifiers(event_notifier_enabler,
- filter, compat_sc_exit_table, ARRAY_SIZE(compat_sc_exit_table),
- SC_TYPE_COMPAT_EXIT);
- if (ret)
- goto end;
+ ret = lttng_syscalls_create_matching_event_notifiers(syscall_event_enabler);
+ if (ret)
+ return ret;
- ret = create_unknown_event_notifier(event_notifier_enabler,
- SC_TYPE_COMPAT_EXIT);
+ if (!syscall_table->sys_enter_registered) {
+ ret = lttng_wrapper_tracepoint_probe_register("sys_enter",
+ (void *) syscall_entry_event_probe, syscall_table);
if (ret)
- goto end;
+ return ret;
+ syscall_table->sys_enter_registered = 1;
+ }
+ if (!syscall_table->sys_exit_registered) {
+ ret = lttng_wrapper_tracepoint_probe_register("sys_exit",
+ (void *) syscall_exit_event_probe, syscall_table);
+ if (ret) {
+ WARN_ON_ONCE(lttng_wrapper_tracepoint_probe_unregister("sys_enter",
+ (void *) syscall_entry_event_probe, syscall_table));
+ return ret;
+ }
+ syscall_table->sys_exit_registered = 1;
}
-end:
return ret;
}
-/*
- * Unregister the syscall event_notifier probes from the callsites.
- */
-int lttng_syscalls_unregister_event_notifier_group(
- struct lttng_event_notifier_group *event_notifier_group)
+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;
- /*
- * Only register the event_notifier probe on the `sys_enter` callsite for now.
- * At the moment, we don't think it's desirable to have one fired
- * event_notifier for the entry and one for the exit of a syscall.
- */
- if (event_notifier_group->sys_enter_registered) {
- ret = lttng_wrapper_tracepoint_probe_unregister("sys_enter",
- (void *) syscall_entry_event_notifier_probe, event_notifier_group);
- if (ret)
- return ret;
- event_notifier_group->sys_enter_registered = 0;
- }
- if (event_notifier_group->sys_exit_registered) {
- ret = lttng_wrapper_tracepoint_probe_unregister("sys_exit",
- (void *) syscall_exit_event_notifier_probe, event_notifier_group);
- if (ret)
- return ret;
- event_notifier_group->sys_enter_registered = 0;
+ 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);
+
+ 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, SC_TYPE_ENTRY);
+ lttng_syscall_event_enabler_create_matching_events(&event_notifier_enabler->parent,
+ 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);
}
- kfree(event_notifier_group->event_notifier_syscall_dispatch);
- kfree(event_notifier_group->event_notifier_exit_syscall_dispatch);
-#ifdef CONFIG_COMPAT
- kfree(event_notifier_group->event_notifier_compat_syscall_dispatch);
- kfree(event_notifier_group->event_notifier_exit_compat_syscall_dispatch);
-#endif
- return 0;
+ 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, SC_TYPE_EXIT);
+ lttng_syscall_event_enabler_create_matching_events(&event_notifier_enabler->parent,
+ 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 ret;
}
-int lttng_syscalls_unregister_channel(struct lttng_channel *chan)
+int lttng_syscalls_unregister_syscall_table(struct lttng_kernel_syscall_table *syscall_table)
{
int ret;
- if (!chan->sc_table)
+ if (!syscall_table->syscall_dispatch)
return 0;
- if (chan->sys_enter_registered) {
+ if (syscall_table->sys_enter_registered) {
ret = lttng_wrapper_tracepoint_probe_unregister("sys_enter",
- (void *) syscall_entry_event_probe, chan);
+ (void *) syscall_entry_event_probe, syscall_table);
if (ret)
return ret;
- chan->sys_enter_registered = 0;
+ syscall_table->sys_enter_registered = 0;
}
- if (chan->sys_exit_registered) {
+ if (syscall_table->sys_exit_registered) {
ret = lttng_wrapper_tracepoint_probe_unregister("sys_exit",
- (void *) syscall_exit_event_probe, chan);
+ (void *) syscall_exit_event_probe, syscall_table);
if (ret)
return ret;
- chan->sys_exit_registered = 0;
+ syscall_table->sys_exit_registered = 0;
}
return 0;
}
-int lttng_syscalls_destroy_event(struct lttng_channel *chan)
+int lttng_syscalls_destroy_syscall_table(struct lttng_kernel_syscall_table *syscall_table)
{
- kfree(chan->sc_table);
- kfree(chan->sc_exit_table);
+ kfree(syscall_table->syscall_dispatch);
+ kfree(syscall_table->syscall_exit_dispatch);
#ifdef CONFIG_COMPAT
- kfree(chan->compat_sc_table);
- kfree(chan->compat_sc_exit_table);
+ kfree(syscall_table->compat_syscall_dispatch);
+ kfree(syscall_table->compat_syscall_exit_dispatch);
#endif
- kfree(chan->sc_filter);
+ kfree(syscall_table->sc_filter);
return 0;
}
int syscall_nr = -1;
int i;
- for (i = 0; i < ARRAY_SIZE(sc_table); i++) {
+ for (i = 0; i < sc_table.len; i++) {
const struct trace_syscall_entry *entry;
const char *it_name;
- entry = &sc_table[i];
+ entry = &sc_table.table[i];
if (!entry->desc)
continue;
- it_name = entry->desc->name;
+ it_name = entry->desc->event_name;
it_name += strlen(SYSCALL_ENTRY_STR);
if (!strcmp(syscall_name, it_name)) {
syscall_nr = i;
int syscall_nr = -1;
int i;
- for (i = 0; i < ARRAY_SIZE(compat_sc_table); i++) {
+ for (i = 0; i < compat_sc_table.len; i++) {
const struct trace_syscall_entry *entry;
const char *it_name;
- entry = &compat_sc_table[i];
+ entry = &compat_sc_table.table[i];
if (!entry->desc)
continue;
- it_name = entry->desc->name;
+ it_name = entry->desc->event_name;
it_name += strlen(COMPAT_SYSCALL_ENTRY_STR);
if (!strcmp(syscall_name, it_name)) {
syscall_nr = i;
static
uint32_t get_sc_tables_len(void)
{
- return ARRAY_SIZE(sc_table) + ARRAY_SIZE(compat_sc_table);
+ return sc_table.len + compat_sc_table.len;
}
static
return 0;
}
-int lttng_syscall_filter_enable_event_notifier(
- struct lttng_event_notifier *notifier)
+int lttng_syscall_filter_enable_event(struct lttng_kernel_event_common *event)
{
- struct lttng_event_notifier_group *group = notifier->group;
- unsigned int syscall_id = notifier->u.syscall.syscall_id;
+ 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 = 0;
+ int ret;
- WARN_ON_ONCE(notifier->instrumentation != LTTNG_KERNEL_SYSCALL);
+ WARN_ON_ONCE(event->priv->instrumentation != LTTNG_KERNEL_ABI_SYSCALL);
- ret = lttng_syscall_filter_enable(group->sc_filter,
- notifier->desc->name, notifier->u.syscall.abi,
- notifier->u.syscall.entryexit);
- if (ret) {
- goto end;
- }
+ ret = lttng_syscall_filter_enable(syscall_table->sc_filter,
+ event->priv->desc->event_name, event->priv->u.syscall.abi,
+ event->priv->u.syscall.entryexit);
+ if (ret)
+ return ret;
- switch (notifier->u.syscall.entryexit) {
+ switch (event->priv->u.syscall.entryexit) {
case LTTNG_SYSCALL_ENTRY:
- switch (notifier->u.syscall.abi) {
+ switch (event->priv->u.syscall.abi) {
case LTTNG_SYSCALL_ABI_NATIVE:
- dispatch_list = &group->event_notifier_syscall_dispatch[syscall_id];
+ dispatch_list = &syscall_table->syscall_dispatch[syscall_id];
break;
case LTTNG_SYSCALL_ABI_COMPAT:
- dispatch_list = &group->event_notifier_compat_syscall_dispatch[syscall_id];
+ dispatch_list = &syscall_table->compat_syscall_dispatch[syscall_id];
break;
+ default:
+ ret = -EINVAL;
+ goto end;
}
break;
case LTTNG_SYSCALL_EXIT:
- switch (notifier->u.syscall.abi) {
+ switch (event->priv->u.syscall.abi) {
case LTTNG_SYSCALL_ABI_NATIVE:
- dispatch_list = &group->event_notifier_exit_syscall_dispatch[syscall_id];
+ dispatch_list = &syscall_table->syscall_exit_dispatch[syscall_id];
break;
case LTTNG_SYSCALL_ABI_COMPAT:
- dispatch_list = &group->event_notifier_exit_compat_syscall_dispatch[syscall_id];
+ dispatch_list = &syscall_table->compat_syscall_exit_dispatch[syscall_id];
break;
+ default:
+ ret = -EINVAL;
+ goto end;
}
break;
+ default:
+ ret = -EINVAL;
+ goto end;
}
- hlist_add_head_rcu(¬ifier->u.syscall.node, dispatch_list);
-
+ hlist_add_head_rcu(&event->priv->u.syscall.node, dispatch_list);
end:
- return ret ;
-}
-
-int lttng_syscall_filter_enable_event(
- struct lttng_channel *channel,
- struct lttng_event *event)
-{
- WARN_ON_ONCE(event->instrumentation != LTTNG_KERNEL_SYSCALL);
-
- return lttng_syscall_filter_enable(channel->sc_filter,
- event->desc->name, event->u.syscall.abi,
- event->u.syscall.entryexit);
+ return ret;
}
static
-int lttng_syscall_filter_disable(
- struct lttng_syscall_filter *filter,
+int lttng_syscall_filter_disable(struct lttng_syscall_filter *filter,
const char *desc_name, enum lttng_syscall_abi abi,
enum lttng_syscall_entryexit entryexit)
{
return 0;
}
-int lttng_syscall_filter_disable_event_notifier(
- struct lttng_event_notifier *notifier)
+int lttng_syscall_filter_disable_event(struct lttng_kernel_event_common *event)
{
- struct lttng_event_notifier_group *group = notifier->group;
+ struct lttng_kernel_syscall_table *syscall_table = get_syscall_table_from_event(event);
int ret;
- WARN_ON_ONCE(notifier->instrumentation != LTTNG_KERNEL_SYSCALL);
-
- ret = lttng_syscall_filter_disable(group->sc_filter,
- notifier->desc->name, notifier->u.syscall.abi,
- notifier->u.syscall.entryexit);
- WARN_ON_ONCE(ret != 0);
-
- hlist_del_rcu(¬ifier->u.syscall.node);
+ ret = lttng_syscall_filter_disable(syscall_table->sc_filter,
+ event->priv->desc->event_name, event->priv->u.syscall.abi,
+ event->priv->u.syscall.entryexit);
+ if (ret)
+ return ret;
+ hlist_del_rcu(&event->priv->u.syscall.node);
return 0;
}
-int lttng_syscall_filter_disable_event(
- struct lttng_channel *channel,
- struct lttng_event *event)
+void lttng_syscall_table_set_wildcard_all(struct lttng_event_enabler_common *event_enabler)
{
- return lttng_syscall_filter_disable(channel->sc_filter,
- event->desc->name, event->u.syscall.abi,
- event->u.syscall.entryexit);
+ struct lttng_kernel_syscall_table *syscall_table = get_syscall_table_from_enabler(event_enabler);
+ enum lttng_kernel_abi_syscall_entryexit entryexit;
+ int enabled = event_enabler->enabled;
+
+ if (!lttng_syscall_event_enabler_is_wildcard_all(event_enabler))
+ 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);
+
+ if (entryexit == LTTNG_KERNEL_ABI_SYSCALL_EXIT || entryexit == LTTNG_KERNEL_ABI_SYSCALL_ENTRYEXIT)
+ WRITE_ONCE(syscall_table->syscall_all_exit, enabled);
}
static
const struct trace_syscall_entry *entry;
int iter = 0;
- for (entry = sc_table;
- entry < sc_table + ARRAY_SIZE(sc_table);
+ for (entry = sc_table.table;
+ entry < sc_table.table + sc_table.len;
entry++) {
if (iter++ >= *pos)
return entry;
}
- for (entry = compat_sc_table;
- entry < compat_sc_table + ARRAY_SIZE(compat_sc_table);
+ for (entry = compat_sc_table.table;
+ entry < compat_sc_table.table + compat_sc_table.len;
entry++) {
if (iter++ >= *pos)
return entry;
const struct trace_syscall_entry **table,
unsigned int *bitness)
{
- if (entry >= sc_table && entry < sc_table + ARRAY_SIZE(sc_table)) {
+ if (entry >= sc_table.table && entry < sc_table.table + sc_table.len) {
if (bitness)
*bitness = BITS_PER_LONG;
if (table)
- *table = sc_table;
+ *table = sc_table.table;
return 0;
}
- if (!(entry >= compat_sc_table
- && entry < compat_sc_table + ARRAY_SIZE(compat_sc_table))) {
+ if (!(entry >= compat_sc_table.table
+ && entry < compat_sc_table.table + compat_sc_table.len)) {
return -EINVAL;
}
if (bitness)
*bitness = 32;
if (table)
- *table = compat_sc_table;
+ *table = compat_sc_table.table;
return 0;
}
return ret;
if (!entry->desc)
return 0;
- if (table == sc_table) {
+ if (table == sc_table.table) {
index = entry - table;
- name = &entry->desc->name[strlen(SYSCALL_ENTRY_STR)];
+ name = &entry->desc->event_name[strlen(SYSCALL_ENTRY_STR)];
} else {
- index = (entry - table) + ARRAY_SIZE(sc_table);
- name = &entry->desc->name[strlen(COMPAT_SYSCALL_ENTRY_STR)];
+ index = (entry - table) + sc_table.len;
+ name = &entry->desc->event_name[strlen(COMPAT_SYSCALL_ENTRY_STR)];
}
seq_printf(m, "syscall { index = %lu; name = %s; bitness = %u; };\n",
index, name, bitness);
/*
* A syscall is enabled if it is traced for either entry or exit.
*/
-long lttng_channel_syscall_mask(struct lttng_channel *channel,
- struct lttng_kernel_syscall_mask __user *usyscall_mask)
+long lttng_syscall_table_get_active_mask(struct lttng_kernel_syscall_table *syscall_table,
+ struct lttng_kernel_abi_syscall_mask __user *usyscall_mask)
{
uint32_t len, sc_tables_len, bitmask_len;
int ret = 0, bit;
tmp_mask = kzalloc(bitmask_len, GFP_KERNEL);
if (!tmp_mask)
return -ENOMEM;
- filter = channel->sc_filter;
+ filter = syscall_table->sc_filter;
- for (bit = 0; bit < ARRAY_SIZE(sc_table); bit++) {
+ for (bit = 0; bit < sc_table.len; bit++) {
char state;
- if (channel->sc_table) {
- if (!(READ_ONCE(channel->syscall_all_entry)
- || READ_ONCE(channel->syscall_all_exit)) && filter)
+ if (syscall_table->syscall_dispatch) {
+ if (!(READ_ONCE(syscall_table->syscall_all_entry)
+ || READ_ONCE(syscall_table->syscall_all_exit)) && filter)
state = test_bit(bit, filter->sc_entry)
|| test_bit(bit, filter->sc_exit);
else
for (; bit < sc_tables_len; bit++) {
char state;
- if (channel->compat_sc_table) {
- if (!(READ_ONCE(channel->syscall_all_entry)
- || READ_ONCE(channel->syscall_all_exit)) && filter)
- state = test_bit(bit - ARRAY_SIZE(sc_table),
+ if (syscall_table->compat_syscall_dispatch) {
+ if (!(READ_ONCE(syscall_table->syscall_all_entry)
+ || READ_ONCE(syscall_table->syscall_all_exit)) && filter)
+ state = test_bit(bit - sc_table.len,
filter->sc_compat_entry)
- || test_bit(bit - ARRAY_SIZE(sc_table),
+ || test_bit(bit - sc_table.len,
filter->sc_compat_exit);
else
state = 1;