From 9d1849029e8e5f510db4fce4865a56873dc61d06 Mon Sep 17 00:00:00 2001 From: Andrei Vagin Date: Mon, 8 Jul 2024 11:23:17 -0700 Subject: [PATCH] tcpip/link/veth: don't send any packets if another end has been closed Reported-by: syzbot+077cb394a25e5bfa4ed9@syzkaller.appspotmail.com PiperOrigin-RevId: 650316007 --- pkg/tcpip/link/veth/veth.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkg/tcpip/link/veth/veth.go b/pkg/tcpip/link/veth/veth.go index 2e382d344..8f96ebd4a 100644 --- a/pkg/tcpip/link/veth/veth.go +++ b/pkg/tcpip/link/veth/veth.go @@ -197,6 +197,13 @@ func (e *Endpoint) SetLinkAddress(addr tcpip.LinkAddress) { // WritePackets stores outbound packets into the channel. // Multiple concurrent calls are permitted. func (e *Endpoint) WritePackets(pkts stack.PacketBufferList) (int, tcpip.Error) { + e.veth.mu.RLock() + defer e.veth.mu.RUnlock() + + if e.veth.closed { + return 0, nil + } + n := 0 for _, pkt := range pkts.AsSlice() { // In order to properly loop back to the inbound side we must create a