diff --git a/pkg/sentry/socket/unix/transport/BUILD b/pkg/sentry/socket/unix/transport/BUILD index 7d74be1cd..60575d520 100644 --- a/pkg/sentry/socket/unix/transport/BUILD +++ b/pkg/sentry/socket/unix/transport/BUILD @@ -22,8 +22,7 @@ declare_mutex( name = "endpoint_mutex", out = "endpoint_mutex.go", nested_lock_names = [ - "e", - "ce", + "higherID", ], package = "transport", prefix = "endpoint", diff --git a/pkg/sentry/socket/unix/transport/connectioned.go b/pkg/sentry/socket/unix/transport/connectioned.go index a61c145b6..7506a91b8 100644 --- a/pkg/sentry/socket/unix/transport/connectioned.go +++ b/pkg/sentry/socket/unix/transport/connectioned.go @@ -288,27 +288,27 @@ func (e *connectionedEndpoint) BidirectionalConnect(ctx context.Context, ce Conn // Do a dance to safely acquire locks on both endpoints. if e.id < ce.ID() { e.Lock() - ce.NestedLock(endpointLockCe) + ce.NestedLock(endpointLockHigherid) } else { ce.Lock() - e.NestedLock(endpointLockE) + e.NestedLock(endpointLockHigherid) } // Check connecting state. if ce.Connected() { - e.NestedUnlock(endpointLockE) + e.NestedUnlock(endpointLockHigherid) ce.Unlock() return syserr.ErrAlreadyConnected } if ce.ListeningLocked() { - e.NestedUnlock(endpointLockE) + e.NestedUnlock(endpointLockHigherid) ce.Unlock() return syserr.ErrInvalidEndpointState } // Check bound state. if !e.ListeningLocked() { - e.NestedUnlock(endpointLockE) + e.NestedUnlock(endpointLockHigherid) ce.Unlock() return syserr.ErrConnectionRefused } @@ -359,7 +359,7 @@ func (e *connectionedEndpoint) BidirectionalConnect(ctx context.Context, ce Conn } // Notify can deadlock if we are holding these locks. - e.NestedUnlock(endpointLockE) + e.NestedUnlock(endpointLockHigherid) ce.Unlock() // Notify on both ends. @@ -369,7 +369,7 @@ func (e *connectionedEndpoint) BidirectionalConnect(ctx context.Context, ce Conn return nil default: // Busy; return EAGAIN per spec. - e.NestedUnlock(endpointLockE) + e.NestedUnlock(endpointLockHigherid) ce.Unlock() ne.Close(ctx) return syserr.ErrTryAgain