From patchwork Mon Nov 25 20:20:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Xu X-Patchwork-Id: 13885253 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 6B7A6D59D67 for ; Mon, 25 Nov 2024 20:20:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F02696B0092; Mon, 25 Nov 2024 15:20:34 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E95636B0093; Mon, 25 Nov 2024 15:20:34 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C68E06B0095; Mon, 25 Nov 2024 15:20:34 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id A4D5E6B0092 for ; Mon, 25 Nov 2024 15:20:34 -0500 (EST) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 62B54AD252 for ; Mon, 25 Nov 2024 20:20:34 +0000 (UTC) X-FDA: 82825734978.07.B083704 Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.42]) by imf09.hostedemail.com (Postfix) with ESMTP id E28F314001B for ; Mon, 25 Nov 2024 20:20:29 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=gOnTzzaY; spf=pass (imf09.hostedemail.com: domain of jeffxu@chromium.org designates 209.85.216.42 as permitted sender) smtp.mailfrom=jeffxu@chromium.org; dmarc=pass (policy=none) header.from=chromium.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1732566029; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=ck8iNHlaINiOxwziQMas9mEee03tDCqdu64rqgP3RtY=; b=KWpyeK2bfymORjhv33cKle3+hHUw8Ar7naa0Jf4mXAcRDkheC8JOkeKpY03+X/MXcZu0M0 ceECFPqUPTkiLDo7dVTUhg22mL25ONzCsJTrWTERNQFgpM1QFQVXl/r8VeMfF9vohzdpYf mzzgcaEkrlBZjAw7XIBdQZLrNaytGWI= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=gOnTzzaY; spf=pass (imf09.hostedemail.com: domain of jeffxu@chromium.org designates 209.85.216.42 as permitted sender) smtp.mailfrom=jeffxu@chromium.org; dmarc=pass (policy=none) header.from=chromium.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1732566029; a=rsa-sha256; cv=none; b=y0StZ6kKpsaBrkrVyNARhPRTJ4dV8wZgLvDY2htSesAtWAGq/mtKOkQitZ37KIYqXU/D19 TWhe5weOA75toxeUxzadOFEY8kqCNO8bfTto/l4yUkcPfyMTREBmGswmHxQQ75J1SHQTp6 hZWaFE4VjRiAqQhjsEJr7ZgtxtruZHs= Received: by mail-pj1-f42.google.com with SMTP id 98e67ed59e1d1-2edbe217f00so309984a91.3 for ; Mon, 25 Nov 2024 12:20:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1732566031; x=1733170831; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ck8iNHlaINiOxwziQMas9mEee03tDCqdu64rqgP3RtY=; b=gOnTzzaYRL2waUAmr8vgsvz4ECcnKW1TUYlWFz1SrLxctUk291SthbyGqvG2KIeSec /vJgwdd3b08Eg7FxM2sSfJ7ro/NIqCurdD5VVEgQxY+npN44gYmfW6xqWJxcevVyre6M WXp2lMdl97bXa2ULUhoDcy+MyvfnNXUQpKHI8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732566031; x=1733170831; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ck8iNHlaINiOxwziQMas9mEee03tDCqdu64rqgP3RtY=; b=iXBLogdG3zdO6A83KvpQj+xDm4ZmTlqEHrEkEXBoCKCNRVfYcnL4RFeubhznhl9cT2 Nuz2G4anT1iO8Vo/jN3qK7TVmW/dm9IwdH0qv3UxQr5RyN41WkR4V6fq/KgnzuLAsmYO L9PccZF9qrTLZOqYNsSzHt+AxoV2EXQTek06/0xPKRfnTn02oOWjlwywwPnBzL5sPZFt QKH6xIU8/bFgjSB4nysoAh8dvS02FqT3ZmfPdlpEC0bg5/1nsXSctEfWQKakB2YGCsM/ grQEoSgNU9Yyv8M3y5kWESt+SSDG5olIupb37Cg1rmMJQTwvfr/qaIINSuLPb/2z5EH5 Y+ow== X-Forwarded-Encrypted: i=1; AJvYcCWHMADZfn0QP7Amt75y5qtLHn+3khUHCL5rHkaP6pfkkMx/E9PTOkqd1KuKtmoX+w2RqBi4ITQI/w==@kvack.org X-Gm-Message-State: AOJu0Yyt9i8E6Xctw2HDvSnOaPR3r6tdylM6YxLetEelFk+F5fDKwTuc ePBRO8UIzlPtJtWGpJDpyKmMMUaAXP/BJx04eyhxHmEOd66dDyOc64vhxUkRGA== X-Gm-Gg: ASbGncsh5NLUHv4jK8iKWOek+bKQNOQBAdccpBN2sH/0SHQEQsFSz06MhuZzC+mWUK+ KICCtvAsvaVAayBKBWrvjCJKcxNqpex4/O9t+yYLxgKkuqhZynUiBoPvyt5dhI/AwaWkLhAz+nn eO3Mext9gFa1pZKHVCm7klSWiuSS+EHPHUhUFgelqUlZUFFC9HFDTIhxEdV/2QJ5MNsrKRWrotS L3HvRjk/qLjUnB5X7yGBsnc1OZEsnVnVg1jWesMSVOEi+1kB9qeyHuzrNGXdsBBk4NgAyUZaFrm 498Z2QlOhb8= X-Google-Smtp-Source: AGHT+IEsNrIfDOlDJszJCCyP5knKGW7zK5+mBVoYuD5vArA1ATNn0z2H+b7d5ury5fhH1aIeHXqdCg== X-Received: by 2002:a17:90b:1a86:b0:2ea:3ab5:cb83 with SMTP id 98e67ed59e1d1-2ede7e58cc0mr723100a91.9.1732566030884; Mon, 25 Nov 2024 12:20:30 -0800 (PST) Received: from localhost (238.76.127.34.bc.googleusercontent.com. [34.127.76.238]) by smtp.gmail.com with UTF8SMTPSA id 98e67ed59e1d1-2eb0d048e94sm7191796a91.40.2024.11.25.12.20.28 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 25 Nov 2024 12:20:30 -0800 (PST) From: jeffxu@chromium.org To: akpm@linux-foundation.org, keescook@chromium.org, jannh@google.com, torvalds@linux-foundation.org, adhemerval.zanella@linaro.org, oleg@redhat.com Cc: linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org, linux-mm@kvack.org, jorgelo@chromium.org, sroettger@google.com, ojeda@kernel.org, adobriyan@gmail.com, anna-maria@linutronix.de, mark.rutland@arm.com, linus.walleij@linaro.org, Jason@zx2c4.com, deller@gmx.de, rdunlap@infradead.org, davem@davemloft.net, hch@lst.de, peterx@redhat.com, hca@linux.ibm.com, f.fainelli@gmail.com, gerg@kernel.org, dave.hansen@linux.intel.com, mingo@kernel.org, ardb@kernel.org, Liam.Howlett@Oracle.com, 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, Jeff Xu Subject: [PATCH v4 1/1] exec: seal system mappings Date: Mon, 25 Nov 2024 20:20:21 +0000 Message-ID: <20241125202021.3684919-2-jeffxu@google.com> X-Mailer: git-send-email 2.47.0.338.g60cca15819-goog In-Reply-To: <20241125202021.3684919-1-jeffxu@google.com> References: <20241125202021.3684919-1-jeffxu@google.com> MIME-Version: 1.0 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: E28F314001B X-Stat-Signature: u4fsootik5byamt9ojtq78yc9w8gnktp X-Rspam-User: X-HE-Tag: 1732566029-652974 X-HE-Meta: U2FsdGVkX19oOm6aTW1VB7rKbChvFoNz+BSErOh4dTxocnZltnm1pJpQ04BR9X+Ss1IwN7qmnfomcYBLY0E1EU2aPyNDlsOns5ZFms1juMvWYX+J8d69B3AYatV1vjSCmvrQb5DS3bkUevPNBLJl9RxA74RjUAdHjHyRPv8ezY59yoGrS2zpCS2mY1+Jp+C+bSKlPMFZIN4BR5B008LYadu9sm9pibJPrG5CqAucNX8Pnt1QTBuw0YKZCLIPfHt6khWIfrlZOdxKen2JkXaJoOT+q5KbVKu91OPQcAIku4SYR/inPnnBgxH/n2+GIuRWzlTyP4ibQXNpGGkHy4swECtd4DT8uZZaWaLj9MSfKKs0vgJKk8M2SgErByqSavDgfgRh+4+XdQ0nzkSVyb9m/2a3jSKXvN4vvMPeeyRQlW0j89aYzbDnoWb0lAaBDFJpO4vs3VNNQZB20bO/rd6y2sGcOhiOQG/sAvP0dIn52PR8BDxbBdiFLPA9M8o00SV7wZYN1MFCIZ20rbEmBrEqTYtzg1PS4O/YE67+qR2W7kHjSaJ5aeHzJ2iEgo9o/Xt4rlwmtLFWc0CMS+IT6/3pTicfsnsp+dd6Dg2XC0GUhrC7t/EZeEfgg3JLQSW4AC2eWSur1xGGGajEgqQU+Rsib2xbi/bJVsbFdoOfsS7dKfj/OfRadaojONio4MyLigEqavixSLl1Ow9OhF3VnZY9hBRsepRg9x+tsgR3IdNt3xtDD3PRxFQX8/IKOiiBaBPawep0pqA/55HK6lzJNM/szxEUbt832qu6NQjeEOCMNjzc8hY7fcjqoMrdSHSfk8qkXGAIhbqcqPuc2dyOgeFuTZEWdTSsrS3PABfW6XsQDcyfvajZD/M8/gvesBkHhRPTlve+GIbk8df+qhH4oWXDHrAswQ4K2D3LebBKjE/ma0EKMTsDjm2VxHnDkbMXY9uMB8K2UbOtub5IHEVYO+0 VZ12H/Nj lV9S8oDyaKXBHuybyfMznwwpkVnV4Lz1rAPu+GRYKbxTpBLNiGwHbEx8s/wmk7mAs5SMzv8iRMbsnN15pxy5IK0WnwU95If1LzTzXBvwWV15XBK57sk/QCxttYY3rrZf5l0l7BaebzNFxuXFBhESYX6FGlB9Qn0eMdPuQyZ1eKfTR5O0lAIyD/f1LUvD9g+oZbnNYzmwZPNvZkID3b7VoUm2/wHUx4EnYDJDEJtY4Yo6hE5VRPCLJKNoIi1w7MAA8AN+Q68VAICSN1aiwNeif28MZW5A0/U3YyjBx/mxqsAm4qarCuETClP0i38z3pxR88c7kMXUolWLcIcJhuybkPE8O8DYTkWUH09E1dISvyq4hkuBkIH18lSHsvw== 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: From: Jeff Xu Seal vdso, vvar, sigpage, uprobes and vsyscall. Those mappings are readonly or executable only, sealing can protect them from ever changing or unmapped during the life time of the process. For complete descriptions of memory sealing, please see mseal.rst [1]. System mappings such as vdso, vvar, and sigpage (for arm) are generated by the kernel during program initialization, and are sealed after creation. Unlike the aforementioned mappings, the uprobe mapping is not established during program startup. However, its lifetime is the same as the process's lifetime [2]. It is sealed from creation. The vdso, vvar, sigpage, and uprobe mappings all invoke the _install_special_mapping() function. As no other mappings utilize this function, it is logical to incorporate sealing logic within _install_special_mapping(). This approach avoids the necessity of modifying code across various architecture-specific implementations. The vsyscall mapping, which has its own initialization function, is sealed in the XONLY case, it seems to be the most common and secure case of using vsyscall. It is important to note that the CHECKPOINT_RESTORE feature (CRIU) may alter the mapping of vdso, vvar, and sigpage during restore operations. Consequently, this feature cannot be universally enabled across all systems. Currently, memory sealing is only functional in a 64-bit kernel configuration. To enable this feature, the architecture needs to be tested to confirm that it doesn't unmap/remap system mappings during the the life time of the process. After the architecture enables ARCH_HAS_SEAL_SYSTEM_MAPPINGS, a distribution can set CONFIG_SEAL_SYSTEM_MAPPING to manage access to the feature. Alternatively, kernel command line (exec.seal_system_mappings) enables this feature also. This feature is tested using ChromeOS and Android on X86_64 and ARM64, therefore ARCH_HAS_SEAL_SYSTEM_MAPPINGS is set for X86_64 and ARM64. Other architectures can enable this after testing. No specific hardware features from the CPU are needed. This feature's security enhancements will benefit ChromeOS, Android, and other secure-by-default systems. [1] Documentation/userspace-api/mseal.rst [2] https://lore.kernel.org/all/CABi2SkU9BRUnqf70-nksuMCQ+yyiWjo3fM4XkRkL-NrCZxYAyg@mail.gmail.com/ Signed-off-by: Jeff Xu --- .../admin-guide/kernel-parameters.txt | 11 ++++++ Documentation/userspace-api/mseal.rst | 4 ++ arch/arm64/Kconfig | 1 + arch/x86/Kconfig | 1 + arch/x86/entry/vsyscall/vsyscall_64.c | 8 +++- include/linux/mm.h | 12 ++++++ init/Kconfig | 25 ++++++++++++ mm/mmap.c | 10 +++++ mm/mseal.c | 39 +++++++++++++++++++ security/Kconfig | 24 ++++++++++++ 10 files changed, 133 insertions(+), 2 deletions(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index e7bfe1bde49e..f63268341739 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -1538,6 +1538,17 @@ Permit 'security.evm' to be updated regardless of current integrity status. + exec.seal_system_mappings = [KNL] + Format: { no | yes } + Seal system mappings: vdso, vvar, sigpage, vsyscall, + uprobe. + - 'no': do not seal system mappings. + - 'yes': seal system mappings. + This overrides CONFIG_SEAL_SYSTEM_MAPPINGS=(y/n) + If not specified or invalid, default is the value set by + CONFIG_SEAL_SYSTEM_MAPPINGS. + This option has no effect if CONFIG_64BIT=n + early_page_ext [KNL,EARLY] Enforces page_ext initialization to earlier stages so cover more early boot allocations. Please note that as side effect some optimizations diff --git a/Documentation/userspace-api/mseal.rst b/Documentation/userspace-api/mseal.rst index 41102f74c5e2..bec122318a59 100644 --- a/Documentation/userspace-api/mseal.rst +++ b/Documentation/userspace-api/mseal.rst @@ -130,6 +130,10 @@ Use cases - Chrome browser: protect some security sensitive data structures. +- seal system mappings: + kernel config CONFIG_SEAL_SYSTEM_MAPPINGS seals system mappings such + as vdso, vvar, sigpage, uprobes and vsyscall. + When not to use mseal ===================== Applications can apply sealing to any virtual memory region from userspace, diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 63de71544d95..fc5da8f74342 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -44,6 +44,7 @@ config ARM64 select ARCH_HAS_SETUP_DMA_OPS select ARCH_HAS_SET_DIRECT_MAP select ARCH_HAS_SET_MEMORY + select ARCH_HAS_SEAL_SYSTEM_MAPPINGS select ARCH_STACKWALK select ARCH_HAS_STRICT_KERNEL_RWX select ARCH_HAS_STRICT_MODULE_RWX diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 1ea18662942c..5f6bac99974c 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -26,6 +26,7 @@ config X86_64 depends on 64BIT # Options that are inherently 64-bit kernel only: select ARCH_HAS_GIGANTIC_PAGE + select ARCH_HAS_SEAL_SYSTEM_MAPPINGS select ARCH_SUPPORTS_INT128 if CC_HAS_INT128 select ARCH_SUPPORTS_PER_VMA_LOCK select ARCH_SUPPORTS_HUGE_PFNMAP if TRANSPARENT_HUGEPAGE diff --git a/arch/x86/entry/vsyscall/vsyscall_64.c b/arch/x86/entry/vsyscall/vsyscall_64.c index 2fb7d53cf333..30e0958915ca 100644 --- a/arch/x86/entry/vsyscall/vsyscall_64.c +++ b/arch/x86/entry/vsyscall/vsyscall_64.c @@ -366,8 +366,12 @@ void __init map_vsyscall(void) set_vsyscall_pgtable_user_bits(swapper_pg_dir); } - if (vsyscall_mode == XONLY) - vm_flags_init(&gate_vma, VM_EXEC); + if (vsyscall_mode == XONLY) { + unsigned long vm_flags = VM_EXEC; + + vm_flags |= seal_system_mappings(); + vm_flags_init(&gate_vma, vm_flags); + } BUILD_BUG_ON((unsigned long)__fix_to_virt(VSYSCALL_PAGE) != (unsigned long)VSYSCALL_ADDR); diff --git a/include/linux/mm.h b/include/linux/mm.h index df0a5eac66b7..f787d6c85cbb 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -4238,4 +4238,16 @@ 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); +#ifdef CONFIG_64BIT +/* + * return VM_SEALED if seal system mapping is enabled. + */ +unsigned long seal_system_mappings(void); +#else +static inline unsigned long seal_system_mappings(void) +{ + return 0; +} +#endif + #endif /* _LINUX_MM_H */ diff --git a/init/Kconfig b/init/Kconfig index 1aa95a5dfff8..614719259aa0 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -1860,6 +1860,31 @@ config ARCH_HAS_MEMBARRIER_CALLBACKS config ARCH_HAS_MEMBARRIER_SYNC_CORE bool +config ARCH_HAS_SEAL_SYSTEM_MAPPINGS + bool + help + Control SEAL_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 be tested to + confirm that it doesn't unmap/remap system mappings during the + the life time of the process. After the architecture enables this, + a distribution can set CONFIG_SEAL_SYSTEM_MAPPING to manage access + to the feature. + + The CONFIG_SEAL_SYSTEM_MAPPINGS already checks the CHECKPOINT_RESTORE + feature, which is known to remap/unmap vdso. Thus, the presence of + CHECKPOINT_RESTORE is not considered a factor in enabling + ARCH_HAS_SEAL_SYSTEM_MAPPINGS for a architecture. + + For complete list of system mappings, please see + CONFIG_SEAL_SYSTEM_MAPPINGS. + + For complete descriptions of memory sealing, please see + Documentation/userspace-api/mseal.rst + config HAVE_PERF_EVENTS bool help diff --git a/mm/mmap.c b/mm/mmap.c index 57fd5ab2abe7..bc694c555805 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -2133,6 +2133,16 @@ struct vm_area_struct *_install_special_mapping( unsigned long addr, unsigned long len, unsigned long vm_flags, const struct vm_special_mapping *spec) { + /* + * At present, all mappings (vdso, vvar, sigpage, and uprobe) that + * invoke the _install_special_mapping function can be sealed. + * Therefore, it is logical to call the seal_system_mappings_enabled() + * function here. In the future, if this is not the case, i.e. if certain + * mappings cannot be sealed, then it would be necessary to move this + * check to the calling function. + */ + vm_flags |= seal_system_mappings(); + return __install_special_mapping(mm, addr, len, vm_flags, (void *)spec, &special_mapping_vmops); } diff --git a/mm/mseal.c b/mm/mseal.c index ece977bd21e1..80126d6231bb 100644 --- a/mm/mseal.c +++ b/mm/mseal.c @@ -7,6 +7,7 @@ * Author: Jeff Xu */ +#include #include #include #include @@ -266,3 +267,41 @@ SYSCALL_DEFINE3(mseal, unsigned long, start, size_t, len, unsigned long, { return do_mseal(start, len, flags); } + +/* + * Kernel cmdline override for CONFIG_SEAL_SYSTEM_MAPPINGS + */ +enum seal_system_mappings_type { + SEAL_SYSTEM_MAPPINGS_DISABLED, + SEAL_SYSTEM_MAPPINGS_ENABLED +}; + +static enum seal_system_mappings_type seal_system_mappings_v __ro_after_init = + IS_ENABLED(CONFIG_SEAL_SYSTEM_MAPPINGS) ? SEAL_SYSTEM_MAPPINGS_ENABLED : + SEAL_SYSTEM_MAPPINGS_DISABLED; + +static const struct constant_table value_table_sys_mapping[] __initconst = { + { "no", SEAL_SYSTEM_MAPPINGS_DISABLED}, + { "yes", SEAL_SYSTEM_MAPPINGS_ENABLED}, + { } +}; + +static int __init early_seal_system_mappings_override(char *buf) +{ + if (!buf) + return -EINVAL; + + seal_system_mappings_v = lookup_constant(value_table_sys_mapping, + buf, seal_system_mappings_v); + return 0; +} + +early_param("exec.seal_system_mappings", early_seal_system_mappings_override); + +unsigned long seal_system_mappings(void) +{ + if (seal_system_mappings_v == SEAL_SYSTEM_MAPPINGS_ENABLED) + return VM_SEALED; + + return 0; +} diff --git a/security/Kconfig b/security/Kconfig index 28e685f53bd1..5bbb8d989d79 100644 --- a/security/Kconfig +++ b/security/Kconfig @@ -51,6 +51,30 @@ config PROC_MEM_NO_FORCE endchoice +config SEAL_SYSTEM_MAPPINGS + bool "seal system mappings" + default n + depends on 64BIT + depends on ARCH_HAS_SEAL_SYSTEM_MAPPINGS + depends on !CHECKPOINT_RESTORE + help + Seal system mappings such as vdso, vvar, sigpage, vsyscall, uprobes. + + A 64-bit kernel is required for the memory sealing feature. + No specific hardware features from the CPU are needed. + + Depends on the ARCH_HAS_SEAL_SYSTEM_MAPPINGS. + + CHECKPOINT_RESTORE might relocate vdso mapping during restore, + and remap/unmap will fail when the mapping is sealed, therefore + !CHECKPOINT_RESTORE is added as dependency. + + Kernel command line exec.seal_system_mappings=(no/yes) overrides + this. + + For complete descriptions of memory sealing, please see + Documentation/userspace-api/mseal.rst + config SECURITY bool "Enable different security models" depends on SYSFS