From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 98E6EC282D1 for ; Mon, 3 Mar 2025 16:37:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 321B3280007; Mon, 3 Mar 2025 11:37:44 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2A914280002; Mon, 3 Mar 2025 11:37:44 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 12313280007; Mon, 3 Mar 2025 11:37:44 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id E2B2D280002 for ; Mon, 3 Mar 2025 11:37:43 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 7AA5D80C62 for ; Mon, 3 Mar 2025 16:37:43 +0000 (UTC) X-FDA: 83180796006.04.130B795 Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) by imf23.hostedemail.com (Postfix) with ESMTP id E38B7140007 for ; Mon, 3 Mar 2025 16:37:41 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=ijvmFAyU; spf=pass (imf23.hostedemail.com: domain of kees@kernel.org designates 172.105.4.254 as permitted sender) smtp.mailfrom=kees@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1741019861; h=from:from:sender: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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=zn3UW3fQqTdcBIGLP+cMPC+71EGyfyASh2TuybBedYI=; b=sNU6bTyOG2nErTkW7UulpiqhY9Mnh+AC7lil3rrcXIXNn+PcOSPRLuTyxv6BjAXMar9zDr kVEUtoZ98aSh0TL3OERmWom4rkmad5BCYc7OYtEy+8lfLmCg8YLB7ZNSm7OvsKKp1YZiRb cvoCYdM7mZNTZ6JV+BxJGzpHHddjfnU= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=ijvmFAyU; spf=pass (imf23.hostedemail.com: domain of kees@kernel.org designates 172.105.4.254 as permitted sender) smtp.mailfrom=kees@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1741019861; a=rsa-sha256; cv=none; b=b1tZUo06s9CcxSY4DZBLvREMuGKoSagF9pSEzFhq4BLvf2OyGAODIatrefKc/R2rD6G5fZ vLSDnTdRjiJ9Tbud0OsmX1DTh/wuRYx/ff9JORAa6AbTSkMU20X1ldy/HsZXB95dji2JRY uFpTTjqUlZCBStZH9UoqH3NI6nnRiOg= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by tor.source.kernel.org (Postfix) with ESMTP id 6496B61211; Mon, 3 Mar 2025 16:37:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E5788C4CED6; Mon, 3 Mar 2025 16:37:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1741019861; bh=wDHTqD18VJeK7bkhgbzWlBYq/asXp0P6f/1nzXKv+78=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ijvmFAyUUslcjV1ax8ZG8N6P7LJ5qri2oVMmR5muyymSwPK4OyFCR7mSJ+zrONlCf 8rW/XEGBGQD49Dsw8L0+xKH+TrmjecLu3C2Gp3VNDFwvThsbyJiYNUJt2RfyMWh172 VIbgILO8pHCB4f3jPUjTV4nXJvRWR9+EJs9rqzfbmMDp+HZH7yx2R4RNCUMXZ0W1rx HvlhXj0maYz22CmjSyjpjgqmaYAdxco+6hZHgrxa0UAAUjOseBbJwSWx9e/uN3pdIB aV4xp8D8/HiUswm4DP0uuCtc37ibLrtzAJ8Ksp5ddrMfksUVkiG0iWu8DayWyCymKG iPPYlZr00/Rxw== Date: Mon, 3 Mar 2025 08:37:37 -0800 From: Kees Cook To: jeffxu@chromium.org Cc: akpm@linux-foundation.org, jannh@google.com, torvalds@linux-foundation.org, vbabka@suse.cz, lorenzo.stoakes@oracle.com, Liam.Howlett@oracle.com, adhemerval.zanella@linaro.org, oleg@redhat.com, avagin@gmail.com, benjamin@sipsolutions.net, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, jorgelo@chromium.org, sroettger@google.com, hch@lst.de, ojeda@kernel.org, thomas.weissschuh@linutronix.de, adobriyan@gmail.com, johannes@sipsolutions.net, pedro.falcato@gmail.com, hca@linux.ibm.com, willy@infradead.org, anna-maria@linutronix.de, mark.rutland@arm.com, linus.walleij@linaro.org, Jason@zx2c4.com, deller@gmx.de, rdunlap@infradead.org, davem@davemloft.net, peterx@redhat.com, f.fainelli@gmail.com, gerg@kernel.org, dave.hansen@linux.intel.com, mingo@kernel.org, ardb@kernel.org, mhocko@suse.com, 42.hyeyoo@gmail.com, peterz@infradead.org, ardb@google.com, enh@google.com, rientjes@google.com, groeck@chromium.org, mpe@ellerman.id.au, aleksandr.mikhalitsyn@canonical.com, mike.rapoport@gmail.com Subject: Re: [PATCH v8 1/7] mseal sysmap: kernel config and header change Message-ID: <202503030834.C4ED5911A@keescook> References: <20250303050921.3033083-1-jeffxu@google.com> <20250303050921.3033083-2-jeffxu@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20250303050921.3033083-2-jeffxu@google.com> X-Rspam-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mzXjSLmd52O Tt5SZqjy F+Rx4xQD9O+yCZv2J5hTc6n8m3xBCE5LimisujVop2Q7QbuVx+ZYs/NFK1ioi8tSuckFR9PuXT/lwrUMU+krgSWW1NrRfM1UJJa7nCAmC6RQ2TwLkxbxelHfih6hiK5W5Dn9cctnM9ii/JexUeLJlJWwFFFjsSTkSdKpnZ4Nut1YN8tXE05y2vhjKs8s3qEL0eaTu1oO3EgdaTWxwUj5ztqjLxqwtt8CIYWs7TLF0lZE2mFSVI5ExTJuN+5YeU0ezCoB6zGCFhDoeKcwGyA+7Pc7PBXlpOejxLFsjLz1b7JEqGqffUsdH88DLQGMexuuza8FTlSOjYYXKAe2UwbLRLB77u+J9Afgvizkdv9Fw65NNfFUEyTNW0RSvrQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Mon, Mar 03, 2025 at 05:09:15AM +0000, jeffxu@chromium.org wrote: > From: Jeff Xu > > Provide infrastructure to mseal system mappings. Establish > two kernel configs (CONFIG_MSEAL_SYSTEM_MAPPINGS, > ARCH_SUPPORTS_MSEAL_SYSTEM_MAPPINGS) and VM_SEALED_SYSMAP > macro for future patches. > > Signed-off-by: Jeff Xu > --- > include/linux/mm.h | 10 ++++++++++ > init/Kconfig | 22 ++++++++++++++++++++++ > security/Kconfig | 21 +++++++++++++++++++++ > 3 files changed, 53 insertions(+) > > diff --git a/include/linux/mm.h b/include/linux/mm.h > index 7b1068ddcbb7..8b800941678d 100644 > --- a/include/linux/mm.h > +++ b/include/linux/mm.h > @@ -4155,4 +4155,14 @@ int arch_get_shadow_stack_status(struct task_struct *t, unsigned long __user *st > int arch_set_shadow_stack_status(struct task_struct *t, unsigned long status); > int arch_lock_shadow_stack_status(struct task_struct *t, unsigned long status); > > + > +/* > + * mseal of userspace process's system mappings. > + */ > +#ifdef CONFIG_MSEAL_SYSTEM_MAPPINGS > +#define VM_SEALED_SYSMAP VM_SEALED > +#else > +#define VM_SEALED_SYSMAP VM_NONE > +#endif > + > #endif /* _LINUX_MM_H */ > diff --git a/init/Kconfig b/init/Kconfig > index d0d021b3fa3b..c90dd8778993 100644 > --- a/init/Kconfig > +++ b/init/Kconfig > @@ -1882,6 +1882,28 @@ config ARCH_HAS_MEMBARRIER_CALLBACKS > config ARCH_HAS_MEMBARRIER_SYNC_CORE > bool > > +config ARCH_SUPPORTS_MSEAL_SYSTEM_MAPPINGS > + bool > + help > + Control MSEAL_SYSTEM_MAPPINGS access based on architecture. > + > + A 64-bit kernel is required for the memory sealing feature. > + No specific hardware features from the CPU are needed. > + > + To enable this feature, the architecture needs to update their > + special mappings calls to include the sealing flag and confirm > + that it doesn't unmap/remap system mappings during the life > + time of the process. The existence of this flag for an architecture > + implies that it does not require the remapping of thest system typo nit: "the" instead of "thest" > + mappings during process lifetime, so sealing these mappings is safe > + from a kernel perspective. > + > + After the architecture enables this, a distribution can set > + CONFIG_MSEAL_SYSTEM_MAPPING to manage access to the feature. > + > + For complete descriptions of memory sealing, please see > + Documentation/userspace-api/mseal.rst > + > config HAVE_PERF_EVENTS > bool > help > diff --git a/security/Kconfig b/security/Kconfig > index f10dbf15c294..5311f4a6786c 100644 > --- a/security/Kconfig > +++ b/security/Kconfig > @@ -51,6 +51,27 @@ config PROC_MEM_NO_FORCE > > endchoice > > +config MSEAL_SYSTEM_MAPPINGS > + bool "mseal system mappings" > + depends on 64BIT > + depends on ARCH_SUPPORTS_MSEAL_SYSTEM_MAPPINGS > + depends on !CHECKPOINT_RESTORE > + help > + Apply mseal on system mappings. > + The system mappings includes vdso, vvar, vvar_vclock, > + vectors (arm compact-mode), sigpage (arm compact-mode), uprobes. typo nits: "compat" instead of "compact". > + > + A 64-bit kernel is required for the memory sealing feature. > + No specific hardware features from the CPU are needed. > + > + WARNING: This feature breaks programs which rely on relocating > + or unmapping system mappings. Known broken software at the time > + of writing includes CHECKPOINT_RESTORE, UML, gVisor, rr. Therefore > + this config can't be enabled universally. > + > + For complete descriptions of memory sealing, please see > + Documentation/userspace-api/mseal.rst > + > config SECURITY > bool "Enable different security models" > depends on SYSFS > -- > 2.48.1.711.g2feabab25a-goog > Perhaps akpm can fix these up directly instead of a v9 spin? But otherwise, yes, reads well to me: Reviewed-by: Kees Cook -- Kees Cook