From a4fb3b200fdc05ac14aedcfc3d5b1b0c89a8a372 Mon Sep 17 00:00:00 2001 From: Konstantin Bogomolov Date: Wed, 10 Aug 2022 13:23:19 -0700 Subject: [PATCH] Fix panic on nil map in Fragmentation. A rare bug occurs when assigning a value to the reassemblers map causes a panic due to the map being nil. The only way this is possible is if Fragmentation.Release() is called before Process() is able to finish. PiperOrigin-RevId: 466771159 --- pkg/tcpip/network/internal/fragmentation/fragmentation.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/tcpip/network/internal/fragmentation/fragmentation.go b/pkg/tcpip/network/internal/fragmentation/fragmentation.go index ebd4a2f80..fecda178b 100644 --- a/pkg/tcpip/network/internal/fragmentation/fragmentation.go +++ b/pkg/tcpip/network/internal/fragmentation/fragmentation.go @@ -175,6 +175,10 @@ func (f *Fragmentation) Process( } f.mu.Lock() + if f.reassemblers == nil { + return nil, 0, false, fmt.Errorf("Release() called before fragmentation processing could finish") + } + r, ok := f.reassemblers[id] if !ok { r = newReassembler(id, f.clock)