Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3999326pxv; Mon, 5 Jul 2021 10:55:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxEzhGHLG0+0wmnAV2KQeShz0kPdo9tksv2nFozY17BeIV9yYmERAMz7XyvLLHa849SzdhH X-Received: by 2002:a05:6402:34c1:: with SMTP id w1mr17896325edc.104.1625507719813; Mon, 05 Jul 2021 10:55:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625507719; cv=none; d=google.com; s=arc-20160816; b=pgFCLIJV2cpDeoUWYg0tNhmt9OAKOgeuX+i/uUFlQag6Vy2xhCIHZwXCdpNONoi7zX qIFztE0wa2xR7OC28gcOVtOFwsVmbIqD351mAxIPe7/chGK10ngcvyWEyHuDimkurKTr laNpYjC4I/Wk20HCscEGFr0wxFdfYcaWIdMHEi5p8xPq4KeEm0lZvUolabE2VcZigL4K jHxXFhy5HfmhxOGXHoIIEwFNite+ixHUPBKYxmlqIOwSAHGmZly8BY1rZjEjWmtsnVf5 0MV+gdqZAOWtjouLV1wicDNjF3okgj7XK3SpkGYSvU2aEW76Io56rGZ0I8qDQY8BERTe 0/4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Vp9m1yOD6PLTwYYvVt7ryjjTzJwHHIyPqnoAwdNcgHc=; b=zbq8Bb1loVQG6mmTb5kodOwOLt7coqkG12GqWOAHKkBuG6c/sAywn4bcZK+9fMn2aW 7Jn0sXUrBo2TV8Ed7rA5cwtxX5ZB6uVXC4mLPQbc9P/UKG29IFEHRMRWLlDIRNVjRpno iWS0OIbEXyh/w9C0+4kqjbd8C/OLwecs7ShfEjKJ3QIiscRXf+8sQEA65mjeukq7VMcT 0svxi1Gqi8XN+lvbEjTW9QcV59akjcFnYYz1lbuqvzjYFiSRRrm0mWZwI9UcRTKTAu8F d+zTWBDMiY77slddE9nWYcnSExlyGiaVVCFAIHF61Gk3BUBU1tSTHQeyb72APugyZ74o ncoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=iIsNWmb2; 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 s8si11427522ejm.214.2021.07.05.10.54.54; Mon, 05 Jul 2021 10:55:19 -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=k20201202 header.b=iIsNWmb2; 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 S229812AbhGERzd (ORCPT + 99 others); Mon, 5 Jul 2021 13:55:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:42398 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229686AbhGERzc (ORCPT ); Mon, 5 Jul 2021 13:55:32 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1664761970; Mon, 5 Jul 2021 17:52:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625507575; bh=3Qw9ctfa0uruVJSlUOjdb6ZdmXLcGb6TQEPOpFwUcBI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=iIsNWmb2ouUN33cJ9ZUSApq38lv3x2uSPqvqt4/HOgy1SIPu57xB3TmcO2BAFk6QI F4tGE9owhuJOj70wHyUJ/CvS3vy7ZB6RCBBUird5LenQKIpYHVcqoOWxDl/ffxZeSW T8OIWRwvVm1qFkbLY9OOU6AqcTDW4149I2pOlcV6ddJnT1UdGqtxMX6EfWpviNU5pL kJVlhGWBbBpYtqFskvkylx+eqMw3fac8+oXRcqmVcL08JjSnDwKapXgel0rRYZi/aS dSJxI1+DjQD1Jz8i8HpPaZ/Rfwn0Qu+Ca7cJDcojmR67FAABVBEnEaGpCGGqvdCO8x XE2RUIJOa/TPg== Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id 96ABC40B1A; Mon, 5 Jul 2021 14:52:52 -0300 (-03) Date: Mon, 5 Jul 2021 14:52:52 -0300 From: Arnaldo Carvalho de Melo To: Riccardo Mancini Cc: Namhyung Kim , Ian Rogers , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Martin Liska , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] perf annotate: fix 's' on source line when disasm is empty Message-ID: References: <20210705161524.72953-1-rickyman7@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20210705161524.72953-1-rickyman7@gmail.com> X-Url: http://acmel.wordpress.com Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Mon, Jul 05, 2021 at 06:15:25PM +0200, Riccardo Mancini escreveu: > If the disasm is empty, 's' should fail. Instead it seemingly works, > hiding the empty lines and causing an assertion error on the next > time annotate is called (from within perf report). > The problem is caused by a buffer overflow, caused by a wrong > exit condition in annotate_browser__find_next_asm_line, which checks > browser->b.top instead of browser->b.entries. > > This patch fixes the issue, making annotate_browser__toggle_source > fail if the disasm is empty (nothing happens to the user). > > Fixes: 6de249d66d2e Next time please make the fixes be of this form: Fixes: 6de249d66d2e7881 ("perf annotate: Allow 's' on source code lines") ⬢[acme@toolbox perf]$ git config core.abbrev 16 ⬢[acme@toolbox perf]$ git config core.abbrev 16 ⬢[acme@toolbox perf]$ head -2 ~/.gitconfig [core] abbrev = 16 ⬢[acme@toolbox perf]$ Thanks, applied. - Arnaldo > Signed-off-by: Riccardo Mancini > --- > tools/perf/ui/browsers/annotate.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c > index f5509a958e38..5812a2214cc1 100644 > --- a/tools/perf/ui/browsers/annotate.c > +++ b/tools/perf/ui/browsers/annotate.c > @@ -350,14 +350,14 @@ static struct annotation_line *annotate_browser__find_next_asm_line( > struct annotation_line *it = al; > > /* find next asm line */ > - list_for_each_entry_continue(it, browser->b.top, node) { > + list_for_each_entry_continue(it, browser->b.entries, node) { > if (it->idx_asm >= 0) > return it; > } > > /* no asm line found forwards, try backwards */ > it = al; > - list_for_each_entry_continue_reverse(it, browser->b.top, node) { > + list_for_each_entry_continue_reverse(it, browser->b.entries, node) { > if (it->idx_asm >= 0) > return it; > } > -- > 2.23.0 > -- - Arnaldo