Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2269426pxp; Mon, 21 Mar 2022 15:27:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw1fi9Rv8OK/Q6/D5L82lUKyQTLX4Gy+bxewTX90bEPVLnrF5+OKDFVzsQhYE6q0Uh50cU8 X-Received: by 2002:a17:902:c713:b0:153:f75d:253b with SMTP id p19-20020a170902c71300b00153f75d253bmr14986014plp.99.1647901649480; Mon, 21 Mar 2022 15:27:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647901649; cv=none; d=google.com; s=arc-20160816; b=CTWK8x/YWQOxRUvNwc+Hri4mev8BGZWmJkBMFWSegjar1MxAiNjqmvQ0KIcD2lR8Vp dt5K+AYolz1EgXpxM+BLtVSj6TLE1uol1a3CGQ3bKjyKoQDE9O5toU8O9pCctGIAVVfR dMlvbx9NQXZRHjXsCEjUAFXRKbR90s3RqZp8kqsU7a00PwMqzOtX2FmCPn4h+aOWh4g9 +dngyAoGWIM7SZYs15PZSmrve04/SsGShE1JTDMGm2nfP0mC6MuNkhOTloqWT6DnYymV IisRnAl0/cpj6UYl+LIyWC3E8tyzgOWTb6Jd97PDLEOimsfyprtwxgTdxo5LkD0ePSXB 5fCQ== 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=mj8AsFEahUBtQv8mxBHiPwNve6Gzfo28HzJvdxfk7lc=; b=hkxdKPv9k/LEgIYWAI7ynh0SQWaivZBZWTl3Xnnc950GIDSkoX50ieZIFN6e9QrOSf LPmjPBJ4UQNSIaW8AhdCWJnndkBxFqQI66FrmGATfWY9w1ozy3YbInV6fR/GDgZzF9Uz 6HmGVqVa2Jb2J30Df5qssY2yY9J6R+PMVlk3uN2wsgIrg7p0l5z/w5JmtsKteOleF4gN Ku5Snc3vxeBuq0HTtw+u0k+vR2fwyH4E24+0MYZFGULVyShn0PVmNS8dWT49x098gt0J 94SR7jd7aPErunVf75fP9nGmldi3y6rqFtfXvnOdFUHXuidi8NrxGpFFh5PzPvtuffdN 4TRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=E4Jrmtfb; 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 m7-20020a656a07000000b003816043eec8si950519pgu.189.2022.03.21.15.27.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Mar 2022 15:27:29 -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=E4Jrmtfb; 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 1AA373AD64E; Mon, 21 Mar 2022 14:44:12 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349131AbiCUODW (ORCPT + 99 others); Mon, 21 Mar 2022 10:03:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349052AbiCUN6u (ORCPT ); Mon, 21 Mar 2022 09:58:50 -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 B52671697B4; Mon, 21 Mar 2022 06:57:17 -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 5437EB81674; Mon, 21 Mar 2022 13:57:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 90165C340E8; Mon, 21 Mar 2022 13:57:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1647871034; bh=mfCp1mtz3uOt21T0deEAqDDBiGLGy+OX7/+Z896l5P4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E4JrmtfbnDVywKLg4cDnpdqAVHdMiAPZUDxiLB9mzoo+BjQoimn5AQ+ziCKmYhCYO riaWRZu/ZaSN1dt8/HQcJpNK1ZAmETcmuhQtRjHRQdVtmedRIfeWlep9ZZ4529NFk3 toegV0kuO1uLr4b20ovBF9Gib0lzsmsYKjbUCKn4= 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 4.19 57/57] perf symbols: Fix symbol size calculation condition Date: Mon, 21 Mar 2022 14:52:38 +0100 Message-Id: <20220321133223.631843972@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220321133221.984120927@linuxfoundation.org> References: <20220321133221.984120927@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 @@ -217,7 +217,7 @@ void symbols__fixup_end(struct rb_root * 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); }