From 2acc818149553e810e21e8fd9fed641297ca52a8 Mon Sep 17 00:00:00 2001 From: Martin Pieuchot Date: Thu, 27 Jul 2017 12:04:43 +0000 Subject: Grab the KERNEL_LOCK() before calling sorwakeup(). In the forwarding path, pf_test() is executed w/o KERNEL_LOCK() and in case of divert end up calling sowakup(). However selwakup() and csignal() are not yet ready to be executed w/o KERNEL_LOCK(). ok bluhm@ --- sys/netinet/ip_divert.c | 7 +++++-- sys/netinet6/ip6_divert.c | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/sys/netinet/ip_divert.c b/sys/netinet/ip_divert.c index cc93134864a..82b55806b7b 100644 --- a/sys/netinet/ip_divert.c +++ b/sys/netinet/ip_divert.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_divert.c,v 1.48 2017/06/26 09:32:32 mpi Exp $ */ +/* $OpenBSD: ip_divert.c,v 1.49 2017/07/27 12:04:42 mpi Exp $ */ /* * Copyright (c) 2009 Michele Marchetto @@ -226,8 +226,11 @@ divert_packet(struct mbuf *m, int dir, u_int16_t divert_port) divstat_inc(divs_fullsock); m_freem(m); return (0); - } else + } else { + KERNEL_LOCK(); sorwakeup(inp->inp_socket); + KERNEL_UNLOCK(); + } } if (sa == NULL) { diff --git a/sys/netinet6/ip6_divert.c b/sys/netinet6/ip6_divert.c index 574201fac18..1afdf9a5096 100644 --- a/sys/netinet6/ip6_divert.c +++ b/sys/netinet6/ip6_divert.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip6_divert.c,v 1.48 2017/06/26 09:32:32 mpi Exp $ */ +/* $OpenBSD: ip6_divert.c,v 1.49 2017/07/27 12:04:42 mpi Exp $ */ /* * Copyright (c) 2009 Michele Marchetto @@ -227,8 +227,11 @@ divert6_packet(struct mbuf *m, int dir, u_int16_t divert_port) div6stat_inc(div6s_fullsock); m_freem(m); return (0); - } else + } else { + KERNEL_LOCK(); sorwakeup(inp->inp_socket); + KERNEL_UNLOCK(); + } } if (sa == NULL) { -- cgit v1.2.3