Received: by 2002:ac0:da4c:0:0:0:0:0 with SMTP id a12csp453768imi; Fri, 22 Jul 2022 02:43:24 -0700 (PDT) X-Google-Smtp-Source: AGRyM1u2WtWeWaEl0A5SI/RcNlJOJQmVHFOW4JA7NqrCVhwGeIicaQac90OTFjUsIW+r77FlPGy8 X-Received: by 2002:a17:90a:c08:b0:1f2:1f4c:2903 with SMTP id 8-20020a17090a0c0800b001f21f4c2903mr3344787pjs.12.1658483004437; Fri, 22 Jul 2022 02:43:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658483004; cv=none; d=google.com; s=arc-20160816; b=GbQ23VbfnRPO/mcPldTmzXoWCdca6TqjSPFALhnsXOH65iKYkbtQ2DkEZ3sTFcLAJc 6UOLnmPSuURZzUQw4EfcshLdmpHMp90Ebjhlz0U3NiYVcEnhx8NbG5poSlBV/GAwzL3Z Q5rPKOezp2ytq1w3Ow39Y46EwkWHhGCMy1HjiwfXnMPkVGslpBX9hFz+XjKFeAE2Ps4n OzlZUVO0jRbeCKsZIfd95dmyO+9OsirBj/gvbrUQSsCQf42kZb0ZGq2vTaSsel24VKf1 RbGZ6rY6whuWgx/MA1HmHFrbp9zg3dcKAa2lgfS/aIxnRQWPp2bWm0LWoLB9nwTalcOK huxw== 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=bp1hbWvPo5/XdELkrMS5dRGYXDFq2GfheVUTLoBrBHY=; b=0x12hefoA/v6A0dq65/Bo+n3F/NuP0mXIQ9jML/CbqwAFJKxyGAk8sQs3mormLHT5c Gziwd88+AwXENjjZ2mBfl4xrie6RukOKrhOmeoMYY8mHRAClhJHXJN1bdRgPwSEw9Dxo BPrGMIGlKVyYxIHlxaGLjE+MCNAXISetzeI8nNUdT34Ep+G+2A5pBz7gKw0ozT6qqNfd pIKspqvQlJPTNDbbQW0+FwkOHdD4Lnx/CvGzCjsP0ddiAqMYirtI3chKLDaGkS8bHIMk DQKgfTuoe7iBDnnmvSvVWlYHm9hZu1y3B3WI1z/z+A9NnWnv8IWCc4sc27jMRMHpAECM 4JcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ZbynaHTp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v202-20020a6361d3000000b00412a329f2d5si5272111pgb.629.2022.07.22.02.43.10; Fri, 22 Jul 2022 02:43:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ZbynaHTp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234347AbiGVJLl (ORCPT + 99 others); Fri, 22 Jul 2022 05:11:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234769AbiGVJLD (ORCPT ); Fri, 22 Jul 2022 05:11:03 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 206CC9F079; Fri, 22 Jul 2022 02:09:32 -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 C7269B827C3; Fri, 22 Jul 2022 09:09:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1AD7AC341C6; Fri, 22 Jul 2022 09:09:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658480969; bh=aYWEnfUrdNOa/O/Hz1gNm9kJ87MT+55MM125rMDSvKA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZbynaHTpW266LAzZnaJNxGvgQwFoOpblOvHlhWKNgM+xNmve+VK/5pZPhshLLrN93 XYSmK1400Ox1nr1FeOfkvlxvY7uqoChi3Jo2C30k1FPRtm3+cHQW85K8HudoK+7qcl KkC3Y76utgSjKuVwS4nb8g80LjmwqFTSASCT32dY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Thadeu Lima de Souza Cascardo , Josh Poimboeuf Subject: [PATCH 5.18 13/70] objtool: skip non-text sections when adding return-thunk sites Date: Fri, 22 Jul 2022 11:07:08 +0200 Message-Id: <20220722090651.464856922@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220722090650.665513668@linuxfoundation.org> References: <20220722090650.665513668@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=-7.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham 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: Thadeu Lima de Souza Cascardo The .discard.text section is added in order to reserve BRK, with a temporary function just so it can give it a size. This adds a relocation to the return thunk, which objtool will add to the .return_sites section. Linking will then fail as there are references to the .discard.text section. Do not add instructions from non-text sections to the list of return thunk calls, avoiding the reference to .discard.text. Signed-off-by: Thadeu Lima de Souza Cascardo Acked-by: Josh Poimboeuf Signed-off-by: Greg Kroah-Hartman --- tools/objtool/check.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -1308,7 +1308,9 @@ static void add_return_call(struct objto insn->type = INSN_RETURN; insn->retpoline_safe = true; - list_add_tail(&insn->call_node, &file->return_thunk_list); + /* Skip the non-text sections, specially .discard ones */ + if (insn->sec->text) + list_add_tail(&insn->call_node, &file->return_thunk_list); } static bool same_function(struct instruction *insn1, struct instruction *insn2)