summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormpi <mpi@openbsd.org>2017-07-04 12:51:18 +0000
committermpi <mpi@openbsd.org>2017-07-04 12:51:18 +0000
commit24fc5127499d135791cc40b148096d463d664acf (patch)
treea568c582e972431ba3c1ea0fb95f338fd3686e86
parentconsistently use the evtimer wrappers around the connection timeout. (diff)
downloadwireguard-openbsd-24fc5127499d135791cc40b148096d463d664acf.tar.xz
wireguard-openbsd-24fc5127499d135791cc40b148096d463d664acf.zip
Assert that the socket lock is held when `so_qlen' is modified.
ok bluhm@, visa@
-rw-r--r--sys/kern/uipc_socket2.c8
-rw-r--r--sys/sys/socketvar.h16
2 files changed, 15 insertions, 9 deletions
diff --git a/sys/kern/uipc_socket2.c b/sys/kern/uipc_socket2.c
index 9619cbd3dc4..d8fc578817d 100644
--- a/sys/kern/uipc_socket2.c
+++ b/sys/kern/uipc_socket2.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uipc_socket2.c,v 1.80 2017/06/27 12:02:43 mpi Exp $ */
+/* $OpenBSD: uipc_socket2.c,v 1.81 2017/07/04 12:51:18 mpi Exp $ */
/* $NetBSD: uipc_socket2.c,v 1.11 1996/02/04 02:17:55 christos Exp $ */
/*
@@ -208,6 +208,7 @@ sonewconn(struct socket *head, int connstatus)
void
soqinsque(struct socket *head, struct socket *so, int q)
{
+ soassertlocked(head);
#ifdef DIAGNOSTIC
if (so->so_onq != NULL)
@@ -228,9 +229,10 @@ soqinsque(struct socket *head, struct socket *so, int q)
int
soqremque(struct socket *so, int q)
{
- struct socket *head;
+ struct socket *head = so->so_head;
+
+ soassertlocked(head);
- head = so->so_head;
if (q == 0) {
if (so->so_onq != &head->so_q0)
return (0);
diff --git a/sys/sys/socketvar.h b/sys/sys/socketvar.h
index 857e23621f1..514156e9a9e 100644
--- a/sys/sys/socketvar.h
+++ b/sys/sys/socketvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: socketvar.h,v 1.70 2017/06/26 09:32:32 mpi Exp $ */
+/* $OpenBSD: socketvar.h,v 1.71 2017/07/04 12:51:18 mpi Exp $ */
/* $NetBSD: socketvar.h,v 1.18 1996/02/09 18:25:38 christos Exp $ */
/*-
@@ -199,11 +199,15 @@ sbspace(struct socket *so, struct sockbuf *sb)
((so)->so_state & SS_ISSENDING)
/* can we read something from so? */
-#define soreadable(so) \
- (!isspliced(so) && \
- ((so)->so_rcv.sb_cc >= (so)->so_rcv.sb_lowat || \
- ((so)->so_state & SS_CANTRCVMORE) || \
- (so)->so_qlen || (so)->so_error))
+static inline int
+soreadable(struct socket *so)
+{
+ soassertlocked(so);
+ if (isspliced(so))
+ return 0;
+ return (so->so_state & SS_CANTRCVMORE) || so->so_qlen || so->so_error ||
+ so->so_rcv.sb_cc >= so->so_rcv.sb_lowat;
+}
/* can we write something to so? */
#define sowriteable(so) \