From 7b33df68450bdb9519cf650a8d92fa4a81f37fa0 Mon Sep 17 00:00:00 2001 From: Fabricio Voznika Date: Tue, 19 Mar 2019 10:37:46 -0700 Subject: Fix data race in netlink send buffer size PiperOrigin-RevId: 239221041 Change-Id: Icc19e32a00fa89167447ab2f45e90dcfd61bea04 --- pkg/sentry/socket/netlink/socket.go | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'pkg/sentry/socket') diff --git a/pkg/sentry/socket/netlink/socket.go b/pkg/sentry/socket/netlink/socket.go index 5b0c11c84..7223773ad 100644 --- a/pkg/sentry/socket/netlink/socket.go +++ b/pkg/sentry/socket/netlink/socket.go @@ -291,6 +291,8 @@ func (s *Socket) GetSockOpt(t *kernel.Task, level int, name int, outLen int) (in if outLen < sizeOfInt32 { return nil, syserr.ErrInvalidArgument } + s.mu.Lock() + defer s.mu.Unlock() return int32(s.sendBufferSize), nil case linux.SO_RCVBUF: @@ -335,7 +337,9 @@ func (s *Socket) SetSockOpt(t *kernel.Task, level int, name int, opt []byte) *sy } else if size > maxSendBufferSize { size = maxSendBufferSize } + s.mu.Lock() s.sendBufferSize = size + s.mu.Unlock() return nil case linux.SO_RCVBUF: if len(opt) < sizeOfInt32 { -- cgit v1.2.3