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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20170604040350.12641-5-joelaf@google.com>
Date:   Sat,  3 Jun 2017 21:03:50 -0700
From:   Joel Fernandes <joelaf@...gle.com>
To:     linux-kernel@...r.kernel.org
Cc:     Joel Fernandes <joelaf@...gle.com>, kernel-team@...roid.com,
        Steven Rostedt <rostedt@...dmis.org>,
        Ingo Molnar <mingo@...hat.com>
Subject: [RFC v2 4/4] tracing/ftrace: Add support to record and display tgid

Make function tracer able to record tgid if/when record-tgid is enabled.

Cc: kernel-team@...roid.com
Cc: Steven Rostedt <rostedt@...dmis.org>
Cc: Ingo Molnar <mingo@...hat.com> 
Signed-off-by: Joel Fernandes <joelaf@...gle.com>
---
 kernel/trace/trace_functions.c | 23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)

diff --git a/kernel/trace/trace_functions.c b/kernel/trace/trace_functions.c
index 05da1e7513f6..290a7a80abf2 100644
--- a/kernel/trace/trace_functions.c
+++ b/kernel/trace/trace_functions.c
@@ -27,6 +27,7 @@ static void
 function_stack_trace_call(unsigned long ip, unsigned long parent_ip,
 			  struct ftrace_ops *op, struct pt_regs *pt_regs);
 static struct tracer_flags func_flags;
+static bool tgid_recorded;
 
 /* Our option */
 enum {
@@ -103,7 +104,8 @@ static int function_trace_init(struct trace_array *tr)
 	tr->trace_buffer.cpu = get_cpu();
 	put_cpu();
 
-	tracing_start_taskinfo_record(true, false);
+	tgid_recorded = tr->trace_flags & TRACE_ITER_RECORD_TGID;
+	tracing_start_taskinfo_record(true, tgid_recorded);
 
 	tracing_start_function_trace(tr);
 	return 0;
@@ -112,7 +114,8 @@ static int function_trace_init(struct trace_array *tr)
 static void function_trace_reset(struct trace_array *tr)
 {
 	tracing_stop_function_trace(tr);
-	tracing_stop_taskinfo_record(true, false);
+	tracing_stop_taskinfo_record(true, tgid_recorded);
+	tgid_recorded = false;
 	ftrace_reset_array_ops(tr);
 }
 
@@ -253,6 +256,21 @@ func_set_flag(struct trace_array *tr, u32 old_flags, u32 bit, int set)
 	return 0;
 }
 
+static int
+func_tracer_flag_changed(struct trace_array *tr, unsigned int mask,
+			 int enabled)
+{
+	if (mask == TRACE_ITER_RECORD_TGID) {
+		tgid_recorded = !!enabled;
+		if (enabled)
+			tracing_start_taskinfo_record(false, true);
+		else
+			tracing_stop_taskinfo_record(false, true);
+	}
+
+	return 0;
+}
+
 static struct tracer function_trace __tracer_data =
 {
 	.name		= "function",
@@ -261,6 +279,7 @@ static struct tracer function_trace __tracer_data =
 	.start		= function_trace_start,
 	.flags		= &func_flags,
 	.set_flag	= func_set_flag,
+	.flag_changed	= func_tracer_flag_changed,
 	.allow_instances = true,
 #ifdef CONFIG_FTRACE_SELFTEST
 	.selftest	= trace_selftest_startup_function,
-- 
2.13.0.506.g27d5fe0cd-goog

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ