diff options
author | Fabricio Voznika <fvoznika@google.com> | 2019-03-19 10:37:46 -0700 |
---|---|---|
committer | Shentubot <shentubot@google.com> | 2019-03-19 10:38:50 -0700 |
commit | 7b33df68450bdb9519cf650a8d92fa4a81f37fa0 (patch) | |
tree | 74fd48413c1eb83aaa18d69a2ff1ee77766c841e /pkg/sentry/socket/netlink/socket.go | |
parent | 928809fa7d3b682c7e2e06c9f9b1f3fb5d75a0d6 (diff) |
Fix data race in netlink send buffer size
PiperOrigin-RevId: 239221041
Change-Id: Icc19e32a00fa89167447ab2f45e90dcfd61bea04
Diffstat (limited to 'pkg/sentry/socket/netlink/socket.go')
-rw-r--r-- | pkg/sentry/socket/netlink/socket.go | 4 |
1 files changed, 4 insertions, 0 deletions
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 { |