From dc317311dcb790bd86fb79d29e065b64af15f057 Mon Sep 17 00:00:00 2001 From: bluhm Date: Tue, 30 Aug 2022 09:35:24 +0000 Subject: [PATCH] Protect the receive socket buffer in UDP input with per PCB mutex. OK claudio@ mvs@ --- sys/netinet/udp_usrreq.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c index 2edbff0781e..ea39aaa96f6 100644 --- a/sys/netinet/udp_usrreq.c +++ b/sys/netinet/udp_usrreq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: udp_usrreq.c,v 1.294 2022/08/29 08:08:17 mvs Exp $ */ +/* $OpenBSD: udp_usrreq.c,v 1.295 2022/08/30 09:35:24 bluhm Exp $ */ /* $NetBSD: udp_usrreq.c,v 1.28 1996/03/16 23:54:03 christos Exp $ */ /* @@ -657,12 +657,17 @@ udp_sbappend(struct inpcb *inp, struct mbuf *m, struct ip *ip, } #endif m_adj(m, hlen); + + mtx_enter(&inp->inp_mtx); if (sbappendaddr(so, &so->so_rcv, srcaddr, m, opts) == 0) { + mtx_leave(&inp->inp_mtx); udpstat_inc(udps_fullsock); m_freem(m); m_freem(opts); return; } + mtx_leave(&inp->inp_mtx); + sorwakeup(so); } -- 2.20.1