[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <99920.1706830997@cvs.openbsd.org>
Date: Thu, 01 Feb 2024 16:43:17 -0700
From: "Theo de Raadt" <deraadt@...nbsd.org>
To: Linus Torvalds <torvalds@...ux-foundation.org>
cc: Jeff Xu <jeffxu@...omium.org>,
"Liam R. Howlett" <Liam.Howlett@...cle.com>,
Jonathan Corbet <corbet@....net>, akpm@...ux-foundation.org,
keescook@...omium.org, jannh@...gle.com, sroettger@...gle.com,
willy@...radead.org, gregkh@...uxfoundation.org,
usama.anjum@...labora.com, rdunlap@...radead.org, jeffxu@...gle.com,
jorgelo@...omium.org, groeck@...omium.org,
linux-kernel@...r.kernel.org, linux-kselftest@...r.kernel.org,
linux-mm@...ck.org, pedro.falcato@...il.com, dave.hansen@...el.com,
linux-hardening@...r.kernel.org
Subject: Re: [PATCH v8 0/4] Introduce mseal
Linus Torvalds <torvalds@...ux-foundation.org> wrote:
> So yes, to my mind
>
> mprotect(addr, len, PROT_READ);
> mseal(addr, len, 0);
>
> should basically give identical results to
>
> mprotect(addr, len, PROT_READ | PROT_SEAL);
>
> and using PROT_SEAL at mmap() time is similarly the same obvious
> notion of "map this, and then seal that mapping".
I think that isn't easy to do. Let's expand it to show error checking.
if (mprotect(addr, len, PROT_READ) == -1)
react to the errno value
if (mseal(addr, len, 0) == -1)
react to the errno value
and
if (mprotect(addr, len, PROT_READ | PROT_SEAL) == -1)
react to the errno value
For current mprotect(), the errno values are mostly related to range
issues with the parameters.
After sealing a region, mprotect() also has the new errno EPERM.
But what is the return value supposed to be from "PROT_READ | PROT_SEAL"
over various sub-region types?
Say I have a region 3 pages long. One page is unmapped, one page is
regular, and one page is sealed. Re-arrange those 3 pages in all 6
permutations. Try them all.
Does the returned errno change, based upon the order?
Does it do part of the operation, or all of the operation?
If the sealed page is first, the regular page is second, and the unmapped
page is 3rd, does it return an error or return 0? Does it change the
permission on the 3rd page? If it returns an error, has it changed any
permissions?
I don't think the diff follows the principle of
if an error is returned --> we know nothing was changed.
if success is returned --> we know all the requests were satisfied
> The reason for having "mseal()" as a separate call at all from the
> PROT_SEAL bit is that it does allow possible future expansion (while
> PROT_SEAL is just a single bit, and it won't change semantics) but
> also so that you can do whatever prep-work in stages if you want to,
> and then just go "now we seal it all".
How about you add basic mseal() that is maximum compatible with mimmutable(),
and then we can all talk about whether PROT_SEAL makes sense once there
are applications that demand it, and can prove they need it?
Powered by blists - more mailing lists