Message ID | 20241125202021.3684919-1-jeffxu@google.com (mailing list archive) |
---|---|
Headers | show
Return-Path: <owner-linux-mm@kvack.org> 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 66E4FD59D69 for <linux-mm@archiver.kernel.org>; Mon, 25 Nov 2024 20:20:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EB2D96B0089; Mon, 25 Nov 2024 15:20:32 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E62CF6B0092; Mon, 25 Nov 2024 15:20:32 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D2AC56B0093; Mon, 25 Nov 2024 15:20:32 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id B24A86B0089 for <linux-mm@kvack.org>; Mon, 25 Nov 2024 15:20:32 -0500 (EST) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 6714F4066A for <linux-mm@kvack.org>; Mon, 25 Nov 2024 20:20:32 +0000 (UTC) X-FDA: 82825734936.08.B6D71D0 Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) by imf22.hostedemail.com (Postfix) with ESMTP id 08A0FC000A for <linux-mm@kvack.org>; Mon, 25 Nov 2024 20:20:25 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b="i6/baBge"; spf=pass (imf22.hostedemail.com: domain of jeffxu@chromium.org designates 209.85.214.169 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=1732566027; 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:references:dkim-signature; bh=2bPBR8Yw5Dhs7C/hFxnb3GEJDbYT54V2RImcN0+GcoI=; b=X86RvS9QC45NjI9l7mHbow8BwFSYkpQS+6D/6kRq07ZvDvhEOfmCoE+OhTNsmD26tQi3yH /5CJ8vDdGwZp5y+htY4o0bkCkW9mtPnSKW44G7tj77w1sVWlYN+M+2ZtOSVnCb8ktxrtXs i6OtBRmDvqQCYXR7O1UiFeZ8ZbkbTEI= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b="i6/baBge"; spf=pass (imf22.hostedemail.com: domain of jeffxu@chromium.org designates 209.85.214.169 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=1732566027; a=rsa-sha256; cv=none; b=OTy9CWOjW91HWRzzQTr252YQApUxopiTP0w3yqVfTHeS/5qSm6AR1n+3s0xcGSf59aDUNy +zg6SjK9COJxnuyup4rxRespCP75Q6ITwWCcliK02cN9v1xfMRX/hUkGBNsVVVcZYS3Bgr +5YXGe0ONWO8dm2vxofqwZu5ZjO2Dpk= Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-2121858db03so5485955ad.2 for <linux-mm@kvack.org>; Mon, 25 Nov 2024 12:20:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1732566029; x=1733170829; darn=kvack.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=2bPBR8Yw5Dhs7C/hFxnb3GEJDbYT54V2RImcN0+GcoI=; b=i6/baBge6cjPHjrxWuz3xcvCSmyqi1TTAZPLN9fX0CkCLukMEAPgZg4EsVrIlzHfgR haNWqVUoYiJeurkj/OI6pUM+jICh4ZOmW0ygw+WHzFAZYMQyG8VWgC1eoedVQiOhavbW xB94Rf4OpL1IC3da1bl7GxOme5Ht0V9zGrpZA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732566029; x=1733170829; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=2bPBR8Yw5Dhs7C/hFxnb3GEJDbYT54V2RImcN0+GcoI=; b=Ag6CuHXCOwS6OF0PwleOcEMFcUgSsMksTD+IK7GLN6cnUt1n5EUdXh0hEQt9DdJvlJ o5Fkn3XsNF4+6vL6eLo8M9uKbwwOI+TZbKb06Exzp+G2Vo8T6aWYk/C8rclUcUFFNQEa jy6IIWB/I4GaLQntX6OuZTPYkmLVtVcWxezy+Mj8pQs+oOb7jjaseP+wMHRxAB8McMiD JQx/liT+dpG7G3A4u7g0vgGCKhOGVXzDxbYge8HE6UEF8kjhT4PPD7B7w3ynT4mG4e+b vI1UPBpzM1UXfYkwO88qvo+SJHOzsZYjekwx1w3RSEZ9hPoraztFkcwwJcvx149o8zI3 7jUg== X-Forwarded-Encrypted: i=1; AJvYcCVsJUS75PozKx+HJAZqIz5vMLljDdNnxa0W8slB/LboG06vylEb1Tod3OA2Efb5Khk72mbUjVbAVg==@kvack.org X-Gm-Message-State: AOJu0YwJpYdYl+QWZyQztzmWU4uXXVyuMI5ZRRFgKJohjJy4vAF8YlZa lROksr7xAU1oC2IzzALv7Tjac/HpWSrPyDyIcxhjRBHWNXYPpZaK3FAaDsFhfQ== X-Gm-Gg: ASbGncu2J3XWSXA5O7QY/p9v/NGhMOz1+cI9qBOwAba9CMRubU1H+ve75/UwGAQBDkJ gmAo9D2MZYrmjkfYHBXYsjqyzVnFnrze2513H7ygKejLYhbOkZafbjIF9APNQDVhUDCN8M9RUzM vMm9HVRKT3hZB8F4jJDTHGNBF1eVXkT2SaVivhn4B0OUQPhqe4OK94tKcwrpx6ML6twkatnBabe Jngi/XPh/iK9tRZx5eysd05GCHJQVatfeHLBT0QnXRMeATcvPCfXfHb82cRGRqcXCvKW6ZUtMs9 RNCJDejT30k= X-Google-Smtp-Source: AGHT+IHp2QrrU3RI0OmIU17fgwey6/8O6ZVj8X1aM9FXZJNL58pk/JZ4qsmgGuHB2EK2wRDkI9lhEw== X-Received: by 2002:a17:903:2291:b0:211:ff32:93 with SMTP id d9443c01a7336-214e4416006mr8613105ad.4.1732566027670; Mon, 25 Nov 2024 12:20:27 -0800 (PST) Received: from localhost (238.76.127.34.bc.googleusercontent.com. [34.127.76.238]) by smtp.gmail.com with UTF8SMTPSA id d9443c01a7336-2129dba5d4bsm69486135ad.80.2024.11.25.12.20.25 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 25 Nov 2024 12:20:27 -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 <jeffxu@chromium.org> Subject: [PATCH v4 0/1] Seal system mappings Date: Mon, 25 Nov 2024 20:20:20 +0000 Message-ID: <20241125202021.3684919-1-jeffxu@google.com> X-Mailer: git-send-email 2.47.0.338.g60cca15819-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 08A0FC000A X-Stat-Signature: n4es8mtdhhxm47eh9smqd3cczdufk9cm X-Rspam-User: X-HE-Tag: 1732566025-987036 X-HE-Meta: U2FsdGVkX19y/t5Xb59gooh0k0SjSE1k1yxK8RLdpZUOrSSgqwZUHdfamLp2PelXhBJlZz67TB/iwhvS3ztNzi8GY5JEWDExELnF4TfTKMQau9WmbIswUOXRXf9m01Rs5JvhoSNfC39cRob+iBqi/WkVTJvT6XH+K8MhyHRIqequi0sdK037dO8ijwoaxbsOmpw/NzozBS1szdo23QF9VDii75XV2QnJIUB6hxIuMnJSP6esOfCEJaJu+ASWJBeDFQ2jKSGHAyG1Tk+gxNMx5v6YLkuYk/qzv4il0JyLfLoCvEBhcwthzuur1tS5oIv5ragyBgvSS8pto6egE29GgS6AQweqv/qGrNqCnFdhR27V5p+HnTkEdH3lQ8LIbBFDmkV9uPIAtXld4NWWxAICg/GFSVJ+yezDNNR2Sq4pZ6u5xFWS97K1ED1BxkSb5uhJC6TZvW30oXL/kBHEpD+AmBn5AkCcqrix/11g7fXKouZQCQXvrAjRzPjDp+dhletnzakx10IC+jrKRDsYhMXuxi59DE4ls2LZii9ydDSQOEp4+CAu2CfN28Kmc5AKOSIVD0YAnRy1uL/0SA0peqVGMpnCY4gaPPBvdvXFsMHsb40azA0yp3OAegW425wwfWPy3qttWI+Q63FLHCDtbDTcbWi4CqBQmSpLgcwnaqzovHV5HyTfNdS88MvwdZj8NPIJkithovYi++cww94mLdkmzEkaaZ122E3E1hgHwnmRj4A7fVDWVzwDPqgIlizZycF0J0h4B2wj+n8RTYfoOFgo65VSi1vbg8vItWCamyWkphzGNVkR4FEHaBICzd5QXMa6hc9+uM/q3b1QdlDW0DaDXC+Fn1Xcx36+wn8CRh36zyk6FOIFilb6a5GJi7sPq8lgTJyx/BH1oOiDIzTOO0DTvqGoxn8ThQqMd+juISz1JIK5rNE2+aSTUzZ1nRzWbwLH0qCrYjZ2s5NCiVWXErX iVvg0ErL LP7dJSptY6ErJo3JSwEs0W1kNemLXI3d5n8tvAk7HdFlU+E3iSG76OOk2YaDmSUW5Y+xF+/gvw54EyrF8FflcdbbOClSW1bN5ULs5mrrmB6PWgPxfh5/lRTlijIv9ZROkJIcfHSiaAl6ow9R+TLN3zHTtWuG9/8PTLneUFT+xylH+8JtE6DogfIPWDKq/xC2H6vNxfEIkW6T9Z4QDWhcMuIMF8+LxkY3bZN5QVO5CeFPwRJNEUng3zKu4bTSQzIMj+d+lmRSRHZVudx4DY9drxG/uMv9yvLZphWhwUHZDl+69ZeNI6J4XzveslPnuDOrIcCbGzCQm4QhbrHNtKt94OvDJdMLIMDjHajipdUO9EqbPi3o= 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: <linux-mm.kvack.org> List-Subscribe: <mailto:majordomo@kvack.org> List-Unsubscribe: <mailto:majordomo@kvack.org> |
Series |
Seal system mappings
|
expand
|
From: Jeff Xu <jeffxu@chromium.org> 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/ History: V4: ARCH_HAS_SEAL_SYSTEM_MAPPINGS (Lorenzo Stoakes) test info (Lorenzo Stoakes) Update mseal.rst (Liam R. Howlett) Update test_mremap_vdso.c (Liam R. Howlett) Misc. style, comments, doc update (Liam R. Howlett) V3: https://lore.kernel.org/all/20241113191602.3541870-1-jeffxu@google.com/ Revert uprobe to v1 logic (Oleg Nesterov) use CONFIG_SEAL_SYSTEM_MAPPINGS instead of _ALWAYS/_NEVER (Kees Cook) Move kernel cmd line from fs/exec.c to mm/mseal.c and misc. refactor (Liam R. Howlett) V2: https://lore.kernel.org/all/20241014215022.68530-1-jeffxu@google.com/ Seal uprobe always (Oleg Nesterov) Update comments and description (Randy Dunlap, Liam R.Howlett, Oleg Nesterov) Rebase to linux_main V1: https://lore.kernel.org/all/20241004163155.3493183-1-jeffxu@google.com/ Jeff Xu (1): exec: seal system mappings .../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(-)