From patchwork Mon Jul 10 08:13:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 117698 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp4868685vqx; Mon, 10 Jul 2023 01:25:16 -0700 (PDT) X-Google-Smtp-Source: APBJJlHsohtn+bCjzo+nushxhqwFbwZcIfkZlicDxayCmucY+dXVu7Z9cMWM0nWtIC4hQDMLgMto X-Received: by 2002:a17:906:1092:b0:993:fba5:cdfa with SMTP id u18-20020a170906109200b00993fba5cdfamr4402908eju.26.1688977515762; Mon, 10 Jul 2023 01:25:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688977515; cv=none; d=google.com; s=arc-20160816; b=vKWVdh1Wr7NwH3m7hI2U3KeesvzcgFal6AGNtqfsing8Y3C5shwfFHiLKKIp1ojDGS cr1LS/F6I1NnvVGnlivMuPlTbuSbgCEN3vUpAMnzeUbhX5MfjXyy5Uih3ObX6rWCWOHi XeZfuVu3gm4G7x+hz/GjJymr/tt8Ymoc4MJKA6cH9qt0amYa4LsZc+mBVaUOJ5oZ6Rkx R3FO2lYgnmQy4zwHDRXsZJ2xBS4fH/A0x9ch63rcAqzFRcOwzaS1bU8qA0HUUnJfG/R5 6Cy82c5MGHqGXEU4IZAbuH77kkshSR3gfxO6b9PsgDWDoDBj2c5qqIrvTbxbWIWvVYzL R2MA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:cc:subject:to:reply-to:sender:from :dkim-signature:dkim-signature:date; bh=XdyazlaR2vkeRMooQSXhSLbL72/JIV9G5hPYgdB8Xxo=; fh=WrTkmvbUhUL1JAx9opISSeuQ7s/DaIYzBSQVdB2wGU4=; b=djHKNdi6NKv9P/fSrMd8qHwdNiN09AmR7wZ66PAB59gcsyF+EIyRY7wc7l5E0ULDbG miLopGdoCrNSE7gzIbTIiw2ZTkWsY9xFPuGRJd82TOTmAkQ/xnfaaZLWNaXqiLLFobGg WZuTXATKsiGaHltpRDo7R27aSxov373m74uxskRyh51t18+6EpV1y6MPF3zc7flk+990 rbAzog0vtCKHfAwgv8eE0LHsBTK8XbvI58J2rqP2f5iNIbZLu/sRcmCHlwKzFpP1MTf9 xVk6DZzrGI6DLaQnQ28BRvC+OBFq338t9/oKd3uUUXbUQam/HFJVFi9eY5Qk6RSh/2Rr vlbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=ESLdYvVq; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=2yAXpxS4; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k9-20020a1709061c0900b0099327546526si7179023ejg.506.2023.07.10.01.24.52; Mon, 10 Jul 2023 01:25:15 -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=@linutronix.de header.s=2020 header.b=ESLdYvVq; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=2yAXpxS4; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232944AbjGJIPR (ORCPT + 99 others); Mon, 10 Jul 2023 04:15:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38616 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232792AbjGJIOW (ORCPT ); Mon, 10 Jul 2023 04:14:22 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32D2C106; Mon, 10 Jul 2023 01:14:00 -0700 (PDT) Date: Mon, 10 Jul 2023 08:13:58 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1688976838; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=XdyazlaR2vkeRMooQSXhSLbL72/JIV9G5hPYgdB8Xxo=; b=ESLdYvVqX3qf0VuJmZYG/+WWs3g+Zq6ECI2+51mmYeA/C3HQ/IsfM73u03Z/NbRCrdI7v5 YU+pjY0FWmjksKPRmznLLfgQPan4yjHqCGZTMHN1nNvTtj0cYSyyBURZAYQVjYZXhh+lBm H9KFUrrcwvJaBNhpaYJmBAWkezzr5a7cHURXUaSI6CiYgtY5p61QSTt4mAQLJiKGlOxp0A GXobPzJ98mpe64X8tDq88UMvnrP9EqUu/098DFvdl1YbASIh1uozTtXlGXZJrMKL4djDTM iML3bMXOpjSF+L12dk5FxWCGIyoLVYh7PnfaQ4Jhm+tDbPPAjMB2iaeiigTAUw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1688976838; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=XdyazlaR2vkeRMooQSXhSLbL72/JIV9G5hPYgdB8Xxo=; b=2yAXpxS47/Y9AItOvG830z7uXQD8OiX5judgbtO10elNNyR1gzPBPwnJjszNBwYOYOve4H B3n0K7alH6s11WAQ== From: "tip-bot2 for Peter Zijlstra" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/urgent] x86/alternative: Rename apply_ibt_endbr() Cc: "Peter Zijlstra (Intel)" , Kees Cook , Sami Tolvanen , x86@kernel.org, linux-kernel@vger.kernel.org MIME-Version: 1.0 Message-ID: <168897683815.404.9610507600520458133.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771021287446433596 X-GMAIL-MSGID: 1771021287446433596 The following commit has been merged into the x86/urgent branch of tip: Commit-ID: be0fffa5ca894a971a31c5e28aa77b633a97d1dc Gitweb: https://git.kernel.org/tip/be0fffa5ca894a971a31c5e28aa77b633a97d1dc Author: Peter Zijlstra AuthorDate: Thu, 22 Jun 2023 15:36:50 +02:00 Committer: Peter Zijlstra CommitterDate: Mon, 10 Jul 2023 09:52:23 +02:00 x86/alternative: Rename apply_ibt_endbr() The current name doesn't reflect what it does very well. Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Kees Cook Reviewed-by: Sami Tolvanen Link: https://lkml.kernel.org/r/20230622144321.427441595%40infradead.org --- arch/um/kernel/um_arch.c | 2 +- arch/x86/include/asm/alternative.h | 2 +- arch/x86/include/asm/ibt.h | 2 +- arch/x86/kernel/alternative.c | 9 ++++++--- arch/x86/kernel/module.c | 2 +- 5 files changed, 10 insertions(+), 7 deletions(-) diff --git a/arch/um/kernel/um_arch.c b/arch/um/kernel/um_arch.c index 918fed7..b1bfed0 100644 --- a/arch/um/kernel/um_arch.c +++ b/arch/um/kernel/um_arch.c @@ -437,7 +437,7 @@ void __init arch_cpu_finalize_init(void) os_check_bugs(); } -void apply_ibt_endbr(s32 *start, s32 *end) +void apply_seal_endbr(s32 *start, s32 *end) { } diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h index 6c15a62..9c4da69 100644 --- a/arch/x86/include/asm/alternative.h +++ b/arch/x86/include/asm/alternative.h @@ -96,7 +96,7 @@ extern void alternative_instructions(void); extern void apply_alternatives(struct alt_instr *start, struct alt_instr *end); extern void apply_retpolines(s32 *start, s32 *end); extern void apply_returns(s32 *start, s32 *end); -extern void apply_ibt_endbr(s32 *start, s32 *end); +extern void apply_seal_endbr(s32 *start, s32 *end); extern void apply_fineibt(s32 *start_retpoline, s32 *end_retpoine, s32 *start_cfi, s32 *end_cfi); diff --git a/arch/x86/include/asm/ibt.h b/arch/x86/include/asm/ibt.h index baae6b4..1e59581 100644 --- a/arch/x86/include/asm/ibt.h +++ b/arch/x86/include/asm/ibt.h @@ -34,7 +34,7 @@ /* * 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()). + * apply_seal_endbr()). */ #define IBT_NOSEAL(fname) \ ".pushsection .discard.ibt_endbr_noseal\n\t" \ diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c index 72646d7..27e0cb4 100644 --- a/arch/x86/kernel/alternative.c +++ b/arch/x86/kernel/alternative.c @@ -803,7 +803,7 @@ static void __init_or_module poison_endbr(void *addr, bool warn) /* * Generated by: objtool --ibt */ -void __init_or_module noinline apply_ibt_endbr(s32 *start, s32 *end) +void __init_or_module noinline apply_seal_endbr(s32 *start, s32 *end) { s32 *s; @@ -818,7 +818,7 @@ void __init_or_module noinline apply_ibt_endbr(s32 *start, s32 *end) #else -void __init_or_module apply_ibt_endbr(s32 *start, s32 *end) { } +void __init_or_module apply_seal_endbr(s32 *start, s32 *end) { } #endif /* CONFIG_X86_KERNEL_IBT */ @@ -1565,7 +1565,10 @@ void __init alternative_instructions(void) */ callthunks_patch_builtin_calls(); - apply_ibt_endbr(__ibt_endbr_seal, __ibt_endbr_seal_end); + /* + * Seal all functions that do not have their address taken. + */ + apply_seal_endbr(__ibt_endbr_seal, __ibt_endbr_seal_end); #ifdef CONFIG_SMP /* Patch to UP if other cpus not imminent. */ diff --git a/arch/x86/kernel/module.c b/arch/x86/kernel/module.c index b05f62e..5f71a0c 100644 --- a/arch/x86/kernel/module.c +++ b/arch/x86/kernel/module.c @@ -358,7 +358,7 @@ int module_finalize(const Elf_Ehdr *hdr, } if (ibt_endbr) { void *iseg = (void *)ibt_endbr->sh_addr; - apply_ibt_endbr(iseg, iseg + ibt_endbr->sh_size); + apply_seal_endbr(iseg, iseg + ibt_endbr->sh_size); } if (locks) { void *lseg = (void *)locks->sh_addr;