From 03a529d8ac52ab0227a0bbd85aaa3d8808b11e59 Mon Sep 17 00:00:00 2001 From: Bhasker Hariharan Date: Tue, 8 Sep 2020 12:29:26 -0700 Subject: Fix data race in tcp.GetSockOpt. e.ID can't be read without holding e.mu. GetSockOpt was reading e.ID when looking up OriginalDst without holding e.mu. PiperOrigin-RevId: 330562293 --- pkg/tcpip/transport/tcp/endpoint.go | 2 ++ 1 file changed, 2 insertions(+) (limited to 'pkg/tcpip') diff --git a/pkg/tcpip/transport/tcp/endpoint.go b/pkg/tcpip/transport/tcp/endpoint.go index 8cb769d58..6d5046a3d 100644 --- a/pkg/tcpip/transport/tcp/endpoint.go +++ b/pkg/tcpip/transport/tcp/endpoint.go @@ -2019,8 +2019,10 @@ func (e *endpoint) GetSockOpt(opt tcpip.GettableSocketOption) *tcpip.Error { e.UnlockUser() case *tcpip.OriginalDestinationOption: + e.LockUser() ipt := e.stack.IPTables() addr, port, err := ipt.OriginalDst(e.ID) + e.UnlockUser() if err != nil { return err } -- cgit v1.2.3