Skip to content

Do not allow mounting to machine dir /tmp #25466

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

Merged
merged 1 commit into from
Mar 9, 2025

Conversation

baude
Copy link
Member

@baude baude commented Mar 4, 2025

the destination machine mount overwrote /tmp. Here I have added a sanity check. I also moved the volume parsing and check earlier in the init function so that one does not have to endure the decompression and clean up of the machine image for cli parsing.

Fixes: #18230

Does this PR introduce a user-facing change?

Fixed bug #18230 where mounting to machine mount to /tmp causes unexpected results.

@openshift-ci openshift-ci bot added release-note approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Mar 4, 2025
@baude
Copy link
Member Author

baude commented Mar 5, 2025

i'm thinking i should probably add a test that checks that /tmp/foo is a valid mount

Copy link
Member

@Luap99 Luap99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, however that raises the question if we restrict /tmp why no other paths. Surely mounting over /etc, /var, /usr, /run and many more would brick the system in possibly even worse ways. I even have seen people mounting /var/lib/containers (or the home dir path) which cannot work as our virtofs mount seem to be limted to a single uid so it cannot work as universal storage path.

So it would be better to rework that to block a defined list of mounts I think.

Copy link

Ephemeral COPR build failed. @containers/packit-build please check.

@baude
Copy link
Member Author

baude commented Mar 5, 2025

however that raises the question if we restrict /tmp why no other paths.

because we are fixing bugs on specific bug reports. that said, I am fine with reworking this again. Are /tmp /etc/ /var the only ones you want restricted? How about /dev , /usr , /proc /sys /bin?

@Luap99
Copy link
Member

Luap99 commented Mar 5, 2025

How about /bin /boot /dev /etc /home /proc /root /run /sbin /sys /tmp /usr /var?
That should cover all the important root dirs I think. Of course mounting a sub directory might still mess things up but it is impossible to catch all while allowing generic mounts.

@baude baude force-pushed the issue18230 branch 2 times, most recently from 61c2f13 to 78762e6 Compare March 5, 2025 20:22
Copy link
Member

@jakecorrenti jakecorrenti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -149,6 +149,11 @@ options are:
* **rw**: mount volume read/write (default)
* **security_model=[model]**: specify 9p security model (see below)

Note: The following destinations are forbidden for volumes: `/bin`, `/boot`, `/dev`, `/etc`,
`/home`, `/proc`, `/root`, `/run`, `/sbin`, `/sys`, `/tmp`, `/usr`, and `/var`. Subdirectories
of these destinations are allowed.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While we do allow subdirectories, it is still not recommend, maybe it should be made clear that mounting over existing important system directories is not supported and can lead to many issues.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with the drift of this PR, it has lost some of its meaning. In the case of /tmp, subdirs are fine as you point out but in that case I have no problem recommending it. /var on the other hand, yeah ... not a good idea imho

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i added in some text to say users need to be careful.

Copy link
Member

@Luap99 Luap99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

When certain directories, like /tmp, get mounted over, FCOS/Linux can
act in unexpected ways.  Added a sanity check for a list of directories
think might be impacted by this.  Also, moved the volume parsing earlier
in the init process so we can catch problems before the expensive
decompression of machine images.

The following destinations are forbidden for volumes:

`/bin`, `/boot`, `/dev`, `/etc`, `/home`, `/proc`, `/root`, `/run`, `/sbin`, `/sys`, `/tmp`, `/usr`, and `/var`. Subdirectories

Fixes: containers#18230

Signed-off-by: Brent Baude <[email protected]>
Copy link
Member

@Luap99 Luap99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Mar 7, 2025
Copy link
Contributor

openshift-ci bot commented Mar 7, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: baude, jakecorrenti, Luap99

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

@openshift-merge-bot openshift-merge-bot bot merged commit 2077faa into containers:main Mar 9, 2025
89 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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. machine release-note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

podman run fails if --tty or -t is used and /tmp is mapped to the podman machine
3 participants