Hold baseEndpoint.mu when calling baseEndpoint.Connected()

Connected must be called with baseEndpoint.mu locked. Updated method comment
to include this precondition.

Reported-by: syzbot+3ee57917033a3a23c8e0@syzkaller.appspotmail.com
PiperOrigin-RevId: 432506434
This commit is contained in:
Nicolas Lacasse
2022-03-04 12:26:21 -08:00
committed by gVisor bot
parent 0b81a0d7b2
commit b1ceabc884
3 changed files with 6 additions and 0 deletions
@@ -519,6 +519,8 @@ func (e *connectionedEndpoint) State() uint32 {
// OnSetSendBufferSize implements tcpip.SocketOptionsHandler.OnSetSendBufferSize.
func (e *connectionedEndpoint) OnSetSendBufferSize(v int64) (newSz int64) {
e.Lock()
defer e.Unlock()
if e.Connected() {
return e.baseEndpoint.connected.SetSendBufferSize(v)
}
@@ -222,6 +222,8 @@ func (e *connectionlessEndpoint) State() uint32 {
// OnSetSendBufferSize implements tcpip.SocketOptionsHandler.OnSetSendBufferSize.
func (e *connectionlessEndpoint) OnSetSendBufferSize(v int64) (newSz int64) {
e.Lock()
defer e.Unlock()
if e.Connected() {
return e.baseEndpoint.connected.SetSendBufferSize(v)
}
+2
View File
@@ -813,6 +813,8 @@ func (e *baseEndpoint) ConnectedPasscred() bool {
}
// Connected implements ConnectingEndpoint.Connected.
//
// Preconditions: e.mu must be held.
func (e *baseEndpoint) Connected() bool {
return e.receiver != nil && e.connected != nil
}