Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4817imw; Tue, 12 Jul 2022 13:23:30 -0700 (PDT) X-Google-Smtp-Source: AGRyM1s/0UM4oJTGv7FK8uxmugdFHs64UgJMz2xjZQM0eAIh5b5W8FAqxGRFPv/T4RP1URcSB9j4 X-Received: by 2002:a05:6402:371a:b0:43a:ece9:ab8e with SMTP id ek26-20020a056402371a00b0043aece9ab8emr6846985edb.126.1657656902408; Tue, 12 Jul 2022 13:15:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657656902; cv=none; d=google.com; s=arc-20160816; b=1F/BRncm7loIECOXbhgMD88uIY4OqKktor2FveI09iJuoxX1yVTO6SdH5gUVO8j9JG D8mGUYccxfdSEj6XPpngIlqpMIvuIWRIJZo+f8V5W5zV6vSbM4a6k43Cy+HenJO7PhqI NGt6aFtCSIpIf7AE7xbuleFKIS38EYbWzwvE/Li8ED5RGVXBKhrcPSh9KVM3FpQVYWFS F5Cvu/NCPaJabtPQ1KwO9DoQiI7xGd6JOYnZd0SkXTOducd6VwDMBAi8A9SIkj5KUiiJ uA6F9nJNqo13BsURu0exJr0BK3yPzBHAN9SLeR89+Xx0PMCAAKcl4RBib43cefdriInz kvlQ== 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=aO+NUXDB1/Mq/CQiFj7Fi02K1tCUAtVvVsEHRrNOxU8QRzH6asn1lC/xQNKNxB3Jfd Bi9NJxHpXtjzbpcD24dxH5oOn6lkfGSsAYJNezrqIkyDOofCDltaQqdaM+/iwwUWrkcT 96lJO7A+yEEYDOCp6DUx8WmcjCad4NM7Oq2wqZrZywQdtFbHx3daaErT2WrNBd5Q6Vi6 IRt7sUqJLrLJIFAkJclscMPwZFR+vb6nPNQlZlxoScNWnbfNxk9rAt7SinQoOA04mcoa 75vbFyeRlzf/fRbPQzahSHVsxsXYeVHbRodq2mL5KOjIbudIc1sakciTk6TUbEMDAi7F P2Fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="VpYfhLR/"; 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 e20-20020a056402191400b0043ad5210bb1si10974413edz.294.2022.07.12.13.14.04; Tue, 12 Jul 2022 13:15:02 -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="VpYfhLR/"; 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 S235500AbiGLTM1 (ORCPT + 99 others); Tue, 12 Jul 2022 15:12:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235102AbiGLTLp (ORCPT ); Tue, 12 Jul 2022 15:11:45 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC1F61020BC; Tue, 12 Jul 2022 11:53:03 -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 5DBF0B81B96; Tue, 12 Jul 2022 18:53:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B36D4C3411C; Tue, 12 Jul 2022 18:53:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657651981; bh=aYWEnfUrdNOa/O/Hz1gNm9kJ87MT+55MM125rMDSvKA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VpYfhLR/M2XRvRnbJylyq621QHpfnU5SvAzoj+YC16ppL7c3hlzjL+B5Pmls8gGab My2RX4JWF5tlfcb8Gg+AH4CIh87MJMmdTwy/z80Ibb8OKOPcSSveoqKkx/9+NTJU/o Zx1rhtJaYPf8G6CL6AAXI9tESJqEpU568hLOTnhQ= 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/61] objtool: skip non-text sections when adding return-thunk sites Date: Tue, 12 Jul 2022 20:39:10 +0200 Message-Id: <20220712183237.480998789@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220712183236.931648980@linuxfoundation.org> References: <20220712183236.931648980@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.7 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,T_SCC_BODY_TEXT_LINE 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)