From ea5045432d93f4474a1265f1a834eb918ad5c2de Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Sat, 7 Oct 2023 23:38:12 +0200 Subject: [PATCH] container: always check if mountpoint is mounted when running as a service, the c.state.Mounted flag could get out of sync if the container is cleaned up through the cleanup process. To avoid this, always check if the mountpoint is really present before skipping the mount. [NO NEW TESTS NEEDED] Closes: https://github.com/containers/podman/issues/17042 Signed-off-by: Giuseppe Scrivano --- libpod/container_internal.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libpod/container_internal.go b/libpod/container_internal.go index 4098296b5f20..8db662ec8981 100644 --- a/libpod/container_internal.go +++ b/libpod/container_internal.go @@ -1539,7 +1539,11 @@ func (c *Container) mountStorage() (_ string, deferredErr error) { var err error // Container already mounted, nothing to do if c.state.Mounted { - return c.state.Mountpoint, nil + if mounted, err := mount.Mounted(c.state.Mountpoint); err != nil { + return "", fmt.Errorf("unable to determine if %q is mounted: %w", c.state.Mountpoint, err) + } else if mounted { + return c.state.Mountpoint, nil + } } if !c.config.NoShm {