All of 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: Wed,  2 Feb 2011 18:11:53 +1100	[thread overview]
Message-ID: <1296630718-17537-2-git-send-email-imunsie@au1.ibm.com> (raw)
In-Reply-To: <1296630718-17537-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


WARNING: multiple messages have this Message-ID (diff)
From: "Ian Munsie" <imunsie@au1.ibm.com>
To: linux-kernel@vger.kernel.org
Cc: Andreas Dilger <adilger@dilger.ca>,
	Andreas Schwab <schwab@linux-m68k.org>,
	Dave Kleikamp <shaggy@linux.vnet.ibm.com>,
	Namhyung Kim <namhyung@gmail.com>, Jiri Kosina <jkosina@suse.cz>,
	Jason Baron <jbaron@redhat.com>, Alexander Graf <agraf@suse.de>,
	Steven Rostedt <rostedt@goodmis.org>,
	David Gibson <dwg@au1.ibm.com>, Ingo Molnar <mingo@redhat.com>,
	Paul Mackerras <paulus@samba.org>,
	Ian Munsie <imunsie@au1.ibm.com>,
	KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Scott Wood <scottwood@freescale.com>,
	Nathan Lynch <ntl@pobox.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	linuxppc-dev <linuxppc-dev@lists.ozlabs.org>,
	Avantika Mathur <mathur@linux.vnet.ibm.com>
Subject: [PATCH 1/6] ftrace syscalls: don't add events for unmapped syscalls
Date: Wed,  2 Feb 2011 18:11:53 +1100	[thread overview]
Message-ID: <1296630718-17537-2-git-send-email-imunsie@au1.ibm.com> (raw)
In-Reply-To: <1296630718-17537-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-02  7:12 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` Ian Munsie
2011-02-02  7:11 ` Ian Munsie [this message]
2011-02-02  7:11   ` [PATCH 1/6] ftrace syscalls: don't add events for unmapped syscalls Ian Munsie
2011-02-02  7:11 ` [PATCH 2/6] trace syscalls: Convert redundant syscall_nr checks into WARN_ON Ian Munsie
2011-02-02  7:11   ` Ian Munsie
2011-02-02  7:11 ` [PATCH 3/6] ftrace syscalls: Make arch_syscall_addr weak Ian Munsie
2011-02-02  7:11   ` Ian Munsie
2011-02-02  7:11 ` [PATCH 4/6] ftrace syscalls: Allow arch specific syscall symbol matching Ian Munsie
2011-02-02  7:11   ` Ian Munsie
2011-02-02 14:04   ` Steven Rostedt
2011-02-02 14:04     ` Steven Rostedt
2011-02-02 14:15     ` [PATCH 4/6] ftrace syscalls: Allow arch specific syscallsymbol matching David Laight
2011-02-02 14:15       ` David Laight
2011-02-02 14:28       ` Steven Rostedt
2011-02-02 14:28         ` Steven Rostedt
2011-02-03  0:28     ` [PATCH 4/6] ftrace syscalls: Allow arch specific syscall symbol matching Ian Munsie
2011-02-02  7:11 ` [PATCH 5/6] trace, powerpc: Implement raw syscall tracepoints on PowerPC Ian Munsie
2011-02-02  7:11   ` Ian Munsie
2011-02-02  7:11 ` [PATCH 6/6] trace syscalls: Early terminate search for sys_ni_syscall Ian Munsie
2011-02-02  7:11   ` Ian Munsie
  -- strict thread matches above, loose matches on Subject: below --
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 ` [PATCH 1/6] ftrace syscalls: don't add events for unmapped syscalls Ian Munsie
2011-02-03  3:27   ` 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=1296630718-17537-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 \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.