diff options
author | Bhasker Hariharan <bhaskerh@google.com> | 2020-09-08 12:29:26 -0700 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-09-08 12:31:19 -0700 |
commit | 38cdb0579b698d67abad4f7f6ba18a84eef66bd7 (patch) | |
tree | 11a727e714c3767e7d25fa65a09b704e9a50193c | |
parent | d35f07b36a40ee94b3a5b588a5fa62572753c620 (diff) |
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
-rw-r--r-- | pkg/tcpip/transport/tcp/endpoint.go | 2 |
1 files changed, 2 insertions, 0 deletions
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 } |