Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp623034rdb; Thu, 1 Feb 2024 21:04:08 -0800 (PST) X-Google-Smtp-Source: AGHT+IEld19HGZRvCo24zqHrPRgqXyDcX5cIyPAxO/qmcICf0L41wPa7ZxgVMMOW+GnwnoWsk/MM X-Received: by 2002:a05:620a:2903:b0:785:5b14:a6e0 with SMTP id m3-20020a05620a290300b007855b14a6e0mr47360qkp.33.1706850248419; Thu, 01 Feb 2024 21:04:08 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706850248; cv=pass; d=google.com; s=arc-20160816; b=lc95S/J1lgxFuyW6y1iD9tt/s3eeFkTq6YFH9iKCH8n0o3tvlzHpGMspb0rbtgBaG5 hjnj937WQGGUNtfrca0XAEPsRYH3W2Aif1wH+RKCQ2PMl4eipoIE76li1cIR2V0tEB4L 3T2BglWZ+d21bVnOTeJ8x9MRRECvnmk2wlLtoAAR7FLUctLuMgmLNsfUcIaLGLbZPeZ8 nculaQxrHEygt/f5M7/9B3EjxLZfT63FcVnTXVus3O0KfWD7XUDPHsPtvJlKiEqdhdPe jkV+Qzaia5Hcj8LV7p+LWQe9+dlDUVkwZZ0i0N5IRxEQurFlc1/oA/jqoB2HcAAz/w2V +rzQ== 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=JotH6rs4h1syyGeyYqY5McfBenHgwpdRO1IwArpDec4=; fh=GZfn6unRo5Wk6ntjH35oroDpk3n6fILbyUu396H6Rp0=; b=v35n7wzsUEaCrG4nbH3wu/mCZOoPyvlVKQpg3UbB70otOJW7WHMJxjSWMreUpBjVLm dqw4uhhO+0cx1fdVjJooPjW4xMGQBophhJH1Cr1f5SClPALghIZoP2VG4r+MflOnCzT3 UgiXJLDl1mAE3re2hG3Tfgl9A37mMAXooYntp22RG+eVbMqWxJKBZKgEtYYMc80GHa1c LlwmdMN/HN8yz0+tsL0PPwa4ifbdAW9VdegOoTvUdAypnKrcEBwurZvA89N5N9uBCzln ERHCMBpFW8PpR0fnYzfMFKDrJQSl2HK2NQfm7Hj7UBXFoov+EtplTkvYpN0WtHkZl57f af1g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@openbsd.org header.s=selector1 header.b=sh1XyYJV; arc=pass (i=1 spf=pass spfdomain=openbsd.org dkim=pass dkdomain=openbsd.org); spf=pass (google.com: domain of linux-kernel+bounces-49225-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49225-linux.lists.archive=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=1; AJvYcCWBE2ONjtfs+LeXOCyz3L+jzNmlvugI5xBbYMF9Hgdz9+Rc11gEJWKb7pwptJoY+GqB3JOAik6Lsun2Rke1pz0yiSZwSmzDCvCPKV2SEw== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id d26-20020a05620a159a00b0078553706039si963524qkk.678.2024.02.01.21.04.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 21:04:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-49225-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@openbsd.org header.s=selector1 header.b=sh1XyYJV; arc=pass (i=1 spf=pass spfdomain=openbsd.org dkim=pass dkdomain=openbsd.org); spf=pass (google.com: domain of linux-kernel+bounces-49225-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49225-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 214A11C2498F for ; Fri, 2 Feb 2024 05:04:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 66A3317566; Fri, 2 Feb 2024 05:00:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=openbsd.org header.i=@openbsd.org header.b="sh1XyYJV" 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 660251754E; Fri, 2 Feb 2024 05:00:36 +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=1706850041; cv=none; b=AIfUvQios7BV0jkYqdix1Mckfdi+leimtWY3CC6TKsQajUloNU3PUrFSssG5ZxbpEXMtQMPFUt9qUWSIWPIyYeYE3zNAg0JL+t0nxjqt4GrHRE/xQdBeX74m2QSBjvvx3d/K8Owh/9sA/nuzq2GHRNAPI5lN+h+tnk9XyDW9lYM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706850041; c=relaxed/simple; bh=Al3s5n9XbYajMyMjy8quEUVmt9j6PNC6PhjL+sDVrak=; h=From:To:cc:Subject:In-reply-to:References:MIME-Version: Content-Type:Date:Message-ID; b=PGOTImyz1wFwfZ9t20gApuf5zW8PHdj5W2O7mHeFDzhKW8HpDfsA07nvuQRb4mwBS2F7Bx7x3u4i4eFKMR4wnJEMGkFTpi82nog37jKTAVbTo7L1hPBZKLrHT8vsrY/vzhSZ5c4VIWMsKvyQPN0j9bQIRl8j/S5d8AwYXzHLSh4= 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=sh1XyYJV; 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=Al3s5n9XbY ajMyMjy8quEUVmt9j6PNC6PhjL+sDVrak=; h=date:references:in-reply-to: subject:cc:to:from; d=openbsd.org; b=sh1XyYJVZYspbYXNo5lPr6eTzSsPxlnzX fUpQ+m0g7osvlXQvcV2G+BhKvz2pnkmgRy3sVTKxdare0Z+M7o58U4MMgKzbCRET9klZsc oaoityDPeqv1qGDLleLPnYPYicdjJuag7OdSxzy341IzrDsWbdrRCEaTWYw12r5aZd3hyr mcd8IEBO6yBRfN5Fz7z8ZIlyNrK9UAHgi3UX4zLwYtrzUPse+VNOk62UmZbSMl6Ep8Isxo dY7bZ+afNtjp+jwl2P7FZeJp52muDmP09AelHIjXZ7q3df86FM2xZDjkxoVIfNiwglMPfI RFfcaD4q2AxYDQzikS7LzNlMfZSRw== Received: from cvs.openbsd.org (localhost [127.0.0.1]) by cvs.openbsd.org (OpenSMTPD) with ESMTP id 96394933; Thu, 1 Feb 2024 22:00:35 -0700 (MST) From: "Theo de Raadt" To: Jeff Xu cc: Jeff Xu , Linus Torvalds , "Liam R. Howlett" , Jonathan Corbet , akpm@linux-foundation.org, keescook@chromium.org, jannh@google.com, sroettger@google.com, willy@infradead.org, gregkh@linuxfoundation.org, usama.anjum@collabora.com, rdunlap@infradead.org, 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 v8 0/4] Introduce mseal In-reply-to: References: <20240131175027.3287009-1-jeffxu@chromium.org> <20240131193411.opisg5yoyxkwoyil@revolver> <20240201204512.ht3e33yj77kkxi4q@revolver> <58408.1706828083@cvs.openbsd.org> <8744.1706846710@cvs.openbsd.org> Comments: In-reply-to Jeff Xu message dated "Thu, 01 Feb 2024 20:54:28 -0800." 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: <60913.1706850035.1@cvs.openbsd.org> Date: Thu, 01 Feb 2024 22:00:35 -0700 Message-ID: <29248.1706850035@cvs.openbsd.org> Jeff Xu wrote: > Even without free. > I personally do not like the heap getting sealed like that. > > Component A. > p=malloc(4096); > writing something to p. > > Component B: > mprotect(p,4096, RO) > mseal(p,4096) > > This will split the heap VMA, and prevent the heap from shrinking, if > this is in a frequent code path, then it might hurt the process's > memory usage. > > The existing code is more likely to use malloc than mmap(), so it is > easier for dev to seal a piece of data belonging to another component. > I hope this pattern is not wide-spreading. > > The ideal way will be just changing the library A to use mmap. I think you are lacking some test programs to see how it actually behaves; the effect is worse than you think, and the impact is immediately visible to the programmer, and the lesson is clear: you can only seal objects which you gaurantee never get recycled. Pushing a sealed object back into reuse is a disasterous bug. Noone should call this interface, unless they understand that. I'll say again, you don't have a test program for various allocators to understand how it behaves. The failure modes described in your docuemnts are not correct.