Jeff Xu jeffxu@chromium.org wrote:
I don't have a feeling about it.
I spent a year engineering a complete system which exercises the maximum amount of memory you can lock.
I saw nothing like what you are describing. I had PROT_IMMUTABLE in my drafts, and saw it turning into a dangerous anti-pattern.
I'm sorry, I have never looked at one line of openBSD code, prototype or not, nor did I install openBSD before.
That is really disingeneous.
It is obvious to everyone that mseal is a derivative of the mimmutable mechanism, the raw idea stems directly from this and you didn't need to stay at a Holiday Express Inn.
Because of this situation on my side, I failed to understand why you have such a strong opinion on PROC_SEAL in mmap() in linux kernel, based on your own OpenBSD's experience ?
Portable and compatible interfaces are good.
Historically, incompatible interfaces are less good.
For PROT_SEAL in mmap(), I see it as a good and reasonable suggestion raised during the RFC process, and incorporate it into the patch set, there is nothing more and nothing less.
Yet, you and those who suggested it don't have a single line of userland code ready which will use this.
If openBSD doesn't want it, that is fine to me, it is not that I'm trying to force this into openBSD's kernel, I understand it is a different code base.
This has nothing to do with code base.
It is about attempting to decrease differences between systems; this approach which has always been valuable.
Divergence has always been painful.
OpenBSD now uses this for a high percent of the address space. It might be worth re-reading a description of the split of responsibility regarding who locks different types of memory in a process;
kernel (the majority, based upon what ELF layout tell us),
shared library linker (the next majority, dealing with shared library mappings and left-overs not determinable at kernel time),
libc (a small minority, mostly regarding forced mutable objects)
and the applications themselves (only 1 application today)
The MAP_SEALABLE bit in the flags field of mmap(). When present, it marks the map as sealable. A map created without MAP_SEALABLE will not support sealing, i.e. mseal() will fail.
We definately won't be doing this. We allow a process to lock any and all it's memory that isn't locked already, even if it means it is shooting itself in the foot.
I think you are going to severely hurt the power of this mechanism, because you won't be able to lock memory that has been allocated by a different callsite not under your source-code control which lacks the MAP_SEALABLE flag. (Which is extremely common with the system-parts of a process, meaning not just libc but kernel allocated objects).
MAP_SEALABLE was an open discussion item called out on V3 [2] and V4 [3].
I acknowledge that additional coordination would be required if mapping were to be allocated by one software component and sealed in another. However, this is feasible.
Considering the side effect of not having this flag (as discussed in V3/V4) and the significant implications of altering the lifetime of the mapping (since unmapping would not be possible), I believe it is reasonable to expect developers to exercise additional care and caution when utilizing memory sealing.
[2] https://lore.kernel.org/linux-mm/20231212231706.2680890-2-jeffxu@chromium.or... [3] https://lore.kernel.org/all/20240104185138.169307-1-jeffxu@chromium.org/
I disagree *strongly*. Developers need to exercise additional care on memory, period. Memory sealing issues is the least of their worries.
(Except for handling RELRO, but only the ld.so developers will lose their hair).
OK, so mseal and mimmutable are very different.
mimmutable can be used by any developer on the address space easily.
mseal requires control of the whole stack between allocation and consumption.
I'm sorry, but I don't think you understand how dangerous this MAP_SEALABLE proposal is because of the difficulties it will create for use.
The immutable memory management we have today in OpenBSD would completely impossible with such a flag. Seperation between allocator (that doesn't know what is going to happen), and consumer (that does know), is completely common in the systems environment (meaning the interaction between DSO, libc, other libraries, and the underside of applications).
This is not not like an application where you can simply sprinkle the flag into the mmap() calls that cause you problems. That mmap() call is now in someone else's code, and you CANNOT gain security advantage unless you convince them to gain an understanding of what that flag means -- and it is a flag that other Linux variants don't have, not even in their #include files.
I respect your reasoning with OpenBSD, but do you have a real example that this will be problematic for linux ?
See below.
In my opinion, the extra communication part with mmap()'s owner has its pros and cons.
See below.
The cons is what you mentioned: extra time for convincing and approval.
No, it is much worse than that. See below.
The pro is that there won't be unexpected behavior from the code owner point of view, once this communication process is completed. It can reduce the possibility of introducing bugs.
So far, I do not have enough information to say this is a bad idea. if you can provide a real example in the context of linux, e.g. DSO and libc you mentioned with details, that will be helpful.
Does the kernel map the main program's text segment, data segment, bss segment, and stack with MAP_SEALABLE or without MAP_SEALABLE?
Once it is mapped, userland starts running.
If those objects don't have MAP_SEALABLE, then ld.so and libc cannot perform locking of those mappings. And ld.so or libc must do some of those lockings later, some of these map lockings cannot be performed in the kernel because userland makes data modifications and permission modifications before proceeding into main().
This is unavoidable, because of RELRO; binaries with text relocation; binaries with W|X mappings; it is probably required for IFUNC setup; and I strongly suspect there are additional circumstances which require this, *just for glibc* to use the mechanism.
If the kernel does map those regions with MAP_SEALABLE, then it seems the most important parts of the address space are going to have MAP_SEALABLE anyways. So what were you trying to defend against?
So why are you doing this MAP_SEALABLE dance? It makes no sense.
I'm sorry, but it is you who must justify these strange semantics which you are introducing -- to change a mechanism previously engineered and fully deployed in another operating system. To me, not being able to justify these behavious seems to be based on intentional ignorance. "Not Invented Here", is what I see.
You say glibc will use this. I call bollocks. I see a specific behaviour which will prevent use by glibc. I designed my mechanism with libc specifically considered -- it was a whole system environment.
You work on chrome. You don't work on glibc. The glibc people aren't publically talking about this. From my perspective, this is looking really dumb.