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 BC574C47DD9 for ; Mon, 22 Jan 2024 15:49:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3E4738D0008; Mon, 22 Jan 2024 10:49:44 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 394158D0001; Mon, 22 Jan 2024 10:49:44 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 25B9C8D0008; Mon, 22 Jan 2024 10:49:44 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 158238D0001 for ; Mon, 22 Jan 2024 10:49:44 -0500 (EST) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id ACCF5409BB for ; Mon, 22 Jan 2024 15:49:43 +0000 (UTC) X-FDA: 81707382246.30.52274D0 Received: from cvs.openbsd.org (cvs.openbsd.org [199.185.137.3]) by imf20.hostedemail.com (Postfix) with ESMTP id 8D0721C0012 for ; Mon, 22 Jan 2024 15:49:41 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=openbsd.org header.s=selector1 header.b=n50s5fom; dmarc=none; spf=pass (imf20.hostedemail.com: domain of deraadt@openbsd.org designates 199.185.137.3 as permitted sender) smtp.mailfrom=deraadt@openbsd.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1705938581; 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=+WTooy6YIlZsn1SzL/rtoBL6Pd0DdQWKX3jXjQPNevI=; b=es+Ja3/D+kpoNwTI5sG7E6O8RjQQUmSpahtUmRDJv0DNGwt+t7EB5ViyUyTYnXFCNEjqQw 6JZPnIovv6oxKjbo1yr/ZKPTT4lryIIz/i891UwxJnPYMmuu5XjGa3kVBuluU1KSdDeOg8 exZFh5d4We750Mslyh2SY+s+DNEdPzU= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=openbsd.org header.s=selector1 header.b=n50s5fom; dmarc=none; spf=pass (imf20.hostedemail.com: domain of deraadt@openbsd.org designates 199.185.137.3 as permitted sender) smtp.mailfrom=deraadt@openbsd.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1705938581; a=rsa-sha256; cv=none; b=ioCxG/QPU8/LZ53FmvdEvY5IkeXt8aGxaCO5nNgLInRNyCueULg3FYORYS3o+XJFkKsdYw FCSNFCHVwrrvjHAsnTkm1S4KyJNT4vrXq2vxSa661EraHerqG3GqB4OOTyc23U62YCN58S 5SuUhlf5BFe/6Lj8A9lzALglXIcrZYA= 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." 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> X-Rspamd-Queue-Id: 8D0721C0012 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: htia65uou4z786m3zz9m8h7rpznanuqe X-HE-Tag: 1705938581-464348 X-HE-Meta: U2FsdGVkX18mOYHCIjQtj5Z3tXvFAwpY4Y40cKX7YsGIaOq6XZa5Am2CS6KOyUuHaBoqvyMo7aHZtUzSm7yqAM2KmQmKSdFWJAHA5C1ZwN9QoCuvxGg9wAP0gziCIDjQz110UjDkxdA7r0KggSnhBla7ALc8rvBYOG/F+QEnAarTfbElBhfQJb8jw4CMcqqQSLz6WaO/NKbRmJEtOdv3jAIocOpEMwaRGXe8LK3so3dk0J31y9lA1i+9a60w+M0rCyjPv4rLBs4DvQyD0YAz4wcNflceaw53axaxgAJX+4Lw97A4BV2IzELEsrPWuO/ay8BFWMqEmPMnu3OAMKpFGTRDiKUmVdbhJHlrQg3iQ6uEbsHqjoJ8RNxx4RxfKii2sWJM9ZuxY5eoJSNwNIdp2dLSNGVvT5ZiptBLmwIJWX5L82DxGndWjymGewR6RT3huj4bu6ne2ZwWPLqr2REpVo0/4qhpun1ZezWb+3cSKBm1Su0zRp3UFFJ+kmRDHb/6tQahvBeE5BBDkA5dta37nm32P5nPE/6hMrsp7M7nfOWpuAQKjKiGZnDooITtTO8FaayzpSUeV/F/j3ZwsK9WZ1uy5vYtwJczGTr8VotDOrrNSMS+IsyLUUtVSN1tATdgc7RSNTaKDbpJU1QgD9h7+SlclW7iPU6Q+0LwWsEDqBnXAMoeK1TZKrqp7Otg4Cbm0pOz/yYfoippMVFZxq6XKKJJh60j/qYttvg+G4KGcMPIhN+LzAtVOMpC32/hC0fr9TWpw7R/OeU4cuWMY6qFoEiJtx5opCSKhlVdneny75i7F0kVTTFntwPFi+zW9RQKOP4aZ9zH+zrqWNA2jv5zecflBhgJB8bcWpEdXLS3JN0KLzYzlEU/I0OB5ya+QxLGnO9qacJlVgVBswmg/TBzXIuzTK3RpjUpoG5VA7GiqDymFREPE2ISUO7vHaMvwQBGlIfQpRCp0HjRYtqttco /keWLfp1 OSDTObDOAhUr8i6YSeNO906ATdMuV5+Ouvwo6FvM3yAwKlV6rP+zsJnNBB+ytm3SvqhNWIEadhSy7U0EdY1KqO85Vw/a0w0Njp7svBHeFE6gJsy+U7026qF8IsSrPEZhDuEo/v0J1d4QfIa2CCypnzzAcHilYD7za4xLJvB3je5fuGYohSZmEtImLgEx9znDNS42ayVpdKwz2ZCDz3SgbgDLtfaGJXSE7vVFImHEH1YpvaQ30T81Q17tgjGisojogwLVudEHU3Laj6rQ= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000231, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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.