diff options
author | Paul Holzinger <pholzing@redhat.com> | 2021-12-01 18:55:08 +0100 |
---|---|---|
committer | Paul Holzinger <pholzing@redhat.com> | 2021-12-01 19:19:44 +0100 |
commit | 3ff47748dea946775b8f4ec8e1c644c2efb3950b (patch) | |
tree | b332a07a1495152c97b589ea17cff35b53d5dc81 /pkg | |
parent | 295a6f7dd086731448a1168a349f62d3035258ca (diff) | |
download | podman-3ff47748dea946775b8f4ec8e1c644c2efb3950b.tar.gz podman-3ff47748dea946775b8f4ec8e1c644c2efb3950b.tar.bz2 podman-3ff47748dea946775b8f4ec8e1c644c2efb3950b.zip |
Fix possible rootless netns cleanup race
rootlessNetNS.Cleanup() has an issue with how it detects if cleanup
is needed, reading the container state is not good ebough because
containers are first stopped and than cleanup will be called. So at one
time two containers could wait for cleanup but the second one will fail
because the first one triggered already the cleanup thus making rootless
netns unavailable for the second container resulting in an teardown
error. Instead of checking the container state we need to check the
netns state.
Secondly, podman unshare --rootless-netns should not do the cleanup.
This causes more issues than it is worth fixing. Users also might want
to use this to setup the namespace in a special way. If unshare also
cleans this up right away we cannot do this.
[NO NEW TESTS NEEDED]
Fixes #12459
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/domain/infra/abi/system.go | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/pkg/domain/infra/abi/system.go b/pkg/domain/infra/abi/system.go index 7da7754f2..e6c9d850b 100644 --- a/pkg/domain/infra/abi/system.go +++ b/pkg/domain/infra/abi/system.go @@ -365,9 +365,12 @@ func (ic *ContainerEngine) Unshare(ctx context.Context, args []string, options e if err != nil { return err } - // make sure to unlock, unshare can run for a long time + // Make sure to unlock, unshare can run for a long time. rootlessNetNS.Lock.Unlock() - defer rootlessNetNS.Cleanup(ic.Libpod) + // We do not want to cleanup the netns after unshare. + // The problem is that we cannot know if we need to cleanup and + // secondly unshare should allow user to setup the namespace with + // special things, e.g. potentially macvlan or something like that. return rootlessNetNS.Do(unshare) } return unshare() |