Skip to content

Commit 7eb6a2a

Browse files
committed
Add /var/lib/containers/storage/ to illegal mount validation.
Due to the virtiofs filesystem limitations, it cannot deal with multiple uids/gids that are required for the container storage. Fixes: #27183 Signed-off-by: Lili Nie <[email protected]>
1 parent 32d6c54 commit 7eb6a2a

File tree

3 files changed

+24
-16
lines changed

3 files changed

+24
-16
lines changed

docs/source/markdown/podman-machine-init.1.md.in

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,11 @@ options are:
157157
* **security_model=[model]**: specify 9p security model (see below)
158158

159159
Note: The following destinations are forbidden for volumes: `/bin`, `/boot`, `/dev`, `/etc`,
160-
`/home`, `/proc`, `/root`, `/run`, `/sbin`, `/sys`, `/tmp`, `/usr`, and `/var`. Subdirectories
161-
of these destinations are allowed but users should be careful to not mount to important directories
162-
as unexpected results may occur.
160+
`/home`, `/proc`, `/root`, `/run`, `/sbin`, `/sys`, `/tmp`, `/usr`, and `/var`. Additionally,
161+
`/var/lib/containers/storage/` is forbidden due to virtiofs filesystem limitations that cannot
162+
handle the multiple UIDs/GIDs required for container storage (particularly relevant on macOS and
163+
other platforms using virtiofs). Subdirectories of these destinations are allowed but users should
164+
be careful to not mount to important directories as unexpected results may occur.
163165

164166

165167
The 9p security model [determines] https://wiki.qemu.org/Documentation/9psetup#Starting_the_Guest_directly

pkg/machine/shim/host.go

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -820,19 +820,20 @@ func Reset(mps []vmconfigs.VMProvider, _ machine.ResetOptions) error {
820820
func validateDestinationPaths(dest string) error {
821821
// illegalMounts are locations at the / level of the podman machine where we do want users mounting directly over
822822
illegalMounts := map[string]struct{}{
823-
"/bin": {},
824-
"/boot": {},
825-
"/dev": {},
826-
"/etc": {},
827-
"/home": {},
828-
"/proc": {},
829-
"/root": {},
830-
"/run": {},
831-
"/sbin": {},
832-
"/sys": {},
833-
"/tmp": {},
834-
"/usr": {},
835-
"/var": {},
823+
"/bin": {},
824+
"/boot": {},
825+
"/dev": {},
826+
"/etc": {},
827+
"/home": {},
828+
"/proc": {},
829+
"/root": {},
830+
"/run": {},
831+
"/sbin": {},
832+
"/sys": {},
833+
"/tmp": {},
834+
"/usr": {},
835+
"/var": {},
836+
"/var/lib/containers/storage/": {},
836837
}
837838
mountTarget := path.Clean(dest)
838839
if _, ok := illegalMounts[mountTarget]; ok {

pkg/machine/shim/host_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ func Test_validateDestinationPaths(t *testing.T) {
4747
dest: "/foobar",
4848
wantErr: false,
4949
},
50+
{
51+
name: "/var/lib/containers/storage/ should fail",
52+
dest: "/var/lib/containers/storage/",
53+
wantErr: true,
54+
},
5055
}
5156
for _, tt := range tests {
5257
t.Run(tt.name, func(t *testing.T) {

0 commit comments

Comments
 (0)