Skip to content

Commit

Permalink
getContainerNetworkInfo: lock netNsCtr before sync
Browse files Browse the repository at this point in the history
`syncContainer()` requires the container to be locked, otherwise we can
end up with undefined behavior.

[NO TESTS NEEDED]

Signed-off-by: Paul Holzinger <[email protected]>
  • Loading branch information
Luap99 authored and mheon committed Jun 24, 2021
1 parent b957bff commit ab5e770
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions libpod/networking_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -866,6 +866,10 @@ func (c *Container) getContainerNetworkInfo() (*define.InspectNetworkSettings, e
if err != nil {
return nil, err
}
// see https://github.com/containers/podman/issues/10090
// the container has to be locked for syncContainer()
netNsCtr.lock.Lock()
defer netNsCtr.lock.Unlock()
// Have to sync to ensure that state is populated
if err := netNsCtr.syncContainer(); err != nil {
return nil, err
Expand Down

0 comments on commit ab5e770

Please sign in to comment.