Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp3117256lqo; Tue, 14 May 2024 23:15:55 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX/8LgZkE9y5UNFovTQEZ2iaMM1GoYTgOGNA+gjwRp67VA6gN0b4jGz6JoxFRJWPl7PlEhZhrk9rjcoe830FSzOz0ma4tSKkQrMBBJ9XQ== X-Google-Smtp-Source: AGHT+IHkQ98FyiIriMd0wjg2X1PvRDsRp98gnGGBcC5kZjeigYkFN8ScmVy+MGkD8Ju1scKtuEqk X-Received: by 2002:a17:907:3203:b0:a59:ca7e:e1f with SMTP id a640c23a62f3a-a5a2d53b76amr1322134166b.15.1715753754987; Tue, 14 May 2024 23:15:54 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715753754; cv=pass; d=google.com; s=arc-20160816; b=WROBIvSlq7ubzHk8mPge+GJXKNBJ2KrQOky2WIIZED4cdBijuShtU7eleCS7BasoCx DflsrXiOvbQVqx/bIK4pVe9atVbssSq9AjrIRDBUUtCz4STrtKiw0hnq7TB6XqFUFlde w4IFRh+3EC3OGlTef9xgTAKDZ4W7Zs5ag3VGcanXe5dBYLn8vYelvYwYGmYkXjVULfhB znqMzeuka7SvpZGluCTRgaTWDQVRWMnSNm79eB3P6D5MxzF6FaJsgdxNweHH5ydJnq9g +6J1caRlWTeh8pi9Vei07k8VXuuZsoYUAuNJYqPiestA5t1VODOZvb4udoz3BvYBtFjE c33Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date; bh=ASdIGQ8qNrrB4UOHINDR4SRi9CLHexrhs1bKAxIoEEQ=; fh=5YraJdarISQQtb7lHIOq17itarvnIJMy23hbXVXOe8o=; b=DDrfQGgd+C81313In/971gsxfxqwDw1IafxpPYy0x05bHQQmkhmT1GC76iKrNzGZ29 6m5NBmkpuCgTY6hQgpPUQJXJ/nWIAcLRKNchDFSMaY5y8tS+G1TSYMbOMPGgWdbcoMOh YZlz6ilF5DK0RupB/XkR+yteeT6N/6KTGv3e+DAhefWtDxVszU7LeseeNc1jJIFMBNkT Tn7RLIM9YIltbTl3YV1msfutyjAgvmuYIFvVxqHpA9aMKkecTKLd2gE8QPZmbE4to4WO zZkECBQ3i6LLdEulcTE5UL72z2WCIDjsFhiFp61mjQ6ptyaAqlMVjIYRY6dXWKe+nbQW yc1A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=1wt.eu); spf=pass (google.com: domain of linux-kernel+bounces-179513-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-179513-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a640c23a62f3a-a5a17b4c641si688233466b.427.2024.05.14.23.15.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 May 2024 23:15:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-179513-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=1wt.eu); spf=pass (google.com: domain of linux-kernel+bounces-179513-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-179513-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 am.mirrors.kernel.org (Postfix) with ESMTPS id AAB411F21C58 for ; Wed, 15 May 2024 06:15:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8B8B63BBCE; Wed, 15 May 2024 06:15:47 +0000 (UTC) Received: from 1wt.eu (ded1.1wt.eu [163.172.96.212]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 380603A29F; Wed, 15 May 2024 06:15:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=163.172.96.212 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715753747; cv=none; b=AHChM/1PtCg5l9qnt4eMUfqf3ysXBSycmF63MRrLiB9j7YdbjeMfjFVVExR+8nNEAzvZgkfvRjFU0qqp2wWRn7qQQkdDwwsmRY7F34ROzvinvOwxk8hsNdWxjUAKmNDvps1nQYRiAsStxP+yex0vj1haH/g4DQc/v2aMFE5FMxY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715753747; c=relaxed/simple; bh=5pN0Bv3ggxcBHrTLeGSKhEB6L3Vo7V64rQH/kwktpaA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=WJGpv7IBpyTPRgpXlw8guNJUpl37FnGFOUUAyMZ4FMiPpywDwOMQxqetrstGXjaW72dujYwse+0bNZWOrYvDlgmqoqneq/u1a3tOEjJrXV1qrVnCDYs7qfLPukJcWAcQugz20NU77pFPRVy7q1yEFcxQ8QrOminjUZEkLXtiYGc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=1wt.eu; spf=pass smtp.mailfrom=1wt.eu; arc=none smtp.client-ip=163.172.96.212 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=1wt.eu Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=1wt.eu Received: (from willy@localhost) by mail.home.local (8.17.1/8.17.1/Submit) id 44F6EquX027885; Wed, 15 May 2024 08:14:52 +0200 Date: Wed, 15 May 2024 08:14:52 +0200 From: Willy Tarreau To: Linus Torvalds Cc: Theo de Raadt , Andrew Morton , Matthew Wilcox , Jonathan Corbet , jeffxu@chromium.org, keescook@chromium.org, jannh@google.com, sroettger@google.com, gregkh@linuxfoundation.org, usama.anjum@collabora.com, Liam.Howlett@oracle.com, surenb@google.com, merimus@google.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 v10 0/5] Introduce mseal Message-ID: References: <20240415163527.626541-1-jeffxu@chromium.org> <20240514104646.e6af4292f19b834777ec1e32@linux-foundation.org> <871q646rea.fsf@meer.lwn.net> <56001.1715726927@cvs.openbsd.org> <20240514160150.3ed0fda8af5cbd2f17c625e6@linux-foundation.org> <92453.1715730450@cvs.openbsd.org> <20240515025811.GA1232@1wt.eu> 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-Disposition: inline In-Reply-To: On Tue, May 14, 2024 at 09:14:37PM -0700, Linus Torvalds wrote: > On Tue, 14 May 2024 at 20:36, Linus Torvalds > wrote: > > > > Guys, if you let untrusted code execute random system calls, the whole > > "look, now unmap() acts oddly" IS THE LEAST OF YOUR ISSUES. I totally agree with this, I'm more speaking about a more general hardening measure, like what is commonly offered via prctl() and that, for example, manages to mitigate the consequences of a successful RCE. > Side note: it doesn't even help to make things "atomic". munmap() acts > oddly whether it fals completely or whether it fails partially, and if > the user doesn't check the result, neither case is great. I don't find the "atomic" aspect that important either, however the munmap() man page says: All pages containing a part of the indicated range are un- mapped, and subsequent references to these pages will generate SIGSEGV. It is not an error if the indicated range does not contain any mapped pages. This alone is an encouragement to not check the result. And BTW, what should one do to try to repair the situation after a failed munmap() ? It reads as "best effort" above: usually upon return, anything that could be unmapped was unmapped. That's how I'm reading it. I think it's a nice property that makes this syscall trustable by its users, and contrary to the atomic aspect I would find it nice if munmap() would properly unmap everything it can then return the error caused by the encounter of a sealed area. For me that's even the opposite of an atomic approach, it's really about making sure to best follow the developer's intent regardless of any obstacles. > If you want to have some "hardened mseal()", you make any attempt to > change a mseal'ed memory area be a fatal error. The whole "atomic or > not" is a complete red herring. Yep, agreed. > I'd certainly be ok with that. If the point of mseal is "you can't > change this mapping", then anybody who tries to change it is obviously > untrustworthy, and killing the whole thing sounds perfectly sane to > me. > > Maybe that's a first valid use-case for the flags argument. That could be for that use case (developer doing mseal, attacker trying munmap), indeed, though that couldn't cover for the other way around (attacker doing mseal() in hope to make a future munmap() fail). That's what I like with prctl(), it offers the developer a panoply of options to decide when and how to lock down a process in order to mitigate consequences of exploited bugs. And it could be independent on this series, by essentially focusing on the ability to kill a process that fails to munmap() a sealed area. I.e. no need to that that property on the area itself, it's a matter of whether we consider the process sensitive enough or not. Willy