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 B1F6BD2F7E9 for ; Thu, 17 Oct 2024 03:56:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 18B266B007B; Wed, 16 Oct 2024 23:56:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 13ABC6B0082; Wed, 16 Oct 2024 23:56:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0029E6B0083; Wed, 16 Oct 2024 23:56:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id D23F66B007B for ; Wed, 16 Oct 2024 23:56:51 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id AE8491C6C38 for ; Thu, 17 Oct 2024 03:56:39 +0000 (UTC) X-FDA: 82681732938.14.1C7F741 Received: from mail-oa1-f44.google.com (mail-oa1-f44.google.com [209.85.160.44]) by imf11.hostedemail.com (Postfix) with ESMTP id AD1DA40005 for ; Thu, 17 Oct 2024 03:56:38 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=SO+SjGOJ; spf=pass (imf11.hostedemail.com: domain of jeffxu@chromium.org designates 209.85.160.44 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=1729137264; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=+xDplWMnrkVDTOjcZzbsa+PFQJ46/uurWYdS279WZl4=; b=heb9WYyHj3hpJyD1QmlhiCfe+dsGVB/U6L9ouzSqPDN6m0kCcR7WQN/vHjpd+Hh1aqCYTo k2oyYBZPDkqnvlBrXltBSEe/CoABD5AcKo6u6BfQ3NUWfrY4kTcyC55SVZQnfjqgETft7r dCT9YGeeOy1K19PX0OcpGKaWHlM48ag= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1729137264; a=rsa-sha256; cv=none; b=h3DK4LJq0sryNIlAdFuVYR/8CTrv/sBsn7i7x7Zp54tE/f5bw5vHtb9ssOXlmjk+E8H1Bt j62GsODFFUvzZaO9IguAfK+Xnd34r89ll3WntmlESQN8p3ZDB2gKw/GX0Z6ss8wYIfjAVp T8hklIeMA0QZbgJ/se706c1eFeCcH3I= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=SO+SjGOJ; spf=pass (imf11.hostedemail.com: domain of jeffxu@chromium.org designates 209.85.160.44 as permitted sender) smtp.mailfrom=jeffxu@chromium.org; dmarc=pass (policy=none) header.from=chromium.org Received: by mail-oa1-f44.google.com with SMTP id 586e51a60fabf-288a6df82ebso56348fac.2 for ; Wed, 16 Oct 2024 20:56:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1729137409; x=1729742209; darn=kvack.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=+xDplWMnrkVDTOjcZzbsa+PFQJ46/uurWYdS279WZl4=; b=SO+SjGOJmW9utXB/XDFv/r5z+fcwXY2b42y6RnZAKL54GZl7EV3GeTBcAu5SFPUSyL rHAQsEB7AxMRgu9DTJ2P4uXbAC4/fcwKahwb1vUC9c4vtSdnirBJRGVhYyQQgyzheIXU RIGnZlTPlEYZRfBnh2o8TQHUv05QOhpCCoEgk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729137409; x=1729742209; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+xDplWMnrkVDTOjcZzbsa+PFQJ46/uurWYdS279WZl4=; b=cdVirtTWCalkxr8jKJPHrvNuVTY443RlEO12xrMokqEY68griGZ+XoAoxbnkt/Cmrh R1qOCRAIHFQhFOfsYlFmDHj70crhrCKHU3/C5dXIG8tq5S2qiCe3ZzG93ulqFozqX4aW VjWGqcuM92O8UWQ88ULPqx73u+5dCA3qQyQ5Fg88Jy79821GHtBiWnNnH1wInAZRPgCI jkrYM30YX54tbt7h75kcAtIvZ0oHqalu4CYcGjEQGpTlSQsJtpfAQvcRu2XWCJ16i/8C jAocIWgShhBrDw8C56MROsIRZ/UeEOQ/A1yhTSLNkkYSkbOz/5ieGW+udkKpP9DsnMwN FHQQ== X-Forwarded-Encrypted: i=1; AJvYcCWYcdGI4+ZDvVRFfCF8kOl8IHN8IsLzwALqYW8+vuhCPSCsS95FsfpNXpjj8wX5UgR45Avbum1z9A==@kvack.org X-Gm-Message-State: AOJu0YxN7L8CrKnLe0fMgrZ9lyRbmP4rM92Gq2yKGeElqztWH6dR+GvH ih7yGd3zi3y6vfCaT/E/ZavLPEp3N48qo8VutlWnYwoQE81XGzmmE7gdgLdewjROjTvZvmpvdRY K1S/teACNssDXbzRF8g4dqVNXEgVtS9mLGHp3 X-Google-Smtp-Source: AGHT+IE4fYg26EfQyIf9BSs4rRYOM6MlrMuoB3kGUvuKZrktYleCB72ksfvspyqDROopedVLIoje8kkW2ksT2pf691A= X-Received: by 2002:a05:6870:2012:b0:268:bd85:ff9a with SMTP id 586e51a60fabf-2890c60b148mr504819fac.3.1729137408676; Wed, 16 Oct 2024 20:56:48 -0700 (PDT) MIME-Version: 1.0 References: <20241014215022.68530-1-jeffxu@google.com> <20241014215022.68530-2-jeffxu@google.com> <202410161424.FA6DBA7D91@keescook> In-Reply-To: From: Jeff Xu Date: Wed, 16 Oct 2024 20:56:36 -0700 Message-ID: Subject: Re: [RFC PATCH v2 1/1] exec: seal system mappings To: Kees Cook Cc: akpm@linux-foundation.org, jannh@google.com, torvalds@linux-foundation.org, adhemerval.zanella@linaro.org, oleg@redhat.com, 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, lorenzo.stoakes@oracle.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: AD1DA40005 X-Stat-Signature: 17uq3dme3cjuw5dgzp1jjiumts9cqqr3 X-HE-Tag: 1729137398-610588 X-HE-Meta: U2FsdGVkX1+IUdBcwC9ky06+BY9yv/1IfN4+WZb6BpudgxG08UdfRxUre67Yj5XCz9GcHKoS2kIX8TL/9hxFIKBq9Lpj0pBTnpDOaqexJPZFlavOGmYReMZm+tBOKdrSqYM9FF2tQzmprZk7ZSIsiY/TYEVLLiTQq99twenkyARNoUo4+U4Sa6qncMIg10PybHdJsGovcImQq3ntcIRpfFTQpbIrQ5wKyUn5FKKvxAakxIiuB/81pmVAoXsZ9RIo1gWYGUi+Vc1YHlaj/+FQo9b2JbbyS/zrj1gR9md5XR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ender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Wed, Oct 16, 2024 at 3:06=E2=80=AFPM Jeff Xu wrote= : > > On Wed, Oct 16, 2024 at 2:26=E2=80=AFPM Kees Cook wrote= : > > > > (I don't think this needs "RFC" any more) > > > > On Mon, Oct 14, 2024 at 09:50:20PM +0000, jeffxu@chromium.org wrote: > > > From: Jeff Xu > > > > > > Seal vdso, vvar, sigpage, uprobes and vsyscall. > > > > > > Those mappings are readonly or executable only, sealing can protect > > > them from ever changing 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. These mappings > > > are designated as non-writable, and sealing them will prevent them > > > from ever becoming writeable. > > > > > > 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], thus sealable. > > > > > > The vdso, vvar, sigpage, and uprobe mappings all invoke the > > > _install_special_mapping() function. As no other mappings utilize thi= s > > > 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) ma= y > > > alter the mapping of vdso, vvar, and sigpage during restore > > > operations. Consequently, this feature cannot be universally enabled > > > across all systems. To address this, a kernel configuration option ha= s > > > been introduced to enable or disable this functionality. Note, uprobe > > > is always sealed and not controlled by this kernel configuration. > > > > > > [1] Documentation/userspace-api/mseal.rst > > > [2] https://lore.kernel.org/all/CABi2SkU9BRUnqf70-nksuMCQ+yyiWjo3fM4X= kRkL-NrCZxYAyg@mail.gmail.com/ > > > > > > Signed-off-by: Jeff Xu > > > --- > > > .../admin-guide/kernel-parameters.txt | 10 ++++ > > > arch/x86/entry/vsyscall/vsyscall_64.c | 9 +++- > > > fs/exec.c | 53 +++++++++++++++++= ++ > > > include/linux/fs.h | 1 + > > > kernel/events/uprobes.c | 2 +- > > > mm/mmap.c | 1 + > > > security/Kconfig | 26 +++++++++ > > > 7 files changed, 99 insertions(+), 3 deletions(-) > > > > > > diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Docume= ntation/admin-guide/kernel-parameters.txt > > > index e7bfe1bde49e..02e5eb23d76f 100644 > > > --- a/Documentation/admin-guide/kernel-parameters.txt > > > +++ b/Documentation/admin-guide/kernel-parameters.txt > > > @@ -1538,6 +1538,16 @@ > > > Permit 'security.evm' to be updated regardless = of > > > current integrity status. > > > > > > + exec.seal_system_mappings =3D [KNL] > > > + Format: { never | always } > > > + Seal system mappings: vdso, vvar, sigpage, upro= bes, > > > + vsyscall. > > > + This overwrites KCONFIG CONFIG_SEAL_SYSTEM_MAPP= INGS_* > > > + - 'never': never seal system mappings. > > > + - 'always': always seal system mappings. > > > + If not specified or invalid, default is the KCO= NFIG value. > > > + This option has no effect if CONFIG_64BIT=3Dn > > > + > > > > Any reason for "always"/"never" instead of the more traditional y/n > > enabled/disabled, etc? > > > Yes. I like to leave room for future extension, in case someone ever > needs a prctl for pre-process opt-in, e.g. > Format:{never|prctl|always} > I copied the pattern from: proc_mem.force_override=3D [KNL] Format: {always | ptrace | never} > > Otherwise, this all makes sense to me. > > > > -- > > Kees Cook