Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3946396pxv; Mon, 5 Jul 2021 09:31:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy63UYaeTKIuBj1HRGUsIjJN5nZx5mEjKLDTfIDyWnpQrFwYxcQRB5w5+kU3KdwiQdtEvFB X-Received: by 2002:a50:d64a:: with SMTP id c10mr17784694edj.199.1625502664294; Mon, 05 Jul 2021 09:31:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625502664; cv=none; d=google.com; s=arc-20160816; b=GO0SZKmYNYgR8uMlE9fRnPBdeLOd8qSo6+saPmtA/3znQJeMkV9YHvhDyrU7/hvUjQ JNL+89nShhVM1vfRS76eF399GfEAw7dlCqYHADcj8yKw8AF8kjDxaCbu8If9sY1x08M3 qVlaE8PGHMsS3V68SYm15ACgfMbOgpnuzXQyBGE/RcFZJJN9GNs/3xIL/wY5KV3Kv2q7 HFQwqBF5R4x6WV5nM4cnZ5Zb4FOjXvGdi82chLYlyn4ZSZj4lzPxsInAajQxYRrE0C1h k/eKc86gmu61OuFHP9LL3qXnbPQ5EFHeRHlwNktqFLcdK5u3s8QYLBuYAr5yNM9X6ZUE NOCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=6eplp7/n3jsj+3IbVU25mDy3/i+Dcp/355oC41kui6M=; b=JKbu9jBOijefo5izDHD5Kf0V7Sevgfo8dWV0o7J/W8uw/bTPApW2fQ4/jyZ6ouw0Ra Fep5yHGXpJ1lysNBKgRHmeD9w/ceQe/L8sVkRHQ+Z6WFv82vf1W7bOy4y9PnWIuW2Qug ZL2iyZWS81H9KZgEjpnrGF4WZFqkUYtUA4J1HTYw4SHpyaldxB/ZNvcQzGVyGdOg1bLt DC28hIVR9REK60EXs7pkUAgWq47Yvhncq/NK7JZKfRTsvBwzbq4LyuiUUMZielSo3oLa tQsRYOs73Y6Dg6lwgMxcMdfUuChcLXmWKy1xp2NGVEX+7xS5cOwHXI2Rl+G2hE6cqdoB v31Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Hhb5EHqq; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id yl15si12066993ejb.281.2021.07.05.09.30.40; Mon, 05 Jul 2021 09:31:04 -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=@gmail.com header.s=20161025 header.b=Hhb5EHqq; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229805AbhGEQcF (ORCPT + 99 others); Mon, 5 Jul 2021 12:32:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229560AbhGEQcE (ORCPT ); Mon, 5 Jul 2021 12:32:04 -0400 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55872C061574; Mon, 5 Jul 2021 09:29:27 -0700 (PDT) Received: by mail-wr1-x435.google.com with SMTP id t6so12822332wrm.9; Mon, 05 Jul 2021 09:29:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=6eplp7/n3jsj+3IbVU25mDy3/i+Dcp/355oC41kui6M=; b=Hhb5EHqqhMhhbKeFBinPr6lxVH6eRLwTeLYSCs08+aQbyS4RtVA/JJnUoZsMA6Ap9L cmc+env0b+QkutlUDk7Nylmbou+0V55ycYL+vq3B6gAdVBv8IIzBgy6SF9XhJcCYGctT zfHzOG37yqjJeTmf1+Bg2fUUj43Zi/NrtWuhNkZaOJeLPmU8fEALKXAdWaDu/e1UAo4x vg/NFDVb7cbJtwyqPepF0ojcjXIFDlKQ/ax26noherWB9dN2JdKqDF94bsjq4pboPs6I LAl18AeU1K9oYfA4eICpFzWLBHComkWopSo5Z9P4Wi/fguADbe60IHLfRj3KmapexAvr xVTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=6eplp7/n3jsj+3IbVU25mDy3/i+Dcp/355oC41kui6M=; b=oOS9f1CgmNnadUBwrH6jCjocjQTpEZl9qypRJ+20eM5eegIdHZ/auve/qAqwpjG86n fc0n5d1viwImIAbcksGItrM0eTo2k9AETEbHANMU09Tmtoj+5ZDESmZM7EvqSngIeFpa tU2nKwm0JK/9ZU6VcoTsKl2WITT8pTkCMHzFZCVUIK7Du9m5hCsabMi6W9f4hJPuoA9T DQ1yGemmTprK8Ujo0uZSIbZYXXJg0WcIxbIfM/vjJM60ZTYthlRbb7c4FWYVa1mFmVF4 NeqHFJrM+51YkMCzpdQjrvE/g2PmpKCyTVbzjordVhGC9ZrKtHbOwsOSj6AHlpewVAx4 VD4A== X-Gm-Message-State: AOAM532vLNT7iOxgYSQHO+x/k3cpxqgR4NlkeTj/7vzgJ1OAlaZEsBfM IF6hfenjTrCJs3adiAKubu0= X-Received: by 2002:adf:d1cc:: with SMTP id b12mr9533901wrd.410.1625502565801; Mon, 05 Jul 2021 09:29:25 -0700 (PDT) Received: from localhost.localdomain ([2001:b07:6456:fd99:ced0:db1c:53e1:191e]) by smtp.googlemail.com with ESMTPSA id j10sm2411457wrt.35.2021.07.05.09.29.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Jul 2021 09:29:25 -0700 (PDT) From: Riccardo Mancini To: Arnaldo Carvalho de Melo Cc: Namhyung Kim , Ian Rogers , Riccardo Mancini , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Martin Liska , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] perf annotate: fix 's' on source line when disasm is empty Date: Mon, 5 Jul 2021 18:15:25 +0200 Message-Id: <20210705161524.72953-1-rickyman7@gmail.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 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