Fix failure with read-only /dev in spec#3276
Merged
cyphar merged 2 commits intoopencontainers:masterfrom Nov 25, 2021
Merged
Conversation
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
803c240 to
356c171
Compare
thaJeztah
previously approved these changes
Nov 15, 2021
Member
thaJeztah
left a comment
There was a problem hiding this comment.
LGTM (left one minor suggestion)
Commit fb4c27c (went into v1.0.0-rc93) fixed a bug with read-only tmpfs, but introduced a bug with read-only /dev. This happens because /dev is a tmpfs mount and is therefore remounted read-only a bit earlier than before. To fix, 1. Revert the part of the above commit which remounts all tmpfs mounts as read-only in mountToRootfs. 2. Reuse finalizeRootfs (which is already used to remount /dev read-only) to also remount all ro tmpfs mounts that were previously mounted rw in mountPropagate. 3. Remove the break in finalizeRootfs, as now we have more than one mount to care about. 4. Reorder the if statements in finalizeRootfs to perform the fast check (for ro flag) first, and compare the strings second. Since /dev is most probably also a tmpfs mount, do the m.Device check first. Add a test case to validate the fix and prevent future regressions; make sure it fails before the fix: ✗ runc run [ro /dev mount] (in test file tests/integration/mounts.bats, line 45) `[ "$status" -eq 0 ]' failed runc spec (status=0): runc run test_busybox (status=1): time="2021-11-12T12:19:48-08:00" level=error msg="runc run failed: unable to start container process: error during container init: error mounting \"devpts\" to rootfs at \"/dev/pts\": mkdir /tmp/bats-run-VJXQk7/runc.0Fj70w/bundle/rootfs/dev/pts: read-only file system" Fixes: fb4c27c Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
356c171 to
b247cd3
Compare
Contributor
Author
|
@AkihiroSuda @cyphar PTAL |
Contributor
Author
|
@AkihiroSuda PTAL |
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.
Commit fb4c27c (PR #2570, went into v1.0.0-rc93) fixed a bug with
read-only tmpfs, but introduced a bug with read-only /dev (#3248).
This happens because /dev is a tmpfs mount and is therefore remounted
read-only a bit earlier than before.
To fix,
Revert the part of the above commit which remounts all tmpfs mounts
as read-only in mountToRootfs.
Reuse finalizeRootfs (which is already used to remount /dev
read-only) to also remount all ro tmpfs mounts that were previously
mounted rw in mountPropagate.
Add a test case to validate the fix and prevent future regressions;
make sure it fails before the fix:
Fixes: #3248
1.0 backport: #3277