Skip to content
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

Fix/improve pkg/storage.InitFSMounts #5676

Merged
merged 3 commits into from
Apr 3, 2020

Conversation

kolyshkin
Copy link
Contributor

Fix

Found the bug by reading the source for InitFSMounts(), confirmed with:

$ ./bin/podman run -v /tmp:/tmp alpine true; echo $?
0

$ ./bin/podman run -v /tmp:/tmp:ro alpine true; echo $?
0

$ ./bin/podman run -v /tmp:/w0w:ro alpine true; echo $?
> Error: container_linux.go:349: starting container process caused "process_linux.go:449: container init caused \"rootfs_linux.go:58: mounting \\\"/tmp\\\" to rootfs \\\"/home/kir/.local/share/containers/storage/overlay/7636ef3650fc91ee4996ccc026532bb3cff7182c0430db662fffb933e0bcadc9/merged\\\" at \\\"/home/kir/.local/share/containers/storage/overlay/7636ef3650fc91ee4996ccc026532bb3cff7182c0430db662fffb933e0bcadc9/merged/w0w\\\" caused \\\"operation not permitted\\\"\"": OCI runtime permission denied error
> 126

The last command is not working because in-container mount point
(i.e. mount destination, not the mount source) is used to search
for a parent mount in /proc/self/mountinfo.

And yet the following

$ ./bin/podman run -v /tmp:/run/test:ro alpine true; echo $?
0

still works fine! Here's why:

$ mount | grep -E '/run |/tmp '
tmpfs on /run type tmpfs (rw,nosuid,nodev,seclabel,mode=755)
tmpfs on /tmp type tmpfs (rw,nosuid,nodev,seclabel)

Fixes: #2432 (commit 0f5ae3c)
Related-to: #2312

Improve

Instead of getting mount options from /proc/self/mountinfo, which is
very costly to read/parse (and can even be unreliable), let's use
statfs(2) to figure out the flags we need.

> $ ./bin/podman run -v /tmp:/tmp alpine true; echo $?
> 0
> $ ./bin/podman run -v /tmp:/tmp:ro alpine true; echo $?
> 0
> $ ./bin/podman run -v /tmp:/w0w:ro alpine true; echo $?
> Error: container_linux.go:349: starting container process caused "process_linux.go:449: container init caused \"rootfs_linux.go:58: mounting \\\"/tmp\\\" to rootfs \\\"/home/kir/.local/share/containers/storage/overlay/7636ef3650fc91ee4996ccc026532bb3cff7182c0430db662fffb933e0bcadc9/merged\\\" at \\\"/home/kir/.local/share/containers/storage/overlay/7636ef3650fc91ee4996ccc026532bb3cff7182c0430db662fffb933e0bcadc9/merged/w0w\\\" caused \\\"operation not permitted\\\"\"": OCI runtime permission denied error
> 126

The last command is not working because in-container mount point
is used to search for a parent mount in /proc/self/mountinfo.

And yet the following

> $ ./bin/podman run -v /tmp:/run/test:ro alpine true; echo $?
> 0

still works fine! Here's why:

> $ mount | grep -E '/run |/tmp '
> tmpfs on /run type tmpfs (rw,nosuid,nodev,seclabel,mode=755)
> tmpfs on /tmp type tmpfs (rw,nosuid,nodev,seclabel)

This is the reason why previous commit modified in-container mount
point.

Fixes: 0f5ae3c
Signed-off-by: Kir Kolyshkin <[email protected]>
@openshift-ci-robot
Copy link
Collaborator

Hi @kolyshkin. Thanks for your PR.

I'm waiting for a containers member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@openshift-ci-robot openshift-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Mar 31, 2020
@kolyshkin
Copy link
Contributor Author

@giuseppe PTAL

@giuseppe
Copy link
Member

/approve

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 31, 2020
@rhatdan
Copy link
Member

rhatdan commented Mar 31, 2020

LGTM, but you have compiler errors.

@mheon
Copy link
Member

mheon commented Mar 31, 2020

/approve
/ok-to-test

I love the simplification of the mount parsing - this is much, much cleaner.

@openshift-ci-robot openshift-ci-robot added ok-to-test and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Mar 31, 2020
@openshift-ci-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: giuseppe, kolyshkin, mheon

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@mheon
Copy link
Member

mheon commented Mar 31, 2020

Looks like it needs to be gated to only compile on Linux, though, it's blowing up on Darwin.

pkg/spec/storage.go Outdated Show resolved Hide resolved
@kolyshkin
Copy link
Contributor Author

  • changed InitFSMounts to change options in place rather than creating a new slice
  • fixed non-Linux compilation (moved getting default options to pkg/util)

@kolyshkin
Copy link
Contributor Author

Looks like it needs to be gated to only compile on Linux, though, it's blowing up on Darwin.

done

@mheon May I ask why do we care for darwin?

@kolyshkin
Copy link
Contributor Author

Oh, any suggestions about how to add a regression test to CI for this are welcome. I tried it before (see e336840) but a CI has passed :-\

@rhatdan
Copy link
Member

rhatdan commented Mar 31, 2020

@kolyshkin containers/image which vendors in container/storage is used for skopeo on Macs. So we want to make sure the tool chain builds for Darwin.

@mheon
Copy link
Member

mheon commented Mar 31, 2020

The Darwin stuff in Libpod is a result of the current remote darwin client situation. Hopefully, once Podmanv2 is done, we will no longer need to have Podman build on OS X.

... rather than create a new slice and then make the caller
replace the original with the new one.

Signed-off-by: Kir Kolyshkin <[email protected]>
Instead of getting mount options from /proc/self/mountinfo, which is
very costly to read/parse (and can even be unreliable), let's use
statfs(2) to figure out the flags we need.

[v2: move getting default options to pkg/util, make it linux-specific]

Signed-off-by: Kir Kolyshkin <[email protected]>
@kolyshkin
Copy link
Contributor Author

I fixed the issues with my patch, current CI failures are (to my best knowledge) unrelated.

@mheon
Copy link
Member

mheon commented Apr 2, 2020

Look like known flakes. Code LGTM

kolyshkin added a commit to kolyshkin/podman that referenced this pull request Apr 2, 2020
For volume and bind mount tests, use the in-container mount point path
that has no common ancestor with any host path (except for root).

This might help to uncover bugs like [1]. Even if not, it seems
lile a good cleanup regardless.

[1] containers#5676

Signed-off-by: Kir Kolyshkin <[email protected]>
@rhatdan
Copy link
Member

rhatdan commented Apr 3, 2020

/lgtm
/hold
hold cancel when tests pass

@openshift-ci-robot openshift-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 3, 2020
@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Apr 3, 2020
@kolyshkin
Copy link
Contributor Author

@rhatdan CI is all green now

@mheon
Copy link
Member

mheon commented Apr 3, 2020

/hold cancel

@openshift-ci-robot openshift-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 3, 2020
@openshift-merge-robot openshift-merge-robot merged commit 2d9b9e8 into containers:master Apr 3, 2020
@kolyshkin kolyshkin deleted the volume-flags-alt branch April 4, 2020 01:23
snj33v pushed a commit to snj33v/libpod that referenced this pull request May 31, 2020
For volume and bind mount tests, use the in-container mount point path
that has no common ancestor with any host path (except for root).

This might help to uncover bugs like [1]. Even if not, it seems
lile a good cleanup regardless.

[1] containers#5676

Signed-off-by: Kir Kolyshkin <[email protected]>
@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 25, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. ok-to-test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants