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: <1460703230-13307-5-git-send-email-hcochran@kernelspring.com>
Date:	Fri, 15 Apr 2016 02:53:49 -0400
From:	Howard Cochran <hcochran@...nelspring.com>
To:	linux-kernel@...r.kernel.org
Cc:	Steven Rostedt <rostedt@...dmis.org>,
	Ingo Molnar <mingo@...hat.com>,
	Howard Cochran <cochran@...mark.com>,
	Howard Cochran <hcochran@...nelspring.com>
Subject: [PATCH 4/5] tracing: Make snapshot trigger affect the correct instance

Currently, the snapshot trigger always snapshots the top level instance,
even if it was triggered within an instance. Fixed by using the trace_array
associated with the trace_event_file which fired the trigger.

Signed-off-by: Howard Cochran <hcochran@...nelspring.com>
---
 kernel/trace/trace.c                | 38 ++++++++++++++++++++++---------------
 kernel/trace/trace.h                |  1 +
 kernel/trace/trace_events_trigger.c |  4 ++--
 3 files changed, 26 insertions(+), 17 deletions(-)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index c78fe42..e98770b 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -620,22 +620,11 @@ EXPORT_SYMBOL_GPL(__trace_bputs);
 
 #ifdef CONFIG_TRACER_SNAPSHOT
 /**
- * trace_snapshot - take a snapshot of the current buffer.
- *
- * This causes a swap between the snapshot buffer and the current live
- * tracing buffer. You can use this to take snapshots of the live
- * trace when some condition is triggered, but continue to trace.
- *
- * Note, make sure to allocate the snapshot with either
- * a tracing_snapshot_alloc(), or by doing it manually
- * with: echo 1 > /sys/kernel/debug/tracing/snapshot
- *
- * If the snapshot buffer is not allocated, it will stop tracing.
- * Basically making a permanent snapshot.
+ * trace_snapshot - take a snapshot of a buffer.
+ * @tr:    Which tracing buffer (instance) to take a snapshot of
  */
-void tracing_snapshot(void)
+void __tracing_snapshot(struct trace_array *tr)
 {
-	struct trace_array *tr = &global_trace;
 	struct tracer *tracer = tr->current_trace;
 	unsigned long flags;
 
@@ -648,7 +637,7 @@ void tracing_snapshot(void)
 	if (!tr->allocated_snapshot) {
 		internal_trace_puts("*** SNAPSHOT NOT ALLOCATED ***\n");
 		internal_trace_puts("*** stopping trace here!   ***\n");
-		tracing_off();
+		tracer_tracing_off(tr);
 		return;
 	}
 
@@ -663,6 +652,25 @@ void tracing_snapshot(void)
 	update_max_tr(tr, current, smp_processor_id());
 	local_irq_restore(flags);
 }
+
+/**
+ * trace_snapshot - take a snapshot of the top level buffer.
+ *
+ * This causes a swap between the snapshot buffer and the current live
+ * tracing buffer. You can use this to take snapshots of the live
+ * trace when some condition is triggered, but continue to trace.
+ *
+ * Note, make sure to allocate the snapshot with either
+ * a tracing_snapshot_alloc(), or by doing it manually
+ * with: echo 1 > /sys/kernel/debug/tracing/snapshot
+ *
+ * If the snapshot buffer is not allocated, it will stop tracing.
+ * Basically making a permanent snapshot.
+ */
+void tracing_snapshot(void)
+{
+	__tracing_snapshot(&global_trace);
+}
 EXPORT_SYMBOL_GPL(tracing_snapshot);
 
 static int resize_buffer_duplicate_size(struct trace_buffer *trace_buf,
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index d3bc0e8..d98d54c 100644
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -717,6 +717,7 @@ enum print_line_t print_trace_line(struct trace_iterator *iter);
 extern char trace_find_mark(unsigned long long duration);
 
 void __trace_dump_stack(int skip, struct trace_array *tr);
+void __tracing_snapshot(struct trace_array *tr);
 int tracer_tracing_is_on(struct trace_array *tr);
 void tracer_tracing_on(struct trace_array *tr);
 void tracer_tracing_off(struct trace_array *tr);
diff --git a/kernel/trace/trace_events_trigger.c b/kernel/trace/trace_events_trigger.c
index a73b823..2f7dc19 100644
--- a/kernel/trace/trace_events_trigger.c
+++ b/kernel/trace/trace_events_trigger.c
@@ -901,7 +901,7 @@ static void
 snapshot_trigger(struct event_trigger_data *data, void *rec,
 		 struct trace_event_file *file)
 {
-	tracing_snapshot();
+	__tracing_snapshot(file->tr);
 }
 
 static void
@@ -914,7 +914,7 @@ snapshot_count_trigger(struct event_trigger_data *data, void *rec,
 	if (data->count != -1)
 		(data->count)--;
 
-	snapshot_trigger(data, rec);
+	snapshot_trigger(data, rec, file);
 }
 
 static int
-- 
1.9.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ