Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libnetwork: protect field access with libnetwork to avoid possible data race #45113

Open
yanke-xu opened this issue Mar 7, 2023 · 0 comments
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

Comments

@yanke-xu
Copy link

yanke-xu commented Mar 7, 2023

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

Nil

docker info

Nil

Additional Info

No response

@yanke-xu yanke-xu added kind/bug Bugs are bugs. The cause may or may not be known at triage time so debugging may be needed. status/0-triage labels Mar 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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
Projects
None yet
Development

No branches or pull requests

2 participants