LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: "Ian Munsie" <imunsie@au1.ibm.com>
To: linux-kernel@vger.kernel.org
Cc: Andreas Dilger <adilger@dilger.ca>,
	Dave Kleikamp <shaggy@linux.vnet.ibm.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Jiri Kosina <jkosina@suse.cz>, Jason Baron <jbaron@redhat.com>,
	linuxppc-dev <linuxppc-dev@lists.ozlabs.org>,
	Steven Rostedt <rostedt@goodmis.org>,
	Alexander Graf <agraf@suse.de>, Ingo Molnar <mingo@redhat.com>,
	Paul Mackerras <paulus@samba.org>,
	KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Scott Wood <scottwood@freescale.com>,
	Nathan Lynch <ntl@pobox.com>,
	Avantika Mathur <mathur@linux.vnet.ibm.com>,
	David Gibson <dwg@au1.ibm.com>,
	Andreas Schwab <schwab@linux-m68k.org>,
	Namhyung Kim <namhyung@gmail.com>,
	Ian Munsie <imunsie@au1.ibm.com>
Subject: [PATCH 1/6] ftrace syscalls: don't add events for unmapped syscalls
Date: Thu,  3 Feb 2011 14:27:20 +1100	[thread overview]
Message-ID: <1296703645-18718-2-git-send-email-imunsie@au1.ibm.com> (raw)
In-Reply-To: <1296703645-18718-1-git-send-email-imunsie@au1.ibm.com>

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>
---
 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 18cd068..2e5a68d 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -160,6 +160,7 @@ extern struct trace_event_functions exit_syscall_print_funcs;
 	  __attribute__((section("__syscalls_metadata")))	\
 	  __syscall_meta_##sname = {				\
 		.name 		= "sys"#sname,			\
+		.syscall_nr	= -1,	/* Filled in at boot */	\
 		.nb_args 	= nb,				\
 		.types		= types_##sname,		\
 		.args		= args_##sname,			\
@@ -176,6 +177,7 @@ extern struct trace_event_functions exit_syscall_print_funcs;
 	  __attribute__((section("__syscalls_metadata")))	\
 	  __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 b706529..a66bc13 100644
--- a/kernel/trace/trace_syscalls.c
+++ b/kernel/trace/trace_syscalls.c
@@ -423,6 +423,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-03  3:27 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-03  3:27 PowerPC, ftrace: Add PPC raw syscall tracepoints & ftrace fixes (mimimal subset only) v4 Ian Munsie
2011-02-03  3:27 ` Ian Munsie [this message]
2011-02-17 14:58   ` [tip:perf/core] tracing/syscalls: Don't add events for unmapped syscalls tip-bot for Ian Munsie
2011-02-03  3:27 ` [PATCH 2/6] ftrace syscalls: Convert redundant syscall_nr checks into WARN_ON Ian Munsie
2011-02-17 14:59   ` [tip:perf/core] tracing/syscalls: " tip-bot for Ian Munsie
2011-02-03  3:27 ` [PATCH 3/6] ftrace syscalls: Make arch_syscall_addr weak Ian Munsie
2011-02-17 14:59   ` [tip:perf/core] tracing/syscalls: " tip-bot for Ian Munsie
2011-02-03  3:27 ` [PATCH 4/6] ftrace syscalls: Allow arch specific syscall symbol matching Ian Munsie
2011-02-17 14:59   ` [tip:perf/core] tracing/syscalls: " tip-bot for Ian Munsie
2011-02-03  3:27 ` [PATCH 5/6] ftrace, powerpc: Implement raw syscall tracepoints on PowerPC Ian Munsie
2011-02-08  2:10   ` Steven Rostedt
2011-02-08 10:07     ` Benjamin Herrenschmidt
2011-02-08 16:54       ` Steven Rostedt
2011-02-03  3:27 ` [PATCH 6/6] ftrace syscalls: Early terminate search for sys_ni_syscall Ian Munsie
2011-02-17 15:00   ` [tip:perf/core] tracing/syscalls: " tip-bot for Ian Munsie
2011-02-08  2:10 ` PowerPC, ftrace: Add PPC raw syscall tracepoints & ftrace fixes (mimimal subset only) v4 Steven Rostedt
  -- strict thread matches above, loose matches on Subject: below --
2011-02-02  7:11 PowerPC, ftrace: Add PPC raw syscall tracepoints & ftrace fixes (mimimal subset only) v3 Ian Munsie
2011-02-02  7:11 ` [PATCH 1/6] ftrace syscalls: don't add events for unmapped syscalls Ian Munsie
     [not found] <1291696151-4336-1-git-send-email-imunsie@au1.ibm.com>
2010-12-07  4:29 ` Ian Munsie

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=1296703645-18718-2-git-send-email-imunsie@au1.ibm.com \
    --to=imunsie@au1.ibm.com \
    --cc=adilger@dilger.ca \
    --cc=agraf@suse.de \
    --cc=akpm@linux-foundation.org \
    --cc=dwg@au1.ibm.com \
    --cc=fweisbec@gmail.com \
    --cc=jbaron@redhat.com \
    --cc=jkosina@suse.cz \
    --cc=kosaki.motohiro@jp.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mathur@linux.vnet.ibm.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@gmail.com \
    --cc=ntl@pobox.com \
    --cc=paulus@samba.org \
    --cc=rostedt@goodmis.org \
    --cc=schwab@linux-m68k.org \
    --cc=scottwood@freescale.com \
    --cc=shaggy@linux.vnet.ibm.com \
    --subject='Re: [PATCH 1/6] ftrace syscalls: don'\''t add events for unmapped syscalls' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).