Repository navigation
fix(libcontainer): open /dev/null read-write in reopen_dev_null - #3947
Merged
Merged
Conversation
Signed-off-by: utam0k <k0ma@utam0k.jp>
Signed-off-by: utam0k <k0ma@utam0k.jp>
3 tasks done
saku3
approved these changes
Nov 29, 2026
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.
Description
A container cannot write to stdout or stderr when that fd is the host's
/dev/null.reopen_dev_null()swaps such fds for the container's/dev/null, but it opens that file read-only. Every write then fails withEBADF. On a GitHub runner, withprocess.argsset tosh -c "echo Hi, my PID is $$; echo Bye Bye":This opens
/dev/nullread-write, as runc'sreOpenDevNulldoes.I found it while fixing the benchmark workflow (#3948). hyperfine sends the benchmarked command's output to
/dev/nullby default.Type of Change
Testing
test_reopen_dev_null_keeps_stdout_writablepoints stdout at a write-only/dev/nullin a child process, callsreopen_dev_null(), and writes to stdout. The first commit adds the test, and it fails withEBADF: Bad file number. The second commit fixes the open, and the test passes.Also ran
cargo test -p libcontainer --lib process::init,cargo +nightly fmt --check -p libcontainer, andcargo clippy -p libcontainer --all-targets -- -D warnings.Additional Context
AI-assisted.