Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4700990imw; Tue, 12 Jul 2022 12:41:11 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sxeoS6sU5iwlkAJty1vPF556sfZcz/14nckTwEksczTEpEt41JuNoUGiA9VcvQ9rc5vgZ7 X-Received: by 2002:a17:90b:1d87:b0:1f0:6c87:fc8 with SMTP id pf7-20020a17090b1d8700b001f06c870fc8mr3490670pjb.173.1657654871308; Tue, 12 Jul 2022 12:41:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657654871; cv=none; d=google.com; s=arc-20160816; b=w+Mkc1aCxkTIbljK7wfLKZCmIREdWpuuTfQOOYMLKCTHwKrat14uNESNMIUHsbVWrq eOhS+TvRIZQiVfcG5kpxarsTZXzjLVkeyfsWTq2sKpWHfYIa0KmO2fupinZW+u/3VmTe UYoUEjKXlLAlOR+8yN3En9GA15KuRt7BoW9O0yHUI4DAf50tXnuNSi+SKejT4KZmgkIY 87e66EgBCbEgTGsFx8Cyr9duWhoRs8Ti4l4JLH0Tg7COL+6Qh2cr4dC4oJtQBjuRxen+ Byct1/HS3fTJjbjUurxGjWjqTyi6HYAeTLPsJOKlxfbIe7+edDx0PU4O5wME1UmIdnDa kuQw== 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=zSzQRMCwioZ61B3vWSYvcaTl50wIXErzc6lm4fXjtDk=; b=WApv42IyQ2zBrO5m12Rk2mQQ2sl3WqHl86sHqPZEIoIYYfpondGjPzDinsFsxz+8lj PHIXSQOsgXknXR7wasOLxUY70QhqWd/8OlJSiSTLxtcu9+0tilZ7alg1t+Gpdi/UvJnB t34TXspPs5ANQpbrRX5hOwVVusw3w73WgrnEWBXaExlgDjBWHJ7R/oTrxcvi8kOqmtgQ Pnj6J6xnd8q9isuDlBOfPvFYH5gkTFeUyZtxFaWX97XqYRq56fK/UfeRT0oydG+Z4afO SwQ6xsOLO3bXr2SH4Ow5axDaiNUhWxrUkZC8YwRoIm3zQz4uqGt1gQkheJEbKL8vfmr7 N7yA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=xkhkjcGy; 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 d11-20020a170902728b00b0016bdf4bb1f9si12450291pll.202.2022.07.12.12.40.59; Tue, 12 Jul 2022 12:41:11 -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=xkhkjcGy; 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 S233688AbiGLSkq (ORCPT + 99 others); Tue, 12 Jul 2022 14:40:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233738AbiGLSkf (ORCPT ); Tue, 12 Jul 2022 14:40:35 -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 22F23C1779; Tue, 12 Jul 2022 11:40:33 -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 9EBB361ACE; Tue, 12 Jul 2022 18:40:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 92C17C3411C; Tue, 12 Jul 2022 18:40:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657651232; bh=7XZ89n0r+YQreOjHqIUzWGHyoEFUcZJ1T7G3vKlv2/s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xkhkjcGyXQ0bUA+Y2MQqoap0+Gbd0I2Uw3D9zCBeA5ikgI99DAW8Zo8w3BJPfR5e7 FaJ0qTNvanwrHVC34hhvwUgYZCPDIaUP4pvl40uT2JAppWZ0hHd2PU7ZmxqLX8RgTB wqlm85rwrKFRiHoy2FBj+x+djYPSuAGsIEQB2Q/0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Josh Poimboeuf , Ben Hutchings Subject: [PATCH 5.10 006/130] objtool: Support retpoline jump detection for vmlinux.o Date: Tue, 12 Jul 2022 20:37:32 +0200 Message-Id: <20220712183246.677303877@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220712183246.394947160@linuxfoundation.org> References: <20220712183246.394947160@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: Josh Poimboeuf commit 31a7424bc58063a8e0466c3c10f31a52ec2be4f6 upstream. Objtool converts direct retpoline jumps to type INSN_JUMP_DYNAMIC, since that's what they are semantically. That conversion doesn't work in vmlinux.o validation because the indirect thunk function is present in the object, so the intra-object jump check succeeds before the retpoline jump check gets a chance. Rearrange the checks: check for a retpoline jump before checking for an intra-object jump. Signed-off-by: Josh Poimboeuf Link: https://lore.kernel.org/r/4302893513770dde68ddc22a9d6a2a04aca491dd.1611263461.git.jpoimboe@redhat.com Signed-off-by: Ben Hutchings Signed-off-by: Greg Kroah-Hartman --- tools/objtool/check.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -795,10 +795,6 @@ static int add_jump_destinations(struct } else if (reloc->sym->type == STT_SECTION) { dest_sec = reloc->sym->sec; dest_off = arch_dest_reloc_offset(reloc->addend); - } else if (reloc->sym->sec->idx) { - dest_sec = reloc->sym->sec; - dest_off = reloc->sym->sym.st_value + - arch_dest_reloc_offset(reloc->addend); } else if (!strncmp(reloc->sym->name, "__x86_indirect_thunk_", 21) || !strncmp(reloc->sym->name, "__x86_retpoline_", 16)) { /* @@ -812,6 +808,10 @@ static int add_jump_destinations(struct insn->retpoline_safe = true; continue; + } else if (reloc->sym->sec->idx) { + dest_sec = reloc->sym->sec; + dest_off = reloc->sym->sym.st_value + + arch_dest_reloc_offset(reloc->addend); } else { /* external sibling call */ insn->call_dest = reloc->sym;