netstack: revert SND.NXT when purging the write queue

There are only 3 places we remove from the write queue. The other two are
fairly self-contained and don't look suspicious. They are:

- tcp.sender.maybeSendSegment - removes iff the segments are merged
- tcp.sender.handleRcvdSegment - removes iff the whole segment is covered by an
  incoming ACK

Given that the panic occurs when the write queue is empty and SND.NXT !=
SND.UNA, the bug likely occurs when either the writeList removes a segment or
SND.NXT increments.

PiperOrigin-RevId: 699283514
This commit is contained in:
Kevin Krakauer
2024-11-22 14:13:29 -08:00
committed by gVisor bot
parent 9e0e42b665
commit ca345ca5af
+2 -5
View File
@@ -1013,16 +1013,13 @@ func (e *Endpoint) purgeWriteQueue() {
e.sndQueueInfo.sndQueueMu.Lock()
defer e.sndQueueInfo.sndQueueMu.Unlock()
e.snd.updateWriteNext(nil)
for {
s := e.snd.writeList.Front()
if s == nil {
break
}
for s := e.snd.writeList.Front(); s != nil; s = e.snd.writeList.Front() {
e.snd.writeList.Remove(s)
s.DecRef()
}
e.sndQueueInfo.SndBufUsed = 0
e.sndQueueInfo.SndClosed = true
e.snd.SndNxt = e.snd.SndUna
}
}