Repository navigation
shared: Run scripts from a file when no executable memfd is available - #1014
Merged
Merged
Conversation
RunScript executes scripts through a memfd. With vm.memfd_noexec=2, memfd_create() refuses to create executable memfds, and with vm.memfd_noexec=1 a memfd created without MFD_EXEC can't be executed. Building an image with action scripts then fails, for example with "fork/exec /proc/self/fd/N: permission denied". Request an executable memfd with MFD_EXEC, retrying without it on kernels older than 6.3. When no executable memfd can be created, write the script to a temporary file, execute it and remove it afterwards. The kernel still takes care of the shebang. Signed-off-by: Alessandro Corbelli <git@initd.it>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
RunScript runs every action script (and a few helper scripts of the sources) by writing it to a memfd and executing /proc/self/fd/N. That can't work on hosts hardened with vm.memfd_noexec=2 (or =1): a memfd created with flags 0 isn't executable, and at level 2 memfd_create() refuses MFD_EXEC too. Any build with an action script fails right after the base system is unpacked:
Changes:
Nothing changes where an executable memfd is available.
Tested:
Notes: