Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp991661rdb; Fri, 2 Feb 2024 09:59:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IG9pdDYNHd8ggKeUwXI1rf3IQilA7IbuVAkAYZhp8rfUMSuUj/OzORcT5WOB39nzroC4vdE X-Received: by 2002:a05:6358:7e50:b0:176:8332:c661 with SMTP id p16-20020a0563587e5000b001768332c661mr9416828rwm.25.1706896779332; Fri, 02 Feb 2024 09:59:39 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706896779; cv=pass; d=google.com; s=arc-20160816; b=EPTRdzyonSTRcjeeYj/lCTbT1gBWMw5C8jg4bwCzgUa7oo9T1aJ2J/eQfsEXsAQK/t iZmhexlWYmLyoOn/5aKikIwPAdFAB3Bb2yvf76/5bQfn6CbPcxDIhcauR7LbwLW7b+Yu EHuOrO6QekNDrABbeBYObZVIthq80GFvWplJvtYXLH96qefGdaMpNCRxl7Mukpmv68l9 3nNmwGLqKsRAo3ii3w7dOdEpYJrGv3eI63FCRyrOGy/byxqGU22uUYGK/Pve7hfjLacn VqsaIngYIy7t83J2cMtefMDxp5AP7n3WdfebIIBjVWR8qdF568XbABgE1a490ikyx6ns J9vQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=V3MyFHdGuJXKIHAocH1cP+k+k6xBW4irfqW7F3umGsY=; fh=2DlrFJZcHFqqYWlzFcgJgGySvQ9tc45sdWfGvZ2TlcE=; b=bx1nq8A+ifltkerIRLMWh//PNifZfmnqLN/S0TKMFg5NWj6lAUnlOWZ+nOcIDk7X7k Bl5lFVqZLMDLt3P8kAwQNzKyh99mqDOD9ENEaRZbjHLuH/ywgbLZ1yE/PB/Gqk7NPfYg cgTms5UYTek1lXqhKQqY4x4JnQXu18De4UizF20BVv8WBNIwPzAkq4kPaBmFkl8B0iE2 RZ27pf2pKAKBi6b4qiAWyFL9oCqFHABjU0Eh52UpgToUh4jmoaRiAl9uENdlZblcRbtR fAeyvHRBUVQ6/C7GnEFXraIIi2I2nmGO6rJU/3uBTJkzxs/gQmfEQHGjZJiOf4Xcqt1d wTxg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=LtKFdmnu; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-50279-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50279-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org X-Forwarded-Encrypted: i=1; AJvYcCXkcXt7Aks0nqwTvsVh+rMB6oZTQVjAQcQD9c5SvvCzHih+2k6AO72GCUQ+782SAdy1UtDtl45bzpQtXu5dPvpmN0T4aWCS8sVrDFQwOA== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 36-20020a631864000000b005db38f3524bsi1931706pgy.52.2024.02.02.09.59.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 09:59:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-50279-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=LtKFdmnu; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-50279-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50279-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.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 6C7EF288891 for ; Fri, 2 Feb 2024 17:59:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BD35014AD1B; Fri, 2 Feb 2024 17:59:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="LtKFdmnu" Received: from mail-ot1-f48.google.com (mail-ot1-f48.google.com [209.85.210.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3DC5D14C58B for ; Fri, 2 Feb 2024 17:59:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.48 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706896747; cv=none; b=bCQE/Y52M6nUjuUClSOHfgUwsh5z9rJ7jrJ/S8hewmA9NQJusRw+4041kBTlw64UbBIoqRhqy7DprZFHhOAiwP5onoINGGIAtdjFCuazU4430GsfTUprnnt3zsNsVwxqh+iagXf66U4JWOq+h9RyLdykv97zwJW4gmZt9SrqZw4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706896747; c=relaxed/simple; bh=b0UK3I6qBl5XLXZ/ULBInBz/ydG+gAjVS2eKkSAUwuc=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=eu53vZEb5fSGSRfjw0VAngVBcVJVudV/S9+FBooUKidJ7/VfCkJ9/CgCCfA4W5fbvaNFqRLTNFP6oTjhnRs+AdMrxzSr7PkDgQlBmbj3AIOE5Yqkb06YVpPbXe9YeTO7HnG0gDxO1+aBQx05WwluOwMvUN4tbj5m8eQ6lo7YL90= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=LtKFdmnu; arc=none smtp.client-ip=209.85.210.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-ot1-f48.google.com with SMTP id 46e09a7af769-6e141ee9c14so1193299a34.3 for ; Fri, 02 Feb 2024 09:59:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1706896745; x=1707501545; darn=vger.kernel.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=V3MyFHdGuJXKIHAocH1cP+k+k6xBW4irfqW7F3umGsY=; b=LtKFdmnuA9zRYggzAzNUaUaUmyKVOrU3o7RbDHpumwWHWdIWt3HRxK05zC1yAXd5Ic d0zcKrDc9vE0iPxnps/sWZLyewDKkhPCIJxhubQl3OmkdoxfE+xI0CB13/ZZIanxtW+k Z6muAVLps3zZZncPOFwtUaVHPzeXiGn7dKyZQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706896745; x=1707501545; 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=V3MyFHdGuJXKIHAocH1cP+k+k6xBW4irfqW7F3umGsY=; b=cSo78O5VBZq2QhTD+wK2sEK+Z6bkeFouZbhXAfAgQLXL0aXc43bfhzMXc4Z6GKU6tM fKFMohSzAmdntmUOjHwDjjMhoaOJOkyKkhaSIRPuVDLCW5H5g20pUddUBeuJlRknFamw PJsRwbdniqRbOf4gJcv2bc7OvMvPvPvX8/kPp/I+CSJlKbDCHFlACJyFiiEUg/wswosY 6qbnjDTdYC2xdtnI8cFL93JM6RNr6duPGWGkeBbBI/pT39MEPW9GutJvSBTazgb9vrcC 7gR/qdPd4agDYHC+7k/IaPmd1gHcItJ4pZ3VQjCLhAxlYp9bobci7rJBcGBSy0hjW0lp zS6w== X-Gm-Message-State: AOJu0Yz+fimGxwoXIBi4+4klVAk+L6w7fgoqLMnV5dxnZXR16sju0ZCd GqVrwgnsdMQ5s2nvVTtNbLO5LA0BYVd+5O6QklxxBEG86NOhBmWNy+KEuoyDzNER32Y3tKvN0yL kW9jOu7WN2PtszkqE+99KQbwnkt+Zf64P881k X-Received: by 2002:a05:6870:200b:b0:218:eff8:3161 with SMTP id o11-20020a056870200b00b00218eff83161mr487923oab.39.1706896745307; Fri, 02 Feb 2024 09:59:05 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240131175027.3287009-1-jeffxu@chromium.org> <20240131193411.opisg5yoyxkwoyil@revolver> <20240201204512.ht3e33yj77kkxi4q@revolver> <58408.1706828083@cvs.openbsd.org> <8744.1706846710@cvs.openbsd.org> <29248.1706850035@cvs.openbsd.org> In-Reply-To: <29248.1706850035@cvs.openbsd.org> From: Jeff Xu Date: Fri, 2 Feb 2024 09:58:53 -0800 Message-ID: Subject: Re: [PATCH v8 0/4] Introduce mseal To: Theo de Raadt 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Feb 1, 2024 at 9:00=E2=80=AFPM Theo de Raadt = wrote: > > Jeff Xu wrote: > > > Even without free. > > I personally do not like the heap getting sealed like that. > > > > Component A. > > p=3Dmalloc(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 immediatel= y > 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. > I understand what you mean: I will add that part to the document: Try to recycle a sealed memory is disastrous, e.g. p=3Dmalloc(4096); mprotect(p,4096,RO) mseal(p,4096) free(p); My point is: I think sealing an object from the heap is a bad pattern in general, even dev doesn't free it. That was one of the reasons for the sealable flag, I hope saying this doesn't be perceived as looking for excuses. >