Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2276294pxp; Mon, 21 Mar 2022 15:38:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJycHLtVNJHakEoDXKV2SB/XnOi/U/cPQCmHVLoxJoTiu79jF3cX2lJJtzbFkEzTn0z62gUa X-Received: by 2002:a17:902:e943:b0:153:f9b:99c9 with SMTP id b3-20020a170902e94300b001530f9b99c9mr14733462pll.170.1647902326801; Mon, 21 Mar 2022 15:38:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647902326; cv=none; d=google.com; s=arc-20160816; b=V1IeSDNw4cqEilxb2Uk1LdqDezHGSnSOdkEGHdEnykhvjRJyN6D54GjB9N9GJtvChC 2t125uJLAd7eIfwvTPNcrhHrF4lZ7puGIBrIyGfgWuIZ9mjx2QQW9ShA2jSa1nweYI34 CeKBSnmjghrnM/LiIFjm9LYtSQCw7luLaHIoiMtnR6K0pv1G4CJ4hQqD8uArbvvm8qWN P2R/wr45s4wQF+oyBFR/G3n5vG1YiZm+k1lRJ9gNBDh4fQq03cKvPBRGdOiTv8tNh6BW MatDrpKdwTXMlBYhHhK+XWh2xWrhvTTZpB2odxRcyE6RlZAzFZVzWfReOALS9tPA8GY4 eGpg== 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=PwAWEOPIUeRpU9y6OWgjie/BurzDogUknG5tG4xfNxp3Hvs6w/GdwIsMz4dLWWFWbz v0kyOLvltMtCAVqf58QqzmDXtmBgNU1Bqy6oD/OWNZPwZwnSYxFkSEoYE1yocSgo8RB1 flw6ymV/k0wgL5YweU4R5FgI6XUTflwF1rieEekaEzUGvYLdikMu+1e814wtdrhejBSB Q/uYoozlU/nj9tC2V6HvrQRgirwv8zbqrh15Yf22k66ImupWgn/7RawXtWf6BH9hjVF2 ykz0A0SGstbrFp94rv2uJBe0sermTMqw5wPZo/H+PvyI51fiTSorrTfN7bkyvClMMcYx JctQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=U2gqj89P; 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 n9-20020a17090a670900b001bf35bf24d7si512730pjj.63.2022.03.21.15.38.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Mar 2022 15:38:46 -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=U2gqj89P; 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 5F3A83CA19C; Mon, 21 Mar 2022 14:51:01 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351649AbiCUOLX (ORCPT + 99 others); Mon, 21 Mar 2022 10:11:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348645AbiCUODt (ORCPT ); Mon, 21 Mar 2022 10:03:49 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A7AAC18022E; Mon, 21 Mar 2022 07:01:10 -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 ams.source.kernel.org (Postfix) with ESMTPS id 7505AB81598; Mon, 21 Mar 2022 14:01:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C10AAC340E8; Mon, 21 Mar 2022 14:01:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1647871265; bh=tj33CDVipt3Hwcf7gdEjoaIZbWPVmkUS+u0jcdrdLGM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U2gqj89PCamlfA+V077NH88xQmolVsQ6PV6AiR+yU8Iz8n2DqkZtpZKSETLouC6NZ U7t8+up0YUoV7PdlIKSpxLigBC1dvOeyUsvGDlUyoIM3UZVCCrNDLkN+RkFUJi5eNr FDDgLVExfaiIdQ7AzqhLa+XQqzppckiRkYWXvQ5E= 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.15 31/32] perf symbols: Fix symbol size calculation condition Date: Mon, 21 Mar 2022 14:53:07 +0100 Message-Id: <20220321133221.460200330@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220321133220.559554263@linuxfoundation.org> References: <20220321133220.559554263@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); }