Received: by 2002:a05:7412:7c14:b0:fa:6e18:a558 with SMTP id ii20csp452075rdb; Mon, 22 Jan 2024 09:06:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IHtrKrybs617o83A0zhtnDVDv5VFlI4RV64fDkDNIrEztlWxuNjgRRhc8I/yo6LDlGU0XsW X-Received: by 2002:a05:6214:2023:b0:685:55d:18b5 with SMTP id 3-20020a056214202300b00685055d18b5mr7093089qvf.84.1705943208864; Mon, 22 Jan 2024 09:06:48 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705943208; cv=pass; d=google.com; s=arc-20160816; b=W1oSJf2P5lAGzlAcmt5ZnV7oyBrJhL9tdwQEDlzZRcjHRlW2f8fq0IKSuV4t6LrccY +boY55GYBDvqaArfbG8YioujmNQkjNXEGzEPzPK05cgrZoiaDoH9MsZm1Fa/mujhLlDi F1iZjJ3lD47TxPjGMF/aMCCPzD+FFlJbv49GSqXBdD+WVtBIpemqCLtZV8ATCcgdLXDI 3Y3QfJXVpGuxzTC/5MUMrAGMvrI3XwgwGUxdItTLD9vNX+hCgnbzLPA6SYM1N+CHUC0S ObEjLrhV0xps9x9v+KN7kj8bQ46bnE33UMMy+vxh6FbDmSu8bXlxLWSUFZ6b9YcrhF++ jIRw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:content-id:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:comments:references:in-reply-to :subject:cc:to:from:dkim-signature; bh=+WTooy6YIlZsn1SzL/rtoBL6Pd0DdQWKX3jXjQPNevI=; fh=laZexazcayN0i7FrYve9WmAdzXKbWN5PLxLU1d0NQoQ=; b=TRk66EfCX3ioFtWDx7j3Wtyj73PeDBMzlYxdhDTQEx9a9EUNZeDy1oic4/PsPfnEwP SqG+pV5tS+XyCvWRuaq9vPFKbyjl6RUM0JucGulXDrEJjnSvnVRQs/rUUnjmBy37QlYD nafzKc6FS0EUMkTSkIbv1unKRWUdGkoextgdzTKeJkg5g5CbYMm8syJl5CtKaVbly5oY FvmCxiv3VYTWePA41SjsIC8WkVaa5nKnwmmr8Eqmq6FQUpnBi/TOwEtXila/qVYTtKG7 Qp0Pk/d+r0laASefkehP6/1f9SJbyUS74ktfRZX4ciFyasSi0UQuPnV8cpozuJmPjQdG hoig== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@openbsd.org header.s=selector1 header.b=n50s5fom; arc=pass (i=1 spf=pass spfdomain=openbsd.org dkim=pass dkdomain=openbsd.org); spf=pass (google.com: domain of linux-kernel+bounces-33625-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-33625-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id f4-20020a37ad04000000b0078394bdfc78si4933529qkm.44.2024.01.22.09.06.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 09:06:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-33625-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@openbsd.org header.s=selector1 header.b=n50s5fom; arc=pass (i=1 spf=pass spfdomain=openbsd.org dkim=pass dkdomain=openbsd.org); spf=pass (google.com: domain of linux-kernel+bounces-33625-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-33625-linux.lists.archive=gmail.com@vger.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id AA9F21C274C4 for ; Mon, 22 Jan 2024 17:05:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 30DAC48CF0; Mon, 22 Jan 2024 15:49:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=openbsd.org header.i=@openbsd.org header.b="n50s5fom" Received: from cvs.openbsd.org (cvs.openbsd.org [199.185.137.3]) (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 94C103D99A; Mon, 22 Jan 2024 15:49:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=199.185.137.3 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705938588; cv=none; b=mKq12+Xz0r0n646R+6E9fkRAUFEZGX/XkeLWRTiJ8rAv+pSkg7dcW01j8G5uBxoSGCZrWoslGNUwhviqFoE2tGkoh989eErUlz0RjtJ0sbleQ1PY/nDkguU8Tsg9iZgCNNhRI46Hh4MZDDz5vt3ANL8qnHn6JFbeRrBGddGKZuw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705938588; c=relaxed/simple; bh=k7nQjJCjWS7QC8MeL9YzD9PrLF0VGaGFHHqIeOBQKAw=; h=From:To:cc:Subject:In-reply-to:References:MIME-Version: Content-Type:Date:Message-ID; b=fID1Qsy58uP+We1doNCzvyMNE8nLBvii1lY1y71/LYXY09S9l0eHsDV0Hh/JIDPoq7lTpUDfz24AaImDMF6t1z2jAoCDZQhXSRM/v7QvifxPoIZHjw4VxSEIZoQRv8L5F8Dq7x/A2vDZFFSeziZ+cZ4KVanUCi2VmATWh25bERo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=openbsd.org; spf=pass smtp.mailfrom=openbsd.org; dkim=pass (2048-bit key) header.d=openbsd.org header.i=@openbsd.org header.b=n50s5fom; arc=none smtp.client-ip=199.185.137.3 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=openbsd.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=openbsd.org DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; s=selector1; bh=k7nQjJCjWS 7QC8MeL9YzD9PrLF0VGaGFHHqIeOBQKAw=; h=date:references:in-reply-to: subject:cc:to:from; d=openbsd.org; b=n50s5fom6DQvnOuPAWppwTTuDx/Hdrg2M 7/pKMQklBESCFMqVIrYmB+1FIBZ6frgkrGVkt3TVlG2/fCGGi1k0mvseFvgf3QQnRHxPQZ pNfYfeRwaX414VOclH4koqNNxL1KaQ3r9/E85ErVnankDhKWJlSfkYbxME23q59ndFBIRU FKde24hKJcx4S8gNnST4MkZcAyGU572VL3RobUJ5toxWWSu/Evt/C5N60lWHsq0IkCTWOe a/WwPvGsNQA/yKQK5RMPAAOpAiItgv+A1lV3KKffLznE2p1B7xSxuGwMKU+urD1vRqxMsH T3OFrVd320BK4OhFH394v9SNpAqsw== Received: from cvs.openbsd.org (localhost [127.0.0.1]) by cvs.openbsd.org (OpenSMTPD) with ESMTP id 2feb09e1; Mon, 22 Jan 2024 08:49:39 -0700 (MST) From: "Theo de Raadt" To: jeffxu@chromium.org cc: akpm@linux-foundation.org, keescook@chromium.org, jannh@google.com, sroettger@google.com, willy@infradead.org, gregkh@linuxfoundation.org, torvalds@linux-foundation.org, usama.anjum@collabora.com, rdunlap@infradead.org, jeffxu@google.com, jorgelo@chromium.org, groeck@chromium.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mm@kvack.org, pedro.falcato@gmail.com, dave.hansen@intel.com, linux-hardening@vger.kernel.org Subject: Re: [PATCH v7 0/4] Introduce mseal() In-reply-to: <20240122152905.2220849-1-jeffxu@chromium.org> References: <20240122152905.2220849-1-jeffxu@chromium.org> Comments: In-reply-to jeffxu@chromium.org message dated "Mon, 22 Jan 2024 15:28:46 +0000." 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-ID: <8627.1705938579.1@cvs.openbsd.org> Date: Mon, 22 Jan 2024 08:49:39 -0700 Message-ID: <726.1705938579@cvs.openbsd.org> Regarding these pieces > The PROT_SEAL bit in prot field of mmap(). When present, it marks > the map sealed since creation. OpenBSD won't be doing this. I had PROT_IMMUTABLE as a draft. In my research I found basically zero circumstances when you userland does that. The most common circumstance is you create a RW mapping, fill it, and then change to a more restrictve mapping, and lock it. There are a few regions in the addressspace that can be locked while RW. For instance, the stack. But the kernel does that, not userland. I found regions where the kernel wants to do this to the address space, but there is no need to export useless functionality to userland. OpenBSD now uses this for a high percent of the address space. It might be worth re-reading a description of the split of responsibility regarding who locks different types of memory in a process; - kernel (the majority, based upon what ELF layout tell us), - shared library linker (the next majority, dealing with shared library mappings and left-overs not determinable at kernel time), - libc (a small minority, mostly regarding forced mutable objects) - and the applications themselves (only 1 application today) https://lwn.net/Articles/915662/ > The MAP_SEALABLE bit in the flags field of mmap(). When present, it marks > the map as sealable. A map created without MAP_SEALABLE will not support > sealing, i.e. mseal() will fail. We definately won't be doing this. We allow a process to lock any and all it's memory that isn't locked already, even if it means it is shooting itself in the foot. I think you are going to severely hurt the power of this mechanism, because you won't be able to lock memory that has been allocated by a different callsite not under your source-code control which lacks the MAP_SEALABLE flag. (Which is extremely common with the system-parts of a process, meaning not just libc but kernel allocated objects). It may be fine inside a program like chrome, but I expect that flag to make it harder to use in libc, and it will hinder adoption.