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

util/misc: support kernels where MFD_NOEXEC_SEAL does not enable sealing #366

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

pobrn
Copy link

@pobrn pobrn commented May 23, 2024

I am trying to squash the kernel's peculiar behaviour of implicitly enabling sealing on MFD_NOEXEC_SEAL. dbus-broker is one of the affected programs, but as noted below, only the test suite would break, normal operations wouldn't. At least as far as I can tell.


Newer Linux kernels do not unset F_SEAL_SEAL when MFD_NOEXEC_SEAL is supplied to memfd_create(). Currently, misc_memfd() has a workaround for this peculiarity of the kernel, however, this workaround will break.

Avoid the breakage by checking if the kernel added F_SEAL_SEAL, and only try to add it if it is not already present.

Note that this kernel uAPI change does not affect dbus-broker's normal operations since it never attempts to create a memfd with MFD_NOEXEC_SEAL and without MFD_ALLOW_SEALING. Only the test suite would be broken on newer kernels without this change.


v2: https://lore.kernel.org/linux-mm/[email protected]/
v1: https://lore.kernel.org/linux-mm/[email protected]/

@pobrn pobrn force-pushed the kernel_noexec_noimply_allowseal branch from 0030cff to 9bd6489 Compare May 23, 2024 01:39
Copy link
Member

@dvdhrm dvdhrm left a comment

Choose a reason for hiding this comment

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

Thanks! I am certainly in favor of this change. I also replied on LKML. Few comments inline!

src/util/misc.c Outdated Show resolved Hide resolved
src/util/misc.c Outdated Show resolved Hide resolved
src/util/misc.c Outdated Show resolved Hide resolved
@dvdhrm
Copy link
Member

dvdhrm commented May 23, 2024

(I can also amend the changes myself when applying the patch. Let me know!)

…aling

Newer Linux kernels do not unset `F_SEAL_SEAL` when `MFD_NOEXEC_SEAL`
is supplied to `memfd_create()`[0]. Currently, `misc_memfd()`
has a workaround for this peculiarity of the kernel, however,
this workaround will break.

Avoid the breakage by checking if the kernel added `F_SEAL_SEAL`,
and only try to add it if it is not already present.

Note that this kernel uAPI change does not affect dbus-broker's
normal operations since it never attempts to create a memfd with
`MFD_NOEXEC_SEAL` and without `MFD_ALLOW_SEALING`. Only the test
suite would be broken on newer kernels without this change.

[0]: https://lore.kernel.org/linux-mm/[email protected]/
@pobrn pobrn force-pushed the kernel_noexec_noimply_allowseal branch from 9bd6489 to 6ac40fa Compare May 25, 2024 01:01
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

2 participants