From a7e1fe92f5885543ad65b6a195b907940f859ffe Mon Sep 17 00:00:00 2001 From: Nicolas Lacasse Date: Wed, 10 May 2023 12:04:19 -0700 Subject: [PATCH] Don't hold baseEndpoint.mu when calling receiver.Recv. We only need baseEndpoint.mu to read e.receiver, which we copy before calling Recv() on in. Reported-by: syzbot+f8566b86ff7c2613d8ce@syzkaller.appspotmail.com Reported-by: syzbot+9f8368319cf3570ea45b@syzkaller.appspotmail.com PiperOrigin-RevId: 530970638 --- pkg/sentry/socket/unix/transport/unix.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pkg/sentry/socket/unix/transport/unix.go b/pkg/sentry/socket/unix/transport/unix.go index 3b865950a..26528b91f 100644 --- a/pkg/sentry/socket/unix/transport/unix.go +++ b/pkg/sentry/socket/unix/transport/unix.go @@ -870,15 +870,14 @@ func (e *baseEndpoint) Connected() bool { // RecvMsg reads data and a control message from the endpoint. func (e *baseEndpoint) RecvMsg(ctx context.Context, data [][]byte, creds bool, numRights int, peek bool, addr *Address) (int64, int64, ControlMessages, bool, func(), *syserr.Error) { e.Lock() - receiver := e.receiver + e.Unlock() + if receiver == nil { - e.Unlock() return 0, 0, ControlMessages{}, false, nil, syserr.ErrNotConnected } recvLen, msgLen, cms, cmt, a, notify, err := receiver.Recv(ctx, data, creds, numRights, peek) - e.Unlock() if err != nil { return 0, 0, ControlMessages{}, false, nil, err }