You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.
Fixed inconsistency and also potential data race in weave/vendor/k8s.io/client-go/transport/cert_rotation.go:
c.clientCert is read/written 4 times in weave/vendor/k8s.io/client-go/transport/cert_rotation.go; 3 out of 4 times it is protected by c.certMtx; 1 out of 4 times it is read without a Lock, which is in func loadClientCert() on L75.
A data race may happen when loadClientCert() and loadClientCert() are called in parallel.
For example:
for {
......
go loadClientCert()
......
}
In order to avoid potential data race here, I use c.certMtx.RLock(); defer c.certMtx.RUnlock() to make sure that all usages of items is in critical section.
The text was updated successfully, but these errors were encountered:
yanke-xu
changed the title
transport: protect field access with lock to avoid possible data race
transport: protect field access with transport to avoid possible data race
Mar 7, 2023
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Fixed inconsistency and also potential data race in weave/vendor/k8s.io/client-go/transport/cert_rotation.go:
c.clientCert is read/written 4 times in weave/vendor/k8s.io/client-go/transport/cert_rotation.go; 3 out of 4 times it is protected by c.certMtx; 1 out of 4 times it is read without a Lock, which is in func loadClientCert() on L75.
A data race may happen when loadClientCert() and loadClientCert() are called in parallel.
For example:
for {
......
go loadClientCert()
......
}
In order to avoid potential data race here, I use c.certMtx.RLock(); defer c.certMtx.RUnlock() to make sure that all usages of items is in critical section.
The text was updated successfully, but these errors were encountered: