Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3409043rwa; Tue, 23 Aug 2022 04:24:54 -0700 (PDT) X-Google-Smtp-Source: AA6agR4Vg/64B4v2wp3ba3bcgqpe0ZX42ZM8zYi4Eee9eE2RvPvKXg0wlzzqNpa1L39aizdN09LS X-Received: by 2002:a62:bd03:0:b0:536:150c:a1c0 with SMTP id a3-20020a62bd03000000b00536150ca1c0mr19275683pff.19.1661253893710; Tue, 23 Aug 2022 04:24:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661253893; cv=none; d=google.com; s=arc-20160816; b=JJIAkiR9XqUZIJzqy06mmm2Mp40kGcGk2knGlx8SxXJjhgq9iod3pnzl/WuTEQgwH/ 7YAHnan8F0mT31EhNNDqS2HY00k5gPkx9OawuBi1J0j+GbXwKSu7l6yMz2dCmUojYGAv oVPROt1cxxmVNtenZbJS6NY4yiGgLWk0KPqobFNKcSeTZGW3xLdXx5nNW++AbDrwJ7xs 8lKwxCUQ22ZIjE8HQLQhrvY84BGlPikYcJHKVsAf21u3ARhmDGumzX7b0n4ZWuLYb99i E5A75PzNKe8SCOYYr19Uib6IK0SWooK9+qKKMmW9cVbpLhq2cKn1BCACeE/NynmPvZ46 O4bQ== 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=DpRoliNa/ZzDA/xy3LjRJ3LqjDCqst1fDzTCVQ4NWzA=; b=b8RB2042BO6UB4pXg+GFM9fhT3CPrLL58FOd5Y3nB31K0kGkhI1ipggypWz3txwVo7 Y3G4S2vPmYhCwRdueD7i0CqpIowR1NspTPO5yBLbfIuxSuopIrNMgqh8hgHm1Wm/c8Ib x2Nink+jI4MoSOj1ElctKqualCKQj1KxtVgKOhbyiv0pkHL8u04dTbIyevifLVG2YIGz i9RE7AGnwsRnu1y0rylWSHGVFLw0AmToJEqIdrd/JoXPSODJtoDq2LysH65SLUYZw+rT JEPtQbKH0ofr85Khnn/MmpaNf1jL43mvbld/jp7sc8ZT7Ln+gfJ60w5y3LTyVkLvsW1R IHyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Yh2VrytR; 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 o12-20020a1709026b0c00b001728fede5c1si11912294plk.174.2022.08.23.04.24.42; Tue, 23 Aug 2022 04:24:53 -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=Yh2VrytR; 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 S1348852AbiHWJM5 (ORCPT + 99 others); Tue, 23 Aug 2022 05:12:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348541AbiHWJKb (ORCPT ); Tue, 23 Aug 2022 05:10:31 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3322A86B50; Tue, 23 Aug 2022 01:31:10 -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 D5A2461360; Tue, 23 Aug 2022 08:29:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CA772C433D6; Tue, 23 Aug 2022 08:29:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661243370; bh=1BYEHRjVREcdMBhA1wsIgbziwPW+7xcj9xwgN5GfgxI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Yh2VrytR7Rzph++QiFko1yOytd48rk6zxHoA2xATrelJZ4qg/ARrFsXEHSPym9PVX tcVdBd5UUH8G57DPRpYgvMTAKWoePrxBuFlbBkoDNZ92EFA/IMrSE2oUj6AEtsINKD yOCAxjcLdSsJhBr/Hgv2YcJbJeSrpfk3mJlnjEP8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Josh Poimboeuf , Paolo Bonzini , Sasha Levin Subject: [PATCH 5.19 255/365] x86/ibt, objtool: Add IBT_NOSEAL() Date: Tue, 23 Aug 2022 10:02:36 +0200 Message-Id: <20220823080128.867380224@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080118.128342613@linuxfoundation.org> References: <20220823080118.128342613@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 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 [ Upstream commit e27e5bea956ce4d3eb15112de5fa5a3b77c2f488 ] Add a macro which prevents a function from getting sealed if there are no compile-time references to it. Signed-off-by: Josh Poimboeuf Message-Id: <20220818213927.e44fmxkoq4yj6ybn@treble> Signed-off-by: Paolo Bonzini Signed-off-by: Sasha Levin --- arch/x86/include/asm/ibt.h | 11 +++++++++++ tools/objtool/check.c | 3 ++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/arch/x86/include/asm/ibt.h b/arch/x86/include/asm/ibt.h index 689880eca9ba..9b08082a5d9f 100644 --- a/arch/x86/include/asm/ibt.h +++ b/arch/x86/include/asm/ibt.h @@ -31,6 +31,16 @@ #define __noendbr __attribute__((nocf_check)) +/* + * Create a dummy function pointer reference to prevent objtool from marking + * the function as needing to be "sealed" (i.e. ENDBR converted to NOP by + * apply_ibt_endbr()). + */ +#define IBT_NOSEAL(fname) \ + ".pushsection .discard.ibt_endbr_noseal\n\t" \ + _ASM_PTR fname "\n\t" \ + ".popsection\n\t" + static inline __attribute_const__ u32 gen_endbr(void) { u32 endbr; @@ -84,6 +94,7 @@ extern __noendbr void ibt_restore(u64 save); #ifndef __ASSEMBLY__ #define ASM_ENDBR +#define IBT_NOSEAL(name) #define __noendbr diff --git a/tools/objtool/check.c b/tools/objtool/check.c index b341f8a8c7c5..31c719f99f66 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -4096,7 +4096,8 @@ static int validate_ibt(struct objtool_file *file) * These sections can reference text addresses, but not with * the intent to indirect branch to them. */ - if (!strncmp(sec->name, ".discard", 8) || + if ((!strncmp(sec->name, ".discard", 8) && + strcmp(sec->name, ".discard.ibt_endbr_noseal")) || !strncmp(sec->name, ".debug", 6) || !strcmp(sec->name, ".altinstructions") || !strcmp(sec->name, ".ibt_endbr_seal") || -- 2.35.1