]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
tracing/syscalls: Don't add events for unmapped syscalls
authorIan Munsie <imunsie@au1.ibm.com>
Thu, 3 Feb 2011 03:27:20 +0000 (14:27 +1100)
committerSteven Rostedt <rostedt@goodmis.org>
Tue, 8 Feb 2011 02:24:44 +0000 (21:24 -0500)
FTRACE_SYSCALLS would create events for each and every system call, even
if it had failed to map the system call's name with it's number. This
resulted in a number of events being created that would not behave as
expected.

This could happen, for example, on architectures who's symbol names are
unusual and will not match the system call name. It could also happen
with system calls which were mapped to sys_ni_syscall.

This patch changes the default system call number in the metadata to -1.
If the system call name from the metadata is not successfully mapped to
a system call number during boot, than the event initialisation routine
will now return an error, preventing the event from being created.

Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
LKML-Reference: <1296703645-18718-2-git-send-email-imunsie@au1.ibm.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
include/linux/syscalls.h
kernel/trace/trace_syscalls.c

index 98664db1be472f42183faba02175c61afe5cb049..8e8968e74544d6864d0ad32c16140f498af101a9 100644 (file)
@@ -158,6 +158,7 @@ extern struct trace_event_functions exit_syscall_print_funcs;
        static struct syscall_metadata __used                   \
          __syscall_meta_##sname = {                            \
                .name           = "sys"#sname,                  \
+               .syscall_nr     = -1,   /* Filled in at boot */ \
                .nb_args        = nb,                           \
                .types          = types_##sname,                \
                .args           = args_##sname,                 \
@@ -175,6 +176,7 @@ extern struct trace_event_functions exit_syscall_print_funcs;
        static struct syscall_metadata __used                   \
          __syscall_meta__##sname = {                           \
                .name           = "sys_"#sname,                 \
+               .syscall_nr     = -1,   /* Filled in at boot */ \
                .nb_args        = 0,                            \
                .enter_event    = &event_enter__##sname,        \
                .exit_event     = &event_exit__##sname,         \
index 5c9fe08d209336e3e0ac1956e56c9a6910a29bfb..a9ceabd52247b2b0b39df6f8d98a3c05c82d6e8c 100644 (file)
@@ -424,6 +424,14 @@ void unreg_event_syscall_exit(struct ftrace_event_call *call)
 int init_syscall_trace(struct ftrace_event_call *call)
 {
        int id;
+       int num;
+
+       num = ((struct syscall_metadata *)call->data)->syscall_nr;
+       if (num < 0 || num >= NR_syscalls) {
+               pr_debug("syscall %s metadata not mapped, disabling ftrace event\n",
+                               ((struct syscall_metadata *)call->data)->name);
+               return -ENOSYS;
+       }
 
        if (set_syscall_print_fmt(call) < 0)
                return -ENOMEM;