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
This commit is contained in:
Bhasker Hariharan 2020-09-08 12:29:26 -07:00 committed by gVisor bot
parent d35f07b36a
commit 38cdb0579b
1 changed files with 2 additions and 0 deletions

View File

@ -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
}