Received: by 2002:ac0:da4c:0:0:0:0:0 with SMTP id a12csp1368664imi; Sat, 23 Jul 2022 03:54:11 -0700 (PDT) X-Google-Smtp-Source: AGRyM1t8qAJG8aYspfwmMQZvNUh/p2B7n1dq70FLnDmBpsB4aS7/9Nusf7CUrhjLdGtUIfDLxToB X-Received: by 2002:a62:3346:0:b0:52a:c0cb:ae8 with SMTP id z67-20020a623346000000b0052ac0cb0ae8mr4142671pfz.37.1658573650812; Sat, 23 Jul 2022 03:54:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658573650; cv=none; d=google.com; s=arc-20160816; b=F0Lz8Rsj88eorT9BRIh07+plaxe2DT2hYDqNz/2Or/ruiJaHuix/kUKQUh2Zdq+VKg tYeYfIruToJvBOj4xaKiTAbxnN/PkWCM+wm1nRyKEkIJFEKL7B/hjuBTN1eGNDtpySGo DcumoVjYec9wCiTeykxyICVqFnfB12qHp2GC2KXQ7xO8hF1NjmVxcl9zaePjw+W12Jaf FQgMohZLJYsoAVLmQP6N+JtV7zrsxxp4/RHCB1lVUq75QtuECoYDOgxZ5hL6TDUb+Vcj /H9FYrlZXxruAW3ySKSiGtSSJTpS4M6kgmNFYVOdGrEMRN4C96odWqfktytwoxRcRsLx lgxw== 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=BAWaLPZPBJe/Gh/oiIvyH6/wvqFOek26rY6bLLRwU8s=; b=N3xkK4eTcEqAl+8Xcizr3uZe3P3xqrt7REqgSfF15fsdfUxmh2bs0MzE/ch0nZ3H0v rtSOMl2RVpXMmywqRobF4pY5qmFdhkm+OrfQrgr4HVlyAQN2yPXyZUWylWC9U4NlhINW 3yg7bof9dDKa0F4LusaiWyq/u6FaXCwhkzgNlDdqbQatdzpKpUAJSWyzb2FIUjjBabfT ts3g4v6HeT/FjmutmxlNpiTp/VT8ApNnmUaY5btZP9mLDLwXSOn8MXBxJAxupumEVAp2 98V9c520+IqRUpYxU/u/g7c/i1NZrs2BcjYnXj2tEvNhfAu66Q32gXcGN8deIm5SwQbW 3s2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=PbrzQCqu; 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 ay8-20020a1709028b8800b0016c192735f1si7481312plb.220.2022.07.23.03.53.55; Sat, 23 Jul 2022 03:54:10 -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=PbrzQCqu; 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 S238562AbiGWKGN (ORCPT + 99 others); Sat, 23 Jul 2022 06:06:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238410AbiGWKFz (ORCPT ); Sat, 23 Jul 2022 06:05:55 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC2EBA0273; Sat, 23 Jul 2022 03:00:31 -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 07FE4611D4; Sat, 23 Jul 2022 10:00:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0CA36C341C7; Sat, 23 Jul 2022 10:00:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658570430; bh=0A1ecswK9RXwOpzgxQteXqxtREg2wIgo60mGWUG+KJs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PbrzQCquYevCfV4MN2H93gXuVrji3QjFfqsGj2tOnZu0+SxoHZz+JeZRmDU34zO8P /EnOyv7jGVSeRoDymp+4OTI9CPoQjxlKJbs/p4nsnqGhAnHWO4p1aUq/dI2CLTDNvI wL9jmyhOr1oHwB5SEweXM3MXf2Z800NXnN9xYq0k= 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 , Ben Hutchings Subject: [PATCH 5.10 086/148] objtool: skip non-text sections when adding return-thunk sites Date: Sat, 23 Jul 2022 11:54:58 +0200 Message-Id: <20220723095248.478393950@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220723095224.302504400@linuxfoundation.org> References: <20220723095224.302504400@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: Ben Hutchings 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 @@ -1090,7 +1090,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); } /*