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: <1348500251-9937-8-git-send-email-feng.tang@intel.com>
Date:	Mon, 24 Sep 2012 23:24:09 +0800
From:	Feng Tang <feng.tang@...el.com>
To:	acme@...hat.com
Cc:	mingo@...e.hu, a.p.zijlstra@...llo.nl, andi@...stfloor.org,
	namhyung@...nel.org, dsahern@...il.com,
	linux-kernel@...r.kernel.org, Feng Tang <feng.tang@...el.com>
Subject: [PATCH v3 7/9] perf header: Add check_perf_magic() func

With this func, other modules can basically check whether a file
is a legal perf data file by checking its first 8 bytes aginst
all possible perf magic nunbers.

Signed-off-by: Feng Tang <feng.tang@...el.com>
---
 tools/perf/util/header.c |   11 +++++++++++
 tools/perf/util/header.h |    1 +
 2 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index ad72b28..555cb68 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -2174,6 +2174,17 @@ static int try_all_pipe_abis(uint64_t hdr_sz, struct perf_header *ph)
 	return -1;
 }
 
+/* Return 0 if matched */
+int check_perf_magic(u64 magic)
+{
+	if (!memcmp(&magic, __perf_magic1, sizeof(magic))
+		|| magic == __perf_magic2
+		|| magic == __perf_magic2_sw)
+		return 0;
+
+	return -1;
+}
+
 static int check_magic_endian(u64 magic, uint64_t hdr_sz,
 			      bool is_pipe, struct perf_header *ph)
 {
diff --git a/tools/perf/util/header.h b/tools/perf/util/header.h
index 58de08b..af1a51c 100644
--- a/tools/perf/util/header.h
+++ b/tools/perf/util/header.h
@@ -131,6 +131,7 @@ int perf_event__synthesize_build_id(struct perf_tool *tool,
 int perf_event__process_build_id(struct perf_tool *tool,
 				 union perf_event *event,
 				 struct perf_session *session);
+int check_perf_magic(u64 magic);
 
 /*
  * arch specific callback
-- 
1.7.1

--
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