exec: add optional --exec-wait-fifo#5375
Open
cpuguy83 wants to merge 1 commit into
Open
Conversation
When you run exec with --detach you can already get the new process's pidfd and pid before it runs, but nothing actually holds the process there. The program can execve, and possibly exit, before whatever is supervising it has finished adopting it. I didn't want to build out a whole create/start style lifecycle for exec just to get that, when all it really needs is a single wait point right before execve. So this adds an opt-in --exec-wait-fifo <path>. The caller creates and owns the fifo. runc passes it into the setns process, which does all of its normal setup and then, just before execve, opens the fifo for writing. That open blocks until something opens the read end, so a supervisor can finish its handoff and then open the fifo to let the program run. We write a byte and exec. It's the same handshake create/start already use with the internal exec.fifo, so this reuses that path (awaitExecFifo) instead of adding another one. The O_PATH fd is closed before execve so the CVE-2016-9962 workaround still holds on old kernels. Nothing changes when the flag isn't set. Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Contributor
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.
Closes #5373
Alternative to implementing full create/start split as suggested in #3453
When you run
runc exec --detachyou can already get the new process's pidfd (--pidfd-socket) and pid (--pid-file) before it runs, but nothing actually holds the process there. The program can execve, and possibly exit, before whatever is supervising it has finished adopting it. I didn't want to build out a whole create/start style lifecycle for exec just to get that, when all it really needs is a single wait point right before execve.So this adds an opt-in
--exec-wait-fifo <path>. The caller creates and owns the fifo. runc passes it into the setns process, which does all of its normal setup and then, just before execve, opens the fifo for writing. That open blocks until something opens the read end, so a supervisor can finish its handoff and then open the fifo to let the program run. We write a byte and exec.It's the same handshake
create/startalready use with the internal exec.fifo, so this reuses that path (awaitExecFifo) instead of adding another one.Typical flow for a supervisor:
--detach,--pid-file,--pidfd-socket,--exec-wait-fifoAdded an integration test covering the wait behavior plus the not-a-fifo and missing-path errors.