Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

memfd: provide proper abstractions #323

Merged
merged 2 commits into from
Aug 7, 2023
Merged

memfd: provide proper abstractions #323

merged 2 commits into from
Aug 7, 2023

Conversation

dvdhrm
Copy link
Member

@dvdhrm dvdhrm commented Jul 14, 2023

Provide proper abstractions for memfd operations. This is especially necessary with the new MFD_EXEC and MFD_NOEXEC_SEAL features of the kernel, which requires all memfd users to update the code to use one of the new flags.

Unfortunately, they decided against providing MFD_NOEXEC, but instead just provide MFD_NOEXEC_SEAL, which is a combination of MFD_ALLOW_SEALING, MFD_NOEXEC, and F_SEAL_EXEC. This is really awkward to use in helpers, but I think I got something that works well enough.

Reported in #322.

Add proper helpers around memfds. This includes a new memfd-constructor
that follows newest kernel standards around EXEC/NOEXEC handling.

Furthermore, add GET_SEALS and ADD_SEALS wrappers to avoid open-coding
them all over the place.

This does not make use of the new helpers, yet, but only adds tests to
verify their behavior.

Reported-by: Дамјан Георгиевски
Signed-off-by: David Rheinsberg <david@readahead.eu>
Rather than open-coding the memfd syscalls, make use of the new
misc_memfd() helpers.

Signed-off-by: David Rheinsberg <david@readahead.eu>
@dvdhrm
Copy link
Member Author

dvdhrm commented Jul 14, 2023

(updated to use MFD_EXEC with journald since it rejects F_SEAL_EXEC)

@dvdhrm dvdhrm merged commit 293a3de into bus1:main Aug 7, 2023
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant