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]
Date:	Sun, 16 Nov 2008 16:08:01 +0530
From:	"Aneesh Kumar K.V" <aneesh.kumar@...ux.vnet.ibm.com>
To:	rostedt@...dmis.org, mingo@...e.hu, akpm@...ux-foundation.org,
	fweisbec@...il.com
Cc:	linux-kernel@...r.kernel.org,
	"Aneesh Kumar K.V" <aneesh.kumar@...ux.vnet.ibm.com>
Subject: [PATCH] ftrace: Add debug_dump trace to dump binary data from kernel to userspace

The trace add a new interface debug_dump() which can be used
to dump binary data using ftrace framework. Use the dump mode
of iterator by 'echo dump > iter_ctrl' to read the value in
userspace

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@...ux.vnet.ibm.com>

---
 include/linux/debug_dump.h     |   10 ++++
 kernel/trace/Kconfig           |    6 ++
 kernel/trace/Makefile          |    1 +
 kernel/trace/trace_debugdump.c |  103 ++++++++++++++++++++++++++++++++++++++++
 4 files changed, 120 insertions(+), 0 deletions(-)

diff --git a/include/linux/debug_dump.h b/include/linux/debug_dump.h
new file mode 100644
index 0000000..2c1836d
--- /dev/null
+++ b/include/linux/debug_dump.h
@@ -0,0 +1,10 @@
+#ifndef _LINUX_DEBUGDUMP_H
+#define _LINUX_DEBUGDUMP_H
+#include <linux/marker.h>
+
+#ifdef CONFIG_DEBUG_DUMP
+extern int debug_dump(void *p, int len);
+#else
+#define debug_dump(p, len)
+#endif
+#endif /*  _LINUX_DEBUGDUMP_H */
diff --git a/kernel/trace/Kconfig b/kernel/trace/Kconfig
index 30eccc8..247cf3f 100644
--- a/kernel/trace/Kconfig
+++ b/kernel/trace/Kconfig
@@ -261,4 +261,10 @@ config DEBUG_PRINT
 	help
 	  This tracer can be used for printk style debugging.
 
+config DEBUG_DUMP
+	bool "Trace based dump support"
+	depends on DEBUG_KERNEL
+	select TRACING
+	help
+	  This tracer can be used to dump binary data from kernel
 endmenu
diff --git a/kernel/trace/Makefile b/kernel/trace/Makefile
index 86e5869..b1c6dec 100644
--- a/kernel/trace/Makefile
+++ b/kernel/trace/Makefile
@@ -32,5 +32,6 @@ obj-$(CONFIG_BOOT_TRACER) += trace_boot.o
 obj-$(CONFIG_FUNCTION_RET_TRACER) += trace_functions_return.o
 obj-$(CONFIG_TRACE_BRANCH_PROFILING) += trace_branch.o
 obj-$(CONFIG_DEBUG_PRINT) += trace_debugprint.o
+obj-$(CONFIG_DEBUG_DUMP) += trace_debugdump.o
 
 libftrace-y := ftrace.o
diff --git a/kernel/trace/trace_debugdump.c b/kernel/trace/trace_debugdump.c
new file mode 100644
index 0000000..3ebae2a
--- /dev/null
+++ b/kernel/trace/trace_debugdump.c
@@ -0,0 +1,103 @@
+/*
+ * Copyright IBM Corporation, 2008
+ * Author Aneesh Kumar K.V <aneesh.kumar@...ux.vnet.ibm.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2.1 of the GNU Lesser General Public License
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it would be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/fs.h>
+#include <linux/debugfs.h>
+#include <linux/ftrace.h>
+
+#include "trace.h"
+
+static struct trace_array *ctx_trace;
+static int __read_mostly dd_tracer_enabled;
+
+int debug_dump(void *bin_data, int len)
+{
+	int size;
+	unsigned long irq_flags;
+	struct dump_entry *entry;
+	struct ring_buffer_event *event;
+
+	if (!dd_tracer_enabled)
+		return 0;
+
+	size = sizeof(*entry) + len;
+	event = ring_buffer_lock_reserve(ctx_trace->buffer, size, &irq_flags);
+	if (!event)
+		return 0;
+	entry = ring_buffer_event_data(event);
+	tracing_generic_entry_update(&entry->ent, 0, preempt_count());
+	entry->ent.type	= TRACE_BIN_DUMP;
+	entry->len	= len;
+
+	memcpy(&entry->buf, bin_data, len);
+	ring_buffer_unlock_commit(ctx_trace->buffer, event, irq_flags);
+
+	return len;
+}
+EXPORT_SYMBOL_GPL(debug_dump);
+
+static void dd_reset(struct trace_array *tr)
+{
+	int cpu;
+
+	tr->time_start = ftrace_now(tr->cpu);
+
+	for_each_online_cpu(cpu)
+		tracing_reset(tr, cpu);
+}
+
+static void dd_trace_start(struct trace_array *tr)
+{
+	dd_reset(tr);
+	dd_tracer_enabled = 1;
+}
+
+static void dd_trace_stop(struct trace_array *tr)
+{
+	dd_tracer_enabled = 0;
+	/* Nothing to do! */
+}
+
+static void dd_trace_init(struct trace_array *tr)
+{
+	ctx_trace = tr;
+	/*
+	 * enable the trace during init if
+	 * we have enabled flag already set
+	 */
+	if (tracing_is_enabled())
+		dd_trace_start(tr);
+}
+
+static void dd_trace_reset(struct trace_array *tr)
+{
+	if (dd_tracer_enabled)
+		dd_trace_stop(tr);
+}
+
+struct tracer dd_trace __read_mostly =
+{
+	.name		= "debug_dump",
+	.init		= dd_trace_init,
+	.reset		= dd_trace_reset,
+	.start		= dd_trace_start,
+	.stop		= dd_trace_stop,
+};
+
+__init static int init_dd_trace(void)
+{
+	return register_tracer(&dd_trace);
+}
+device_initcall(init_dd_trace);
-- 
tg: (140170e..) an/ftrace-debug-dump.patch (depends on: an/ftrace-bin-dump.patch)
--
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