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:	Mon, 14 Sep 2015 10:23:55 +0000
From:	Wang Nan <wangnan0@...wei.com>
To:	<acme@...nel.org>, <namhyung@...nel.org>
CC:	<linux-kernel@...r.kernel.org>, <lizefan@...wei.com>,
	<pi3orama@....com>, Wang Nan <wangnan0@...wei.com>
Subject: [PATCH v2] perf tools: Fix segfault in 'perf top'

'perf top' segfaults with following operation:

 # perf top -e page-faults -p 11400 # 11400 never generates page-fault

Then on the resulting empty interface, press right key:

 # ./perf top -e page-faults -p 11400
 perf: Segmentation fault
 -------- backtrace --------
 ./perf[0x535428]
 /lib64/libc.so.6(+0x3545f)[0x7f0dd360745f]
 ./perf[0x531d46]
 ./perf(perf_evlist__tui_browse_hists+0x96)[0x5340d6]
 ./perf[0x44ba2f]
 /lib64/libpthread.so.0(+0x81d0)[0x7f0dd49dc1d0]
 /lib64/libc.so.6(clone+0x6c)[0x7f0dd36b90dc]

The bug reside in perf_evsel__hists_browse() that, in the above circumstance
browser->selection can be NULL, but code after skip_annotation doesn't consider
it.

This patch fix it by checking browser->selection before fetching
browser->selection->map.

Signed-off-by: Wang Nan <wangnan0@...wei.com>
Cc: Arnaldo Carvalho de Melo <acme@...nel.org>
Cc: Namhyung Kim <namhyung@...nel.org>
---
 tools/perf/ui/browsers/hists.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index e4fd40f..182b87a 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -2017,7 +2017,8 @@ skip_annotation:
 					  &options[nr_options], dso);
 		nr_options += add_map_opt(browser, &actions[nr_options],
 					  &options[nr_options],
-					  browser->selection->map);
+					  browser->selection ?
+					      browser->selection->map : NULL);
 		nr_options += add_socket_opt(browser, &actions[nr_options],
 					     &options[nr_options],
 					     socket);
@@ -2027,6 +2028,15 @@ skip_annotation:
 						     &actions[nr_options],
 						     &options[nr_options],
 						     thread, NULL);
+			/*
+			 * Note that browser->selection != NULL
+			 * when browser->he_selection is not NULL,
+			 * so we don't need to check browser->selection
+			 * before fetching browser->selection->sym like what
+			 * we do before fetching browser->selection->map.
+			 *
+			 * See hist_browser__show_entry.
+			 */
 			nr_options += add_script_opt(browser,
 						     &actions[nr_options],
 						     &options[nr_options],
-- 
1.8.3.4

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