Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp1364685rdb; Wed, 24 Jan 2024 12:51:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IHbdh7mKx6rBTZDWhxqUt3AftBHIDDDmiJ3WtRjJ85FySFaIKMsELecoHeXfDtKTDAzY8W5 X-Received: by 2002:a17:902:b693:b0:1d6:ed14:e30d with SMTP id c19-20020a170902b69300b001d6ed14e30dmr1022987pls.78.1706129508782; Wed, 24 Jan 2024 12:51:48 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706129508; cv=pass; d=google.com; s=arc-20160816; b=YtirrXqRC9dz3jvYmk9Gh0z2Klp5DG2yjxMQfb7pL/JeTGdPBQ2mhfHhNFwUWf+FIp HRwSsIyzI+pBB/vZSdxoeHgOnyj/DPFgcvIa/0sFB0XbC17mv+Nh9+eWa+1N4Caq0ekn KZkOj/53jQ9Ub8NcmxDD8TTkSBcq048lFu0r/krMJp4sBbgfSNAomBl46DBOEx2z8MWu +Fs7Z5mgAZ0Ljkv1Ark1ymXVaWNiU6yzEVisnzoxi3VXs4Hq+0UJuqIo9CrpaY79WU53 4ZwnJw9h7cgKVjFISX6GWn3J8PdGetkWSmaEgp2PANDdmk0b3KjRcy+WeRxqPuyQTIhN mwMw== 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:mail-followup-to:to:from:dkim-signature; bh=fYaXq5b08WQ4EtjgoGrtivsJuo+jrQUBjKTPesTH4+k=; fh=Wluo3vv1dnO/TTRLxc8VozpcLKakaf4/ujleTjsyTw4=; b=jYbvQmao76tKgy6t6dm04YyCnBXyyxMbhmpUg06YZCGdWm/zrZ2GeCsyZoOBIb62ek JZVbHYW4BGOKwOPFzMDodBp6UzBhlmT27wq8l9kd7E3t9DG96GEqAF7+5DrGZRYtV/91 QRlwoHXAwHXTiks83DBdlzFG2uNKnrbXsd7PHWH0Iz+TgQwjyUFNkw1VC9SzrI3FueIt a0t6wlM1Q1VpIwYHzO+u1Iw0/ZnAylk6yWfw736z1ir4CTACJQ/y3d19W7QuRvuz95Rx OjjU98UackOPFMCRpZ6cAOtQRjv+wsCJ8R95LEXsSQgvNq+ryuON/TFE5EagjfMMps4U zriQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@openbsd.org header.s=selector1 header.b="43WCwO/h"; arc=pass (i=1 spf=pass spfdomain=openbsd.org dkim=pass dkdomain=openbsd.org); spf=pass (google.com: domain of linux-kernel+bounces-37663-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-37663-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id ji15-20020a170903324f00b001d7250653dfsi9117641plb.249.2024.01.24.12.51.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jan 2024 12:51:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-37663-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@openbsd.org header.s=selector1 header.b="43WCwO/h"; arc=pass (i=1 spf=pass spfdomain=openbsd.org dkim=pass dkdomain=openbsd.org); spf=pass (google.com: domain of linux-kernel+bounces-37663-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-37663-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 6F43E284BC7 for ; Wed, 24 Jan 2024 20:51:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BFCD41350D5; Wed, 24 Jan 2024 20:51:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=openbsd.org header.i=@openbsd.org header.b="43WCwO/h" 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 0BB101292FB; Wed, 24 Jan 2024 20:51:37 +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=1706129500; cv=none; b=eQveOtboNHq2NuaL6TiyOT+yltgJhFDBmngOR+JPxNLRGNszWSaH2nacBFuju6AYdTgCzueyUf6oLorj5ef/zDHaDlbUlTTXnj4hA4GnGaMieSpxPq4x5rd/P0xJ957HXWjii2WW02viIVAwNwvxVnMTuhap9XyYKYxpUZKiesU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706129500; c=relaxed/simple; bh=Z6R0DSevUsWp/ES4X1fSbzidtHovZqFHyGVCe23vpOQ=; h=From:To:Subject:In-reply-to:References:MIME-Version:Content-Type: Date:Message-ID; b=UWOGTIGDuwxKQhU7FmA8qIGThVbVZZQB+b1Dioa5wxtFuqFXoiV2QURFpdP2/DRTp6z954bOnc6uvJFDldwQam3k1n+unHNCC1ibULcIp4ZN4qRPIJakRQDYYtgUP5uNBxreg61HBJ+KXJChqWqDgf8VoZ/zLJYwV0nHlySytVw= 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=43WCwO/h; 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=Z6R0DSevUs Wp/ES4X1fSbzidtHovZqFHyGVCe23vpOQ=; h=date:references:in-reply-to: subject:to:from; d=openbsd.org; b=43WCwO/hWJyeW7jniZUXpoRulSjG7aM+cwLo LzWTShoquiNAk1T+jrBK6SMcVIbDB+V51FxS9Zuoa7yiu+uJnEuLsJ/yl3R4QijJGWRmA+ MuBAO63A7qp4qRUizMMMzUN6XAGwCoXnwb0F5rMrZ4VU9kSXuZdV+Jj/ccK03N0lH3Umrl MN7q+ffha9DN63HMmBAKUyeVOvCqaJdaDlJ+terJSrnNEtPcy/81YKlwfVbfv9eMhcxKAo 9EwcDoScJoOvaPYrzj+sXkmj/yw3YsTkr8zdGWgUHmkb4NzKMV5P7efFXj4UsndWP7FpdP viVTF2l2zifSmurxqYEMPZ+8LQ== Received: from cvs.openbsd.org (localhost [127.0.0.1]) by cvs.openbsd.org (OpenSMTPD) with ESMTP id 302f01a8; Wed, 24 Jan 2024 13:51:37 -0700 (MST) From: "Theo de Raadt" To: "Liam R. Howlett" , Jeff Xu , 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 Mail-Followup-To: "Liam R. Howlett" , Jeff Xu , 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 2/4] mseal: add mseal syscall In-reply-to: <98656.1706128621@cvs.openbsd.org> References: <20240122152905.2220849-1-jeffxu@chromium.org> <20240122152905.2220849-3-jeffxu@chromium.org> <20240123181457.idckaydk7dt7q2qy@revolver> <20240124200628.ti327diy7arb7byb@revolver> <98656.1706128621@cvs.openbsd.org> Comments: In-reply-to "Theo de Raadt" message dated "Wed, 24 Jan 2024 13:37:01 -0700." 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: <38861.1706129497.1@cvs.openbsd.org> Date: Wed, 24 Jan 2024 13:51:37 -0700 Message-ID: <82138.1706129497@cvs.openbsd.org> Theo de Raadt wrote: > This discussion about the malloc heap is ridiculous. Obviously it is > programmer error to lock the permissions on memory you will free for > reuse. But you can't fix this problem with malloc(), without breaking > other extremely common circumstances where the allocation of memory > and PERMANENT-USE-WITHOUT-RELEASE of such memory are seperated over a > memory boundary, unless you start telling all open source library authors ^^^^^^^^^^^^^^^ library boundary, sorry > to always use MAP_SEALABLE in their mmap() calls. Example: 1. libcrypto (or some other library) has some ways to allocate memory and provide it to an application. 2. Even if this is using malloc(), heap allocations over a pagesize are page-aligned, so even then following assumptions are sound. 3. I have an application which uses that memory, but will never release the memory until program termination 4. The library interface is public and used by many programs, so the library author has a choice of using MAP_SEALABLE or not using MAP_SEALABLE Due to your choice, my application cannot make lock the memory permissions unless that library author chooses MAP_SEALABLE If they choose to use MAP_SEALABLE, all programs get this memory you consider less safe. Exactly what is being gained here?