Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp1654493lqa; Mon, 29 Apr 2024 15:17:00 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUvxL9HG0Hdpk+jlw/nHdMyRCwrqvU4XKZ+9wOCOYYHR1c4AgWmgZKOFHMw+31HV8rrqyTIuiaEcDvc8K5y5rNn7m3HxQaXjrfjfBwA9A== X-Google-Smtp-Source: AGHT+IGFeLEO3DDfzKYUBFKhQJMgdZSyBxyXxW94ZAqYPUHDMFgn3D1jRpmTZO8Px7WTJinB+T6+ X-Received: by 2002:a05:6a21:144c:b0:1a7:1b6e:4d4 with SMTP id oc12-20020a056a21144c00b001a71b6e04d4mr9026287pzb.23.1714429020472; Mon, 29 Apr 2024 15:17:00 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714429020; cv=pass; d=google.com; s=arc-20160816; b=HkyiG8cwqPU6T8lQzwXlYcsDHLONHKfq+HbYm7jl+Zo5+5Pa1HvH56BeA23hXV0BvM b+/3VM8LhtypI8yERt9es1rDrBt5/jva5uTA5HeihUzry6wCsyxMsaLz39JRDnaEtG4v 7RlNk5r+S/xSWbAUmfipDY3QMhF3fkD9BaCtMIttBJLSHyvSNtglweddLmnITqCqClBK R9j5kRxhEoYtSN7c7fnueetNtdQ4vsa+w72xuCab3J+6ZE3E6hsjnFE8Ei8/T8c9iFGO swHac9qO9qeEORVHoL8Invy42asg57p3Iul+/PxiHY2MBbB9/Z4zxs/0oEtvc4pRFPAo nfiQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=c8uEBDLq88AS4K1JhQOg0DRnmQ4DCJgU9UqYKulI7vo=; fh=kwwrvw0xSZ6oTmSykbLxRyMLWv+9OtCJSoowz1oXewk=; b=iSHGCliCOSJlCw6qsyBDnP/dyR0JraPB88A5WrwrV0SdnSiLZNMBKruD/WBsW5NDKb xGCuSUCsLLPlAwt7A+mlJ23iX09y+zrvct0rtYTCngjE91EbOmJjZ8WJNYFmal25rDw1 FUxXOWRGoJk/CTYhX0thOCn/YEavPBL3mw0ClQa5Uj5PS9K/qJk5CqHGs2gOoo5KcdcN D9gz1eNrNQU39ao0ONjGrXPztLl8x7SDZmBHrzBrh0QVyb06oa3tOFTlfK2wogesKGdv rfjK8S8QMqknX7abF7EWWXcpp0trLG9PtScHFAAN6FHvomK9SYpnUTyI7Z5YIfDY4xH0 KICg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=AE1ScLev; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-163093-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-163093-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id ff17-20020a056a002f5100b006ecbe857186si20280356pfb.242.2024.04.29.15.17.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 15:17:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-163093-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=AE1ScLev; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-163093-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-163093-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id E0A7B283359 for ; Mon, 29 Apr 2024 22:16:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CB579194C61; Mon, 29 Apr 2024 22:16:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="AE1ScLev" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EBF8017798F; Mon, 29 Apr 2024 22:16:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714429014; cv=none; b=rCucBmI1BRERp1V7Yl0ZKORdv7/4LSCSEjXb7OtWvgsHLtrtsHF64h4BOtf5allvqdKGi9c3GPIohkZ4x1rKAP/xwPPkVM2cGT7iuLT3Ynz0QPtlo8hKmpTc+BDkjSCv+dgBAK81vhQVJzXJrqAzcqJCIv98GBqTmbGH/UHQVj4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714429014; c=relaxed/simple; bh=sM12wNpxyClzIujECU2Q2Xq0Fp03wR6ElrAkPU8LTJE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=k0EPSmQ5BpBtQg1zoVNxP6H1v6ZDa7yKS8SALHqOWc/IqySRPRKReQcUYWOP6knpfm9m9pRlaf25CoLHEjjnlAh1Z6qXbYRhkPQ1N+fi7OCKMm18pxkZJTW8oIjtpgdpxIL/ymneR/L92M1tOolKwMYyecX6gxj1zkuMWPI8/Uo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=AE1ScLev; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7DF9AC113CD; Mon, 29 Apr 2024 22:16:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714429013; bh=sM12wNpxyClzIujECU2Q2Xq0Fp03wR6ElrAkPU8LTJE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=AE1ScLevghQRxQ4qCrFsi9uVrMVHe0DLu4Fi/opB2QweZCJaOCcNoj2YYHHt9thz9 OcNY7C5Z3n0iQWyNGzwz56muSCRYaNXZ8oBvZSXpMnzO+MgjyRx2jIF2hB5Y/cmyTo m/wpaUuexq+73sniwy1mApDi33fXdLHpVnz03b44dFGEr9mNhZTSv7PDS69z9ySIDh jP3ikArks0EEvjdH8fM536Qivg8+lYUYPQXlFc8MlpW2w9VAKb+9rbjeSryEb4prFF PxAA0zNei5LqRS91RkxXZJGXGOUVPG4obGjO1WWzq1ErlpDec91w5ye2wl5xuAn1PH 2PKJqWxdYTT4g== Date: Mon, 29 Apr 2024 15:16:50 -0700 From: Nathan Chancellor To: Kees Cook Cc: "Gustavo A. R. Silva" , Catalin Marinas , Will Deacon , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Nick Desaulniers , Bill Wendling , Justin Stitt , linux-hardening@vger.kernel.org, linux-arm-kernel@lists.infradead.org, llvm@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCH] hardening: Refresh KCFI options, add some more Message-ID: <20240429221650.GA3666021@dev-arch.thelio-3990X> References: <20240426222940.work.884-kees@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240426222940.work.884-kees@kernel.org> On Fri, Apr 26, 2024 at 03:29:44PM -0700, Kees Cook wrote: > Add some stuff that got missed along the way: > > - CONFIG_UNWIND_PATCH_PAC_INTO_SCS=y so SCS vs PAC is hardware > selectable. > > - CONFIG_X86_KERNEL_IBT=y while a default, just be sure. > > - CONFIG_CFI_CLANG=y for x86 and arm64. (And disable FINEIBT since > it isn't as secure as straight KCFI.) > > - CONFIG_PAGE_TABLE_CHECK=y for userspace mapping sanity. > > Signed-off-by: Kees Cook Seems reasonable to me. Reviewed-by: Nathan Chancellor One comment below. > --- > Cc: "Gustavo A. R. Silva" > Cc: Catalin Marinas > Cc: Will Deacon > Cc: Thomas Gleixner > Cc: Ingo Molnar > Cc: Borislav Petkov > Cc: Dave Hansen > Cc: x86@kernel.org > Cc: "H. Peter Anvin" > Cc: Nathan Chancellor > Cc: Nick Desaulniers > Cc: Bill Wendling > Cc: Justin Stitt > Cc: linux-hardening@vger.kernel.org > Cc: linux-arm-kernel@lists.infradead.org > Cc: llvm@lists.linux.dev > --- > arch/arm64/configs/hardening.config | 5 +++++ > arch/x86/configs/hardening.config | 9 +++++++++ > kernel/configs/hardening.config | 4 ++++ > 3 files changed, 18 insertions(+) > > diff --git a/arch/arm64/configs/hardening.config b/arch/arm64/configs/hardening.config > index b0e795208998..e8a18fec7a3e 100644 > --- a/arch/arm64/configs/hardening.config > +++ b/arch/arm64/configs/hardening.config > @@ -5,6 +5,7 @@ CONFIG_ARM64_SW_TTBR0_PAN=y > > # Software Shadow Stack or PAC > CONFIG_SHADOW_CALL_STACK=y > +CONFIG_UNWIND_PATCH_PAC_INTO_SCS=y > > # Pointer authentication (ARMv8.3 and later). If hardware actually supports > # it, one can turn off CONFIG_STACKPROTECTOR_STRONG with this enabled. > @@ -20,3 +21,7 @@ CONFIG_ARM64_E0PD=y > > # Available in ARMv8.7 and later. > CONFIG_ARM64_EPAN=y > + > +# Enable Kernel Control Flow Integrity (currently Clang only). > +CONFIG_CFI_CLANG=y > +# CONFIG_CFI_PERMISSIVE is not set Should this be a part of kernel/configs/hardening.config because RISC-V supports it (and 32-bit ARM will soon too)? > diff --git a/arch/x86/configs/hardening.config b/arch/x86/configs/hardening.config > index 7b497f3b7bc3..b47e5f411dd3 100644 > --- a/arch/x86/configs/hardening.config > +++ b/arch/x86/configs/hardening.config > @@ -10,5 +10,14 @@ CONFIG_INTEL_IOMMU_DEFAULT_ON=y > CONFIG_INTEL_IOMMU_SVM=y > CONFIG_AMD_IOMMU=y > > +# Enforce CET Indirect Branch Tracking in the kernel. > +CONFIG_X86_KERNEL_IBT=y > + > +# Enable Kernel Control Flow Integrity (currently Clang only), but disable > +# weaker FINEIBT landing pads. > +CONFIG_CFI_CLANG=y > +# CONFIG_CFI_PERMISSIVE is not set > +# CONFIG_FINEIBT is not set > + > # Enable CET Shadow Stack for userspace. > CONFIG_X86_USER_SHADOW_STACK=y > diff --git a/kernel/configs/hardening.config b/kernel/configs/hardening.config > index 7a5bbfc024b7..4be0de1f085c 100644 > --- a/kernel/configs/hardening.config > +++ b/kernel/configs/hardening.config > @@ -23,6 +23,10 @@ CONFIG_SLAB_FREELIST_HARDENED=y > CONFIG_SHUFFLE_PAGE_ALLOCATOR=y > CONFIG_RANDOM_KMALLOC_CACHES=y > > +# Sanity check userspace page table mappings. > +CONFIG_PAGE_TABLE_CHECK=y > +CONFIG_PAGE_TABLE_CHECK_ENFORCED=y > + > # Randomize kernel stack offset on syscall entry. > CONFIG_RANDOMIZE_KSTACK_OFFSET_DEFAULT=y > > -- > 2.34.1 >