[1.0] Fix failure with rw bind mount of a ro fuse#3292
Merged
AkihiroSuda merged 1 commit intoopencontainers:release-1.0from Nov 23, 2021
Merged
[1.0] Fix failure with rw bind mount of a ro fuse#3292AkihiroSuda merged 1 commit intoopencontainers:release-1.0from
AkihiroSuda merged 1 commit intoopencontainers:release-1.0from
Conversation
As reported in [1], in a case where read-only fuse (sshfs) mount
is used as a volume without specifying ro flag, the kernel fails
to remount it (when adding various flags such as nosuid and nodev),
returning EPERM.
Here's the relevant strace line:
> [pid 333966] mount("/tmp/bats-run-PRVfWc/runc.RbNv8g/bundle/mnt", "/proc/self/fd/7", 0xc0001e9164, MS_NOSUID|MS_NODEV|MS_REMOUNT|MS_BIND|MS_REC, NULL) = -1 EPERM (Operation not permitted)
I was not able to reproduce it with other read-only mounts as the source
(tried tmpfs, read-only bind mount, and an ext2 mount), so somehow this
might be specific to fuse.
The fix is to check whether the source has RDONLY flag, and retry the
remount with this flag added.
A test case (which was kind of hard to write) is added, and it fails
without the fix. Note that rootless user need to be able to ssh to
rootless@localhost in order to sshfs to work -- amend setup scripts
to make it work, and skip the test if the setup is not working.
[1] containers/podman#12205
Signed-off-by: Kir Kolyshkin <[email protected]>
(cherry picked from commit 50105de)
Conflicts:
- .cirrus.yml: trivial, due to missing commit f0dbefa.
- .github/workflows/test.yml: due to missing commits 120f740 and
3fd1851, resolved manually.
- Dockerfile: trivial, due to missing commit 24d318b.
- libcontainer/rootfs_linux.go: due to missing commits 36aefad
and 9c44407, resolved manually.
Signed-off-by: Kir Kolyshkin <[email protected]>
AkihiroSuda
approved these changes
Nov 23, 2021
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.
This is a backport of #3283 to release-1.0 branch. See original PR for details.
Fixes: containers/podman#12205