Re: Sealed memfd & no-fault mmap

From: Ming Lin
Date: Thu Jun 03 2021 - 16:08:04 EST


On 6/3/2021 6:01 AM, Simon Ser wrote:


Regarding the requirements for Wayland:

- The baseline requirement is being able to avoid SIGBUS for read-only mappings
of shm files.
- Wayland clients can expand their shm files. However the compositor doesn't
need to immediately access the new expanded region. The client will tell the
compositor what the new shm file size is, and the compositor will re-map it.
- Ideally, MAP_NOSIGBUS would work on PROT_WRITE + MAP_SHARED mappings (of
course, the no-SIGBUS behavior would be restricted to that mapping). The
use-case is writing back to client buffers e.g. for screen capture. From the
earlier discussions it seems like this would be complicated to implement.
This means we'll need to come up with a new libwayland API to allow
compositors to opt-in to the read-only mappings. This is sub-optimal but
seems doable.
- Ideally, MAP_SIGBUS wouldn't be restricted to shm. There are use-cases for
using it on ordinary files too, e.g. for sharing ICC profiles. But from the
earlier replies it seems very unlikely that this will become possible, and
making it work only on shm files would already be fantastic.

In the new version of the patches, MAP_NOSIGBUS is not restricted to shmem.
It can be used on ordinary files.