linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] perf hists browser: Fix segfault when all entries be filtered
@ 2015-03-04  4:13 He Kuang
  2015-03-10  3:38 ` He Kuang
  0 siblings, 1 reply; 3+ messages in thread
From: He Kuang @ 2015-03-04  4:13 UTC (permalink / raw)
  To: acme; +Cc: a.p.zijlstra, mingo, wangnan0, linux-kernel

When all perf report entries be filtered, the result of
hists__filter_entries() can be NULL, check the result before processing.

Miss this checking will cause segmentation fault like this:

  $ perf report

(filter all entries and left nothing, then zoom in/out)
  perf: Segmentation fault
  -------- backtrace --------
  ../bin/perf[0x4d1858]
  ../lib64/libc.so.6(+0x3545f)[0x7fe72fc1145f]
  ../bin/perf[0x4cd9f5]
  ../bin/perf[0x4ce176]
  ../bin/perf[0x4d0506]
  ../bin/perf[0x41a94f]
  ../bin/perf[0x408cf2]
  ../bin/perf[0x408455]
  ../lib64/libc.so.6(__libc_start_main+0xf4)[0x7fe72fbfdbd4]
  ../bin/perf[0x408584]

Signed-off-by: He Kuang <hekuang@huawei.com>
---
 tools/perf/ui/browsers/hists.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index 788506e..1106bb8 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -992,6 +992,9 @@ static void ui_browser__hists_seek(struct ui_browser *browser,
 	 * and stop when we printed enough lines to fill the screen.
 	 */
 do_offset:
+	if (!nd)
+		return;
+
 	if (offset > 0) {
 		do {
 			h = rb_entry(nd, struct hist_entry, rb_node);
-- 
2.2.0.33.gc18b867


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] perf hists browser: Fix segfault when all entries be filtered
  2015-03-04  4:13 [PATCH] perf hists browser: Fix segfault when all entries be filtered He Kuang
@ 2015-03-10  3:38 ` He Kuang
  2015-03-10  6:01   ` Namhyung Kim
  0 siblings, 1 reply; 3+ messages in thread
From: He Kuang @ 2015-03-10  3:38 UTC (permalink / raw)
  To: acme, a.p.zijlstra, mingo, paulus, jolsa,
	namhyung@kernel.org >> Namhyung Kim
  Cc: wangnan0, linux-kernel

ping..
On 2015/3/4 12:13, He Kuang wrote:
> When all perf report entries be filtered, the result of
> hists__filter_entries() can be NULL, check the result before processing.
>
> Miss this checking will cause segmentation fault like this:
>
>    $ perf report
>
> (filter all entries and left nothing, then zoom in/out)
>    perf: Segmentation fault
>    -------- backtrace --------
>    ../bin/perf[0x4d1858]
>    ../lib64/libc.so.6(+0x3545f)[0x7fe72fc1145f]
>    ../bin/perf[0x4cd9f5]
>    ../bin/perf[0x4ce176]
>    ../bin/perf[0x4d0506]
>    ../bin/perf[0x41a94f]
>    ../bin/perf[0x408cf2]
>    ../bin/perf[0x408455]
>    ../lib64/libc.so.6(__libc_start_main+0xf4)[0x7fe72fbfdbd4]
>    ../bin/perf[0x408584]
>
> Signed-off-by: He Kuang <hekuang@huawei.com>
> ---
>   tools/perf/ui/browsers/hists.c | 3 +++
>   1 file changed, 3 insertions(+)
>
> diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
> index 788506e..1106bb8 100644
> --- a/tools/perf/ui/browsers/hists.c
> +++ b/tools/perf/ui/browsers/hists.c
> @@ -992,6 +992,9 @@ static void ui_browser__hists_seek(struct ui_browser *browser,
>   	 * and stop when we printed enough lines to fill the screen.
>   	 */
>   do_offset:
> +	if (!nd)
> +		return;
> +
>   	if (offset > 0) {
>   		do {
>   			h = rb_entry(nd, struct hist_entry, rb_node);



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] perf hists browser: Fix segfault when all entries be filtered
  2015-03-10  3:38 ` He Kuang
@ 2015-03-10  6:01   ` Namhyung Kim
  0 siblings, 0 replies; 3+ messages in thread
From: Namhyung Kim @ 2015-03-10  6:01 UTC (permalink / raw)
  To: He Kuang; +Cc: acme, a.p.zijlstra, mingo, paulus, jolsa, wangnan0, linux-kernel

Hi,

On Tue, Mar 10, 2015 at 11:38:59AM +0800, He Kuang wrote:
> ping..
> On 2015/3/4 12:13, He Kuang wrote:
> >When all perf report entries be filtered, the result of
> >hists__filter_entries() can be NULL, check the result before processing.

In that case, browser->nr_entries should be zero IMHO.  But it seems
there's a place missing to update the number.

Thanks,
Namhyung


> >
> >Miss this checking will cause segmentation fault like this:
> >
> >   $ perf report
> >
> >(filter all entries and left nothing, then zoom in/out)
> >   perf: Segmentation fault
> >   -------- backtrace --------
> >   ../bin/perf[0x4d1858]
> >   ../lib64/libc.so.6(+0x3545f)[0x7fe72fc1145f]
> >   ../bin/perf[0x4cd9f5]
> >   ../bin/perf[0x4ce176]
> >   ../bin/perf[0x4d0506]
> >   ../bin/perf[0x41a94f]
> >   ../bin/perf[0x408cf2]
> >   ../bin/perf[0x408455]
> >   ../lib64/libc.so.6(__libc_start_main+0xf4)[0x7fe72fbfdbd4]
> >   ../bin/perf[0x408584]
> >
> >Signed-off-by: He Kuang <hekuang@huawei.com>
> >---
> >  tools/perf/ui/browsers/hists.c | 3 +++
> >  1 file changed, 3 insertions(+)
> >
> >diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
> >index 788506e..1106bb8 100644
> >--- a/tools/perf/ui/browsers/hists.c
> >+++ b/tools/perf/ui/browsers/hists.c
> >@@ -992,6 +992,9 @@ static void ui_browser__hists_seek(struct ui_browser *browser,
> >  	 * and stop when we printed enough lines to fill the screen.
> >  	 */
> >  do_offset:
> >+	if (!nd)
> >+		return;
> >+
> >  	if (offset > 0) {
> >  		do {
> >  			h = rb_entry(nd, struct hist_entry, rb_node);
> 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-03-10  6:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-04  4:13 [PATCH] perf hists browser: Fix segfault when all entries be filtered He Kuang
2015-03-10  3:38 ` He Kuang
2015-03-10  6:01   ` Namhyung Kim

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).