Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2263048pxp; Mon, 21 Mar 2022 15:16:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwzyIM3qsua62jlTZWyO4IGhISvcLW4StqxEMLyZ0n8CmprWyPZyvY0pd0b9BIDnW3lJzWL X-Received: by 2002:a17:90a:5b0d:b0:1bc:7e66:2970 with SMTP id o13-20020a17090a5b0d00b001bc7e662970mr1412155pji.12.1647901007112; Mon, 21 Mar 2022 15:16:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647901007; cv=none; d=google.com; s=arc-20160816; b=tZEYDcrzKhm5x/ndmCLIN4+K7Lil92dpaFmVuBF3bergE8rbOB0FM4ErRkTry6KYP3 gdGW01dwVFIhyYDJ8VaHXMlajUD97vZi5Ny3KG0TPD9/RlHj1BktmZ20MJ8vo1eDz2av dqcGe6co/l/pXaEfWgRqj6M1tOR0OdKH2heWif0ORxERkbOcgC97i8LieID2ZYHODKqa myMXFMOnL4QwSMJj9JBFz7UkvniovpuLWboVP/atk4hkcdUpAqcLqNQsS+CwXC7TBKJe bQk06f/gOlRCeV4NdUBcwVQ+EudK2TY0eCHw1/V3+mwkPSWuT4UuI9D9HzsSZvm+bLmJ ZbHQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Up/tGE8DNnoupiBIXEl4nj7CsIOQyehJDCx5w7tISxc=; b=PcyOiMqiH5TZHmxnnrQQqgnH4scrgWjN0tLgygWgkcL9hT22dHOJw0zvLfl1IWan+M M4/TBZrz8T5eaxihYQvamqeBP/VgUefJvrfUBP6YK1e4P2/yI5oy3pY8dhMSs9FKG903 tjctLGvkmiQGmnWCXpOTG+vOTXcgER36e5DnaXVIR/IS7hsZSao5v40p9reLcyxSTsL1 I9iJSuaojt9jxGcSyRwW1UJMvCvVHH0yLAl8OKiXRUlrAimM27KWNqfw+EI4O6yIsvdo 7Lk2SgGc55VPkrP0U2pHwcHt+mfkHeH2jcbgXxdJsDHSxHVpMr0KMLX9sqwUL/ciieSW tHQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Xl21rsFR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id m66-20020a633f45000000b003816043f064si15058297pga.601.2022.03.21.15.16.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Mar 2022 15:16:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Xl21rsFR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id BF7DD371499; Mon, 21 Mar 2022 14:33:18 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345309AbiCUOFb (ORCPT + 99 others); Mon, 21 Mar 2022 10:05:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349155AbiCUN71 (ORCPT ); Mon, 21 Mar 2022 09:59:27 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A5657672; Mon, 21 Mar 2022 06:58:01 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D1C796125C; Mon, 21 Mar 2022 13:58:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DD750C340E8; Mon, 21 Mar 2022 13:57:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1647871080; bh=tj33CDVipt3Hwcf7gdEjoaIZbWPVmkUS+u0jcdrdLGM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Xl21rsFR58KjffptMJonZ8hBxrgiTe52k9YSX3KUaluXabObpICw+Yj3bFnekoKLr Gfc6KAJl5cGM/2RWjK+jlM3KBZaU7nBZGoLB3RzjyaQFYmM2o5zOGrU2g2xi+K1HrI xX6mc0NXcdZSksKjQ84kafKgf3gX9Aw9iPZP97/0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Michael Petlan , Athira Jajeev , Jiri Olsa , Kajol Jain , Madhavan Srinivasan , Arnaldo Carvalho de Melo Subject: [PATCH 5.4 16/17] perf symbols: Fix symbol size calculation condition Date: Mon, 21 Mar 2022 14:52:52 +0100 Message-Id: <20220321133217.625197205@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220321133217.148831184@linuxfoundation.org> References: <20220321133217.148831184@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Michael Petlan commit 3cf6a32f3f2a45944dd5be5c6ac4deb46bcd3bee upstream. Before this patch, the symbol end address fixup to be called, needed two conditions being met: if (prev->end == prev->start && prev->end != curr->start) Where "prev->end == prev->start" means that prev is zero-long (and thus needs a fixup) and "prev->end != curr->start" means that fixup hasn't been applied yet However, this logic is incorrect in the following situation: *curr = {rb_node = {__rb_parent_color = 278218928, rb_right = 0x0, rb_left = 0x0}, start = 0xc000000000062354, end = 0xc000000000062354, namelen = 40, type = 2 '\002', binding = 0 '\000', idle = 0 '\000', ignore = 0 '\000', inlined = 0 '\000', arch_sym = 0 '\000', annotate2 = false, name = 0x1159739e "kprobe_optinsn_page\t[__builtin__kprobes]"} *prev = {rb_node = {__rb_parent_color = 278219041, rb_right = 0x109548b0, rb_left = 0x109547c0}, start = 0xc000000000062354, end = 0xc000000000062354, namelen = 12, type = 2 '\002', binding = 1 '\001', idle = 0 '\000', ignore = 0 '\000', inlined = 0 '\000', arch_sym = 0 '\000', annotate2 = false, name = 0x1095486e "optinsn_slot"} In this case, prev->start == prev->end == curr->start == curr->end, thus the condition above thinks that "we need a fixup due to zero length of prev symbol, but it has been probably done, since the prev->end == curr->start", which is wrong. After the patch, the execution path proceeds to arch__symbols__fixup_end function which fixes up the size of prev symbol by adding page_size to its end offset. Fixes: 3b01a413c196c910 ("perf symbols: Improve kallsyms symbol end addr calculation") Signed-off-by: Michael Petlan Cc: Athira Jajeev Cc: Jiri Olsa Cc: Kajol Jain Cc: Madhavan Srinivasan Link: http://lore.kernel.org/lkml/20220317135536.805-1-mpetlan@redhat.com Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Greg Kroah-Hartman --- tools/perf/util/symbol.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c @@ -231,7 +231,7 @@ void symbols__fixup_end(struct rb_root_c prev = curr; curr = rb_entry(nd, struct symbol, rb_node); - if (prev->end == prev->start && prev->end != curr->start) + if (prev->end == prev->start || prev->end != curr->start) arch__symbols__fixup_end(prev, curr); }