Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp2260299ybt; Fri, 3 Jul 2020 05:01:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyMKT6nCtsWQR/kD4Rj6I74i6FCnvS2ZTz4u4SzRbhnHjzaqRNBgZOZooVUYnNe/JPTvtz5 X-Received: by 2002:a17:906:40d3:: with SMTP id a19mr32963474ejk.474.1593777712433; Fri, 03 Jul 2020 05:01:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593777712; cv=none; d=google.com; s=arc-20160816; b=c1xDDZ6Xn5AfgqQfAbDpAIlUZZ6Jo8gpSzmZr5Kfugkjxp92T2JhwS3xL1g0sLXwYT OyxTq5qN0r3RNj8vx/drL9reyOtUznw6uwwiNe165rT3n/cpB0Zubnw7zjrhAiyI++CJ yNZI/4iEnKndE/80r4naGfGAWRfAVQJLUSqpQqaSOpKS8uI+vGb2JQO5cb0zVfTfns2R Xkc42vlgB85zE1wVymspYePdzd87dahSgcawSSTpKIhgu5VrShLJySDUgjsCNjUPIZqp pka/wBf1X8Ic+WZjHOa6J8nZNUQUt3JdcHtXQBBzdgrLTJI/gR4niOi0hVLsIww52Rtm iTjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=7LuAxl2nVFBjNOUJ6z4bPsL7FFNZC63d09hw+xYJ/1E=; b=Pc+JhQrhANaX5kWAGku7hgVSoe9mLO/+kkDiyKqFSM/qZF9t8fUHKrrkKe4y39L0Nk FP+77+1oSptGPyPPGzvNf1v1Av+V4LlYcjDD26IIYNC07HpoEVkseDoXQV3VBMUnBtM6 7b4324r5WBNhNx+ZMBjvyT7EhMAQYWkM51QWjlRhyvsI8qEnxeU6E6vU3C2WhcjfurjT Xp5kZOSzwJyHAaGiQ6by3CDPWgzKt47S8dXuniQAQNJKPXeYER+ofiBrG+l+Q1wEsNr+ 9r80HyRiGEyXFQJ1sa05BI83+OFTh8Fpfbs87oqY2kGIqEzg8JIjn6LXCjzfk4BSgy9C KRzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=HpsZCP0y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ml21si8085348ejb.261.2020.07.03.05.01.28; Fri, 03 Jul 2020 05:01:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=HpsZCP0y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726112AbgGCL7R (ORCPT + 99 others); Fri, 3 Jul 2020 07:59:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:57620 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726022AbgGCL7Q (ORCPT ); Fri, 3 Jul 2020 07:59:16 -0400 Received: from quaco.ghostprotocols.net (unknown [179.162.131.14]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DA95E20782; Fri, 3 Jul 2020 11:59:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1593777555; bh=keRg3YRbxDR461UXdjt+avGgeCv6FyZupYAUcFrt5cI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=HpsZCP0ypoAaUAk9b21qT0U1PLtj+R/qZhp0jdG1d0gTV1gZ3HCKuKqgHSTPLOOa+ CUP0s4voHHdAXpiDVzpeLfZ2++ZGBYto/ZR8AP9GzKnyEJFDnJRvqEeYng//251jUK 9ukX0EF/OdOiFmAeNLzBdGDrKp9rgvoTww7y761o= Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id 0BC47405FF; Fri, 3 Jul 2020 08:59:12 -0300 (-03) Date: Fri, 3 Jul 2020 08:59:11 -0300 From: Arnaldo Carvalho de Melo To: "liwei (GF)" Cc: Jiri Olsa , Namhyung Kim , Mark Rutland , Alexander Shishkin , linux-kernel , Jin Yao , Andi Kleen , guohanjun@huawei.com Subject: Re: [PATCH] perf report TUI: Fix segmentation fault in perf_evsel__hists_browse() Message-ID: <20200703115911.GE1320@kernel.org> References: <20200612094322.39565-1-liwei391@huawei.com> <48be67be-9b87-87a1-125a-bb7d0d027a57@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <48be67be-9b87-87a1-125a-bb7d0d027a57@huawei.com> X-Url: http://acmel.wordpress.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Fri, Jul 03, 2020 at 09:03:53AM +0800, liwei (GF) escreveu: > Ping... Thanks, applied and tested, added the Acked-by Jiri and Namhyung provided, - Arnaldo > On 2020/6/12 23:19, Namhyung Kim wrote: > > Hello, > > > > On Fri, Jun 12, 2020 at 6:58 PM Wei Li wrote: > >> > >> The segmentation fault can be reproduced as following steps: > >> 1) Executing perf report in tui. > >> 2) Typing '/xxxxx' to filter the symbol to get nothing matched. > >> 3) Pressing enter with no entry selected. > >> Then it will report a segmentation fault. > >> > >> It is caused by the lack of check of browser->he_selection when > >> accessing it's member res_samples in perf_evsel__hists_browse(). > >> > >> These processes are meaningful for specified samples, so we can > >> skip these when nothing is selected. > >> > >> Fixes: 4968ac8fb7c3 ("perf report: Implement browsing of individual samples") > >> Signed-off-by: Wei Li > > > > Acked-by: Namhyung Kim > > > > Thanks > > Namhyung > > > > > >> --- > >> tools/perf/ui/browsers/hists.c | 17 +++++++++++------ > >> 1 file changed, 11 insertions(+), 6 deletions(-) > >> > >> diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c > >> index 487e54ef56a9..2101b6b770d8 100644 > >> --- a/tools/perf/ui/browsers/hists.c > >> +++ b/tools/perf/ui/browsers/hists.c > >> @@ -2288,6 +2288,11 @@ static struct thread *hist_browser__selected_thread(struct hist_browser *browser > >> return browser->he_selection->thread; > >> } > >> > >> +static struct res_sample *hist_browser__selected_res_sample(struct hist_browser *browser) > >> +{ > >> + return browser->he_selection ? browser->he_selection->res_samples : NULL; > >> +} > >> + > >> /* Check whether the browser is for 'top' or 'report' */ > >> static inline bool is_report_browser(void *timer) > >> { > >> @@ -3357,16 +3362,16 @@ static int perf_evsel__hists_browse(struct evsel *evsel, int nr_events, > >> &options[nr_options], NULL, NULL, evsel); > >> nr_options += add_res_sample_opt(browser, &actions[nr_options], > >> &options[nr_options], > >> - hist_browser__selected_entry(browser)->res_samples, > >> - evsel, A_NORMAL); > >> + hist_browser__selected_res_sample(browser), > >> + evsel, A_NORMAL); > >> nr_options += add_res_sample_opt(browser, &actions[nr_options], > >> &options[nr_options], > >> - hist_browser__selected_entry(browser)->res_samples, > >> - evsel, A_ASM); > >> + hist_browser__selected_res_sample(browser), > >> + evsel, A_ASM); > >> nr_options += add_res_sample_opt(browser, &actions[nr_options], > >> &options[nr_options], > >> - hist_browser__selected_entry(browser)->res_samples, > >> - evsel, A_SOURCE); > >> + hist_browser__selected_res_sample(browser), > >> + evsel, A_SOURCE); > >> nr_options += add_switch_opt(browser, &actions[nr_options], > >> &options[nr_options]); > >> skip_scripting: > >> -- > >> 2.17.1 > >> -- - Arnaldo