libnetwork: protect field access with libnetwork to avoid possible data race #45113
Labels
area/networking
kind/bug
Bugs are bugs. The cause may or may not be known at triage time so debugging may be needed.
status/0-triage
Description
Fixed inconsistency and also potential data race in moby/moby/blob/master/libnetwork/agent.go and moby/moby/blob/master/libnetwork/endpoint.go:
myAliases is read/written many times in moby/moby/blob/master/libnetwork/agent.go and moby/moby/blob/master/libnetwork/endpoint.go;
https://github.com/moby/moby/blob/master/libnetwork/agent.go#L681 is read without a Lock,
https://github.com/moby/moby/blob/master/libnetwork/endpoint.go#L221 is write with a Lock。
A data race may happen when the two operations are called in parallel.
In order to avoid potential data race here, I use xx.RLock(); defer xx.RUnlock() to make sure that all usages of items is in critical section.
Reproduce
Nil
Expected behavior
Data Race
docker version
docker info
Additional Info
No response
The text was updated successfully, but these errors were encountered: