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

common: Mark our memfds as non-executable #19823

Merged
merged 1 commit into from
Jan 9, 2024

Conversation

martinpitt
Copy link
Member

@martinpitt martinpitt commented Jan 8, 2024

We only ever use them to store data. Recent Linux kernels now encourage explicitly declaring whether a memfd is supposed to be executable [1]. This avoids an unsightly warning at boot:

login: [ 85.637785] cockpit-tls[1176]: memfd_create() called without MFD_EXEC or MFD_NOEXEC_SEAL set

Older kernel releases don't know about that flag yet, so add some ifdeffery and runtime fallback. We need to support building for a new distro/include files, but running on an older kernel.

[1] https://lwn.net/Articles/918106/


You can see this with bots/vm-run fedora-39

@martinpitt
Copy link
Member Author

FTR, current Python 3.12 does not expose these new constants yet. But we also only use os.memfd_create in a unit test.

@martinpitt martinpitt marked this pull request as draft January 8, 2024 08:30
@martinpitt
Copy link
Member Author

martinpitt commented Jan 8, 2024

Ugh, fails on aarch64 at least.

Update: Fixed.

@martinpitt
Copy link
Member Author

I've seen this udisks crash a lot, let's see if I can find out something more about it locally.

@martinpitt martinpitt marked this pull request as ready for review January 9, 2024 11:04
Copy link
Member

@allisonkarlitskaya allisonkarlitskaya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something is off here. I'm hoping it's a simple typo s/0/8U/...

src/common/cockpitjsonprint.c Outdated Show resolved Hide resolved
src/common/cockpitjsonprint.c Outdated Show resolved Hide resolved
@martinpitt
Copy link
Member Author

@allisonkarlitskaya no, it was not a typo, but deliberate (I had a version with 8, but then discarded it). See replies above.

We only ever use them to store data. Recent Linux kernels now encourage
explicitly declaring whether a memfd is supposed to be executable [1].
This avoids an unsightly warning at boot:

> login: [   85.637785] cockpit-tls[1176]: memfd_create() called without MFD_EXEC or MFD_NOEXEC_SEAL set

Older kernel releases don't know about that flag yet, so add some
ifdeffery and runtime fallback. We need to support building for a new
distro/include files, but running on an older kernel.

[1] https://lwn.net/Articles/918106/
Copy link
Member

@allisonkarlitskaya allisonkarlitskaya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the go-arounds. This is nicely self-contained and does everything it needs to.

@martinpitt
Copy link
Member Author

Eww, what happened to this aarch64 run.. retrying, can't hurt here.

@martinpitt martinpitt merged commit 992c989 into cockpit-project:main Jan 9, 2024
90 of 91 checks passed
@martinpitt martinpitt deleted the memfd-noexec branch January 9, 2024 17:47
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.

2 participants