From 6a7e4c21021d2a9900794fbaa5adc466262ec241 Mon Sep 17 00:00:00 2001 From: Lucas Manning Date: Wed, 15 May 2024 10:52:17 -0700 Subject: [PATCH] Fix race during fdbased endpoint teardown. If the fdbased processor is handling packets and the endpoint dispatcher concurrently is set to nil we can crash the sandbox. PiperOrigin-RevId: 634007307 --- pkg/tcpip/link/fdbased/processors.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/tcpip/link/fdbased/processors.go b/pkg/tcpip/link/fdbased/processors.go index 03b51fb4a..5e634b1b4 100644 --- a/pkg/tcpip/link/fdbased/processors.go +++ b/pkg/tcpip/link/fdbased/processors.go @@ -62,6 +62,12 @@ func (p *processor) deliverPackets() { p.e.mu.RLock() p.gro.Dispatcher = p.e.dispatcher p.e.mu.RUnlock() + if p.gro.Dispatcher == nil { + p.mu.Lock() + p.pkts.Reset() + p.mu.Unlock() + return + } p.mu.Lock() for p.pkts.Len() > 0 {