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-next>] [day] [month] [year] [list]
Message-Id: <1468919125-18562-1-git-send-email-gongss@linux.vnet.ibm.com>
Date:	Tue, 19 Jul 2016 17:05:25 +0800
From:	Song Shan Gong <gongss@...ux.vnet.ibm.com>
To:	acme@...nel.org, jolsa@...nel.org
Cc:	dsahern@...il.com, linux-kernel@...r.kernel.org,
	Song Shan Gong <gongss@...ux.vnet.ibm.com>
Subject: [PATCH RFC V1] perf tests: ignore symbols before kernel start

perf gets kernel map start in function 'machine__get_running_kernel_start',
by finding the first no-zero value of symbol start value of '_text' or
'_stext'. Though kernel maybe start from a no-zero value, perf loads all
symbols into a red-black tree, even if one symbol starts from zero (for
example, '_text' is zero, '_stext' is kernel map start value, '_text' is
also added to the red-black tree).

In test function 'test__vmlinux_matches_kallsyms', perf traverses all
vmlinux symbols by enumerating its red-black tree, but finding the pair
symbol in kallsyms by 'machine__find_kernel_symbol'. For function
'machine__find_kernel_symbol', it will find the matched map firstly, then
find the pair symbol in the red-black tree corresponding to that map.

So when '_text' is zero, '_stext' is kernel map start(no-zero), we can
get '_text' symbol of vmlinux, but we can't find the pair '_text' symbol of
kallsyms, because there is no map starting from zero. This mismatch is
incorrrect.

Fix by just ignoring these symbols before kernel start.

Signed-off-by: Song Shan Gong <gongss@...ux.vnet.ibm.com>
---
 tools/perf/tests/vmlinux-kallsyms.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/perf/tests/vmlinux-kallsyms.c b/tools/perf/tests/vmlinux-kallsyms.c
index e63abab..6766006 100644
--- a/tools/perf/tests/vmlinux-kallsyms.c
+++ b/tools/perf/tests/vmlinux-kallsyms.c
@@ -28,6 +28,7 @@ int test__vmlinux_matches_kallsyms(int subtest __maybe_unused)
 	enum map_type type = MAP__FUNCTION;
 	struct maps *maps = &vmlinux.kmaps.maps[type];
 	u64 mem_start, mem_end;
+	u64 kernel_start;
 
 	/*
 	 * Step 1:
@@ -75,6 +76,7 @@ int test__vmlinux_matches_kallsyms(int subtest __maybe_unused)
 	 * same value in the vmlinux file we load.
 	 */
 	kallsyms_map = machine__kernel_map(&kallsyms);
+	kernel_start = kallsyms_map->start;
 
 	/*
 	 * Step 5:
@@ -119,7 +121,7 @@ int test__vmlinux_matches_kallsyms(int subtest __maybe_unused)
 
 		sym  = rb_entry(nd, struct symbol, rb_node);
 
-		if (sym->start == sym->end)
+		if (sym->start == sym->end || sym->start < kernel_start)
 			continue;
 
 		mem_start = vmlinux_map->unmap_ip(vmlinux_map, sym->start);
-- 
2.3.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ