From 1d12fe5988988863b84ce489e39aef409382fa47 Mon Sep 17 00:00:00 2001 From: mpi Date: Wed, 7 Jun 2017 13:41:02 +0000 Subject: [PATCH] Assert that the KERNEL_LOCK() is held when messing with routing, pfkey and unix sockets. ok claudio@ --- sys/kern/uipc_socket2.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/sys/kern/uipc_socket2.c b/sys/kern/uipc_socket2.c index 235a20059a9..0ba476bcf51 100644 --- a/sys/kern/uipc_socket2.c +++ b/sys/kern/uipc_socket2.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uipc_socket2.c,v 1.77 2017/05/27 18:50:53 claudio Exp $ */ +/* $OpenBSD: uipc_socket2.c,v 1.78 2017/06/07 13:41:02 mpi Exp $ */ /* $NetBSD: uipc_socket2.c,v 1.11 1996/02/04 02:17:55 christos Exp $ */ /* @@ -292,10 +292,18 @@ sounlock(int s) void soassertlocked(struct socket *so) { - if ((so->so_proto->pr_domain->dom_family != PF_LOCAL) && - (so->so_proto->pr_domain->dom_family != PF_ROUTE) && - (so->so_proto->pr_domain->dom_family != PF_KEY)) + switch (so->so_proto->pr_domain->dom_family) { + case PF_INET: + case PF_INET6: NET_ASSERT_LOCKED(); + break; + case PF_LOCAL: + case PF_ROUTE: + case PF_KEY: + default: + KERNEL_ASSERT_LOCKED(); + break; + } } int -- 2.20.1