lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4AA4C09E.4050704@cn.fujitsu.com>
Date:	Mon, 07 Sep 2009 16:13:18 +0800
From:	Li Zefan <lizf@...fujitsu.com>
To:	Ingo Molnar <mingo@...e.hu>
CC:	Peter Zijlstra <peterz@...radead.org>,
	Steven Rostedt <rostedt@...dmis.org>,
	Frederic Weisbecker <fweisbec@...il.com>,
	Tom Zanussi <tzanussi@...il.com>,
	Jason Baron <jbaron@...hat.com>,
	LKML <linux-kernel@...r.kernel.org>
Subject: [PATCH 3/6] tracing/syscalls: Add profile filter support

This makes syscall profile events filter-able.

Signed-off-by: Li Zefan <lizf@...fujitsu.com>
---
 include/linux/syscalls.h      |   14 ++++++++++----
 kernel/trace/trace_syscalls.c |    9 +++++++--
 2 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index a8e3782..510d941 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -103,30 +103,36 @@ struct perf_counter_attr;
 static int prof_sysenter_enable_##sname(struct ftrace_event_call *event_call)  \
 {									       \
 	int ret = 0;							       \
-	if (!atomic_inc_return(&event_enter_##sname.profile_count))	       \
+	if (!atomic_inc_return(&event_call->profile_count))		       \
 		ret = reg_prof_syscall_enter("sys"#sname);		       \
 	return ret;							       \
 }									       \
 									       \
 static void prof_sysenter_disable_##sname(struct ftrace_event_call *event_call)\
 {									       \
-	if (atomic_add_negative(-1, &event_enter_##sname.profile_count))       \
+	if (atomic_add_negative(-1, &event_call->profile_count)) {	       \
 		unreg_prof_syscall_enter("sys"#sname);			       \
+		tracepoint_synchronize_unregister();			       \
+		destroy_profile_preds(event_call);			       \
+	}								       \
 }
 
 #define TRACE_SYS_EXIT_PROFILE(sname)					       \
 static int prof_sysexit_enable_##sname(struct ftrace_event_call *event_call)   \
 {									       \
 	int ret = 0;							       \
-	if (!atomic_inc_return(&event_exit_##sname.profile_count))	       \
+	if (!atomic_inc_return(&event_call->profile_count))		       \
 		ret = reg_prof_syscall_exit("sys"#sname);		       \
 	return ret;							       \
 }									       \
 									       \
 static void prof_sysexit_disable_##sname(struct ftrace_event_call *event_call) \
 {                                                                              \
-	if (atomic_add_negative(-1, &event_exit_##sname.profile_count))	       \
+	if (atomic_add_negative(-1, &event_call->profile_count)) {	       \
 		unreg_prof_syscall_exit("sys"#sname);			       \
+		tracepoint_synchronize_unregister();			       \
+		destroy_profile_preds(event_call);			       \
+	}								       \
 }
 
 #define TRACE_SYS_ENTER_PROFILE_INIT(sname)				       \
diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c
index 8712ce3..c2faf98 100644
--- a/kernel/trace/trace_syscalls.c
+++ b/kernel/trace/trace_syscalls.c
@@ -414,7 +414,10 @@ static void prof_syscall_enter(struct pt_regs *regs, long id)
 		rec->nr = syscall_nr;
 		syscall_get_arguments(current, regs, 0, sys_data->nb_args,
 				       (unsigned long *)&rec->args);
-		perf_tpcounter_event(sys_data->enter_id, 0, 1, rec, size);
+
+		if (profile_filter_check(sys_data->enter_event, &rec))
+			perf_tpcounter_event(sys_data->enter_id, 0, 1,
+					     rec, size);
 	} while(0);
 }
 
@@ -476,7 +479,9 @@ static void prof_syscall_exit(struct pt_regs *regs, long ret)
 	rec.nr = syscall_nr;
 	rec.ret = syscall_get_return_value(current, regs);
 
-	perf_tpcounter_event(sys_data->exit_id, 0, 1, &rec, sizeof(rec));
+	if (profile_filter_check(sys_data->exit_event, &rec))
+		perf_tpcounter_event(sys_data->exit_id, 0, 1,
+				     &rec, sizeof(rec));
 }
 
 int reg_prof_syscall_exit(char *name)
-- 
1.6.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ