public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Ingo Molnar <mingo@elte.hu>,
	Andrew Morton <akpm@linux-foundation.org>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Ian Munsie <imunsie@au1.ibm.com>
Subject: [PATCH 01/10] tracing/syscalls: Dont add events for unmapped syscalls
Date: Tue, 08 Feb 2011 17:16:13 -0500	[thread overview]
Message-ID: <20110208221718.996649974@goodmis.org> (raw)
In-Reply-To: 20110208221612.084294240@goodmis.org

[-- Attachment #1: 0001-tracing-syscalls-Don-t-add-events-for-unmapped-sysca.patch --]
[-- Type: text/plain, Size: 2557 bytes --]

From: Ian Munsie <imunsie@au1.ibm.com>

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      |    2 ++
 kernel/trace/trace_syscalls.c |    8 ++++++++
 2 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index 98664db..8e8968e 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -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,		\
diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c
index 5c9fe08..a9ceabd 100644
--- a/kernel/trace/trace_syscalls.c
+++ b/kernel/trace/trace_syscalls.c
@@ -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;
-- 
1.7.2.3



  reply	other threads:[~2011-02-08 22:17 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-08 22:16 [PATCH 00/10] [GIT PULL][v2.6.39] tracing: updates Steven Rostedt
2011-02-08 22:16 ` Steven Rostedt [this message]
2011-02-08 22:16 ` [PATCH 02/10] tracing/syscalls: Convert redundant syscall_nr checks into WARN_ON Steven Rostedt
2011-02-08 22:16 ` [PATCH 03/10] tracing/syscalls: Make arch_syscall_addr weak Steven Rostedt
2011-02-08 22:16 ` [PATCH 04/10] tracing/syscalls: Allow arch specific syscall symbol matching Steven Rostedt
2011-02-08 22:16 ` [PATCH 05/10] tracing/syscalls: Early terminate search for sys_ni_syscall Steven Rostedt
2011-02-08 22:16 ` [PATCH 06/10] tracing: Add unstable sched clock note to the warning Steven Rostedt
2011-02-08 22:16 ` [PATCH 07/10] trivial: Fix Stevens Copyright typos Steven Rostedt
2011-02-08 22:16 ` [PATCH 08/10] tracing: Compile time initialization for event flags value Steven Rostedt
2011-02-08 22:16 ` [PATCH 09/10] tracing: Remove obsolete sched_switch tracer Steven Rostedt
2011-02-14 19:42   ` Steven Rostedt
2011-02-08 22:16 ` [PATCH 10/10] tracing: Deprecate tracing_enabled for tracing_on Steven Rostedt
2011-02-17 13:50 ` [PATCH 00/10] [GIT PULL][v2.6.39] tracing: updates Ingo Molnar
2011-02-17 14:04   ` Ingo Molnar
2011-02-17 14:55     ` Ingo Molnar
2011-02-17 15:03     ` Steven Rostedt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110208221718.996649974@goodmis.org \
    --to=rostedt@goodmis.org \
    --cc=akpm@linux-foundation.org \
    --cc=fweisbec@gmail.com \
    --cc=imunsie@au1.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox