Re: [PATCH v7 2/4] mseal: add mseal syscall

From: Theo de Raadt
Date: Wed Jan 24 2024 - 15:51:49 EST


Theo de Raadt <deraadt@xxxxxxxxxxx> wrote:

> This discussion about the malloc heap is ridiculous. Obviously it is
> programmer error to lock the permissions on memory you will free for
> reuse. But you can't fix this problem with malloc(), without breaking
> other extremely common circumstances where the allocation of memory
> and PERMANENT-USE-WITHOUT-RELEASE of such memory are seperated over a
> memory boundary, unless you start telling all open source library authors

^^^^^^^^^^^^^^^ library boundary, sorry

> to always use MAP_SEALABLE in their mmap() calls.

Example:

1. libcrypto (or some other library) has some ways to allocate memory and
provide it to an application.
2. Even if this is using malloc(), heap allocations over a pagesize are
page-aligned, so even then following assumptions are sound.
3. I have an application which uses that memory, but will never release the memory
until program termination
4. The library interface is public and used by many programs, so the library
author has a choice of using MAP_SEALABLE or not using MAP_SEALABLE

Due to your choice, my application cannot make lock the memory permissions
unless that library author chooses MAP_SEALABLE

If they choose to use MAP_SEALABLE, all programs get this memory you consider
less safe.

Exactly what is being gained here?