-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Allow bind mounts of nodev,nosuid,noexec filesystems #3805
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,20 @@ | |
load helpers | ||
|
||
function setup() { | ||
# Create a ro fuse-sshfs mount; skip the test if it's not working. | ||
setup_busybox | ||
update_config '.process.args = ["/bin/echo", "Hello World"]' | ||
} | ||
|
||
function teardown() { | ||
# Some distros do not have fusermount installed | ||
# as a dependency of fuse-sshfs, and good ol' umount works. | ||
fusermount -u "$DIR" || umount "$DIR" | ||
|
||
teardown_bundle | ||
} | ||
|
||
function setup_sshfs() { | ||
# Create a fuse-sshfs mount; skip the test if it's not working. | ||
local sshfs="sshfs | ||
-o UserKnownHostsFile=/dev/null | ||
-o StrictHostKeyChecking=no | ||
|
@@ -12,30 +25,86 @@ function setup() { | |
DIR="$BATS_RUN_TMPDIR/fuse-sshfs" | ||
mkdir -p "$DIR" | ||
|
||
if ! $sshfs -o ro rootless@localhost: "$DIR"; then | ||
if ! $sshfs -o "$1" rootless@localhost: "$DIR"; then | ||
skip "test requires working sshfs mounts" | ||
fi | ||
} | ||
|
||
setup_busybox | ||
update_config '.process.args = ["/bin/echo", "Hello World"]' | ||
@test "runc run [rw bind mount of a ro fuse sshfs mount]" { | ||
setup_sshfs "ro" | ||
update_config ' .mounts += [{ | ||
type: "bind", | ||
source: "'"$DIR"'", | ||
destination: "/mnt", | ||
options: ["rw", "rprivate", "nosuid", "nodev", "rbind"] | ||
}]' | ||
|
||
runc run --no-mount-fallback test_busybox | ||
[ "$status" -eq 0 ] | ||
} | ||
|
||
function teardown() { | ||
# New distros (Fedora 35) do not have fusermount installed | ||
# as a dependency of fuse-sshfs, and good ol' umount works. | ||
fusermount -u "$DIR" || umount "$DIR" | ||
@test "runc run [dev,exec,suid,atime bind mount of a nodev,nosuid,noexec,noatime fuse sshfs mount]" { | ||
setup_sshfs "nodev,nosuid,noexec,noatime" | ||
# The "sync" option is used to trigger a remount with the below options. | ||
# It serves no further purpose. Otherwise only a bind mount without | ||
# applying the below options will be done. | ||
update_config ' .mounts += [{ | ||
type: "bind", | ||
source: "'"$DIR"'", | ||
destination: "/mnt", | ||
options: ["dev", "suid", "exec", "atime", "rprivate", "rbind", "sync"] | ||
}]' | ||
|
||
teardown_bundle | ||
runc run test_busybox | ||
[ "$status" -eq 0 ] | ||
} | ||
|
||
@test "runc run [rw bind mount of a ro fuse sshfs mount]" { | ||
@test "runc run [ro bind mount of a nodev,nosuid,noexec,noatime fuse sshfs mount]" { | ||
setup_sshfs "nodev,nosuid,noexec,noatime" | ||
update_config ' .mounts += [{ | ||
type: "bind", | ||
source: "'"$DIR"'", | ||
destination: "/mnt", | ||
options: ["rw", "rprivate", "nosuid", "nodev", "rbind"] | ||
options: ["rbind", "ro"] | ||
}]' | ||
|
||
runc run test_busybox | ||
[ "$status" -eq 0 ] | ||
} | ||
|
||
@test "runc run [dev,exec,suid,atime bind mount of a nodev,nosuid,noexec,noatime fuse sshfs mount without fallback]" { | ||
setup_sshfs "nodev,nosuid,noexec,noatime" | ||
# The "sync" option is used to trigger a remount with the below options. | ||
# It serves no further purpose. Otherwise only a bind mount without | ||
# applying the below options will be done. | ||
update_config ' .mounts += [{ | ||
type: "bind", | ||
source: "'"$DIR"'", | ||
destination: "/mnt", | ||
options: ["dev", "suid", "exec", "atime", "rprivate", "rbind", "sync"] | ||
}]' | ||
|
||
runc run --no-mount-fallback test_busybox | ||
# The above will fail as we added --no-mount-fallback which causes us not to | ||
# try to remount a bind mount again after the first attempt failed on source | ||
# filesystems that have nodev, noexec, nosuid, noatime set. | ||
[ "$status" -ne 0 ] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you add a comment line to explain how/why this fails? |
||
[[ "$output" == *"runc run failed: unable to start container process: error during container init: error mounting"*"operation not permitted"* ]] | ||
} | ||
|
||
@test "runc run [ro bind mount of a nodev,nosuid,noexec,noatime fuse sshfs mount without fallback]" { | ||
setup_sshfs "nodev,nosuid,noexec,noatime" | ||
update_config ' .mounts += [{ | ||
type: "bind", | ||
source: "'"$DIR"'", | ||
destination: "/mnt", | ||
options: ["rbind", "ro"] | ||
}]' | ||
|
||
runc run --no-mount-fallback test_busybox | ||
# The above will fail as we added --no-mount-fallback which causes us not to | ||
# try to remount a bind mount again after the first attempt failed on source | ||
# filesystems that have nodev, noexec, nosuid, noatime set. | ||
[ "$status" -ne 0 ] | ||
[[ "$output" == *"runc run failed: unable to start container process: error during container init: error mounting"*"operation not permitted"* ]] | ||
} |
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original test has to be kept
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved out my check to a new bats test file (b7bb49b). Furthermore I reviewed the test again and I could simplify it and make it more like the existing test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One more rebase done. After the rebase is before the next one :-)
Fixed commit message.