summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2017-11-23 13:42:54 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2017-11-23 13:42:54 +0000
commit7e36b61cd38a09ad7df4709cfc0a24d47bca6ced (patch)
treea837ceb395d5be4b48a024d7ab067a017f8fc8e8
parent67465fd603d528f730e49f0421b671deabc7972e (diff)
We want `sb_flags' to be protected by the socket lock rather than the
KERNEL_LOCK(), so change asserts accordingly. This is now possible since sblock()/sbunlock() are always called with the socket lock held. ok bluhm@, visa@
-rw-r--r--sys/kern/uipc_socket.c24
-rw-r--r--sys/kern/uipc_socket2.c7
-rw-r--r--sys/sys/socketvar.h4
3 files changed, 17 insertions, 18 deletions
diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c
index 92efb46fd6e..7111b358287 100644
--- a/sys/kern/uipc_socket.c
+++ b/sys/kern/uipc_socket.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uipc_socket.c,v 1.207 2017/11/04 14:13:53 mpi Exp $ */
+/* $OpenBSD: uipc_socket.c,v 1.208 2017/11/23 13:42:53 mpi Exp $ */
/* $NetBSD: uipc_socket.c,v 1.21 1996/02/04 02:17:52 christos Exp $ */
/*
@@ -453,7 +453,7 @@ restart:
(atomic || space < so->so_snd.sb_lowat))) {
if ((so->so_state & SS_NBIO) || (flags & MSG_DONTWAIT))
snderr(EWOULDBLOCK);
- sbunlock(&so->so_snd);
+ sbunlock(so, &so->so_snd);
error = sbwait(so, &so->so_snd);
so->so_state &= ~SS_ISSENDING;
if (error)
@@ -497,7 +497,7 @@ restart:
release:
so->so_state &= ~SS_ISSENDING;
- sbunlock(&so->so_snd);
+ sbunlock(so, &so->so_snd);
out:
sounlock(s);
m_freem(top);
@@ -736,7 +736,7 @@ restart:
}
SBLASTRECORDCHK(&so->so_rcv, "soreceive sbwait 1");
SBLASTMBUFCHK(&so->so_rcv, "soreceive sbwait 1");
- sbunlock(&so->so_rcv);
+ sbunlock(so, &so->so_rcv);
error = sbwait(so, &so->so_rcv);
sounlock(s);
if (error)
@@ -957,7 +957,7 @@ dontblock:
SBLASTMBUFCHK(&so->so_rcv, "soreceive sbwait 2");
error = sbwait(so, &so->so_rcv);
if (error) {
- sbunlock(&so->so_rcv);
+ sbunlock(so, &so->so_rcv);
sounlock(s);
return (0);
}
@@ -993,7 +993,7 @@ dontblock:
}
if (orig_resid == uio->uio_resid && orig_resid &&
(flags & MSG_EOR) == 0 && (so->so_state & SS_CANTRCVMORE) == 0) {
- sbunlock(&so->so_rcv);
+ sbunlock(so, &so->so_rcv);
sounlock(s);
goto restart;
}
@@ -1004,7 +1004,7 @@ dontblock:
if (flagsp)
*flagsp |= flags;
release:
- sbunlock(&so->so_rcv);
+ sbunlock(so, &so->so_rcv);
sounlock(s);
return (error);
}
@@ -1049,7 +1049,7 @@ sorflush(struct socket *so)
/* with SB_NOINTR and M_WAITOK sblock() must not fail */
KASSERT(error == 0);
socantrcvmore(so);
- sbunlock(sb);
+ sbunlock(so, sb);
aso.so_proto = pr;
aso.so_rcv = *sb;
memset(sb, 0, sizeof (*sb));
@@ -1110,7 +1110,7 @@ sosplice(struct socket *so, int fd, off_t max, struct timeval *tv)
}
if (so->so_sp->ssp_socket)
sounsplice(so, so->so_sp->ssp_socket, 1);
- sbunlock(&so->so_rcv);
+ sbunlock(so, &so->so_rcv);
return (0);
}
@@ -1139,7 +1139,7 @@ sosplice(struct socket *so, int fd, off_t max, struct timeval *tv)
return (error);
}
if ((error = sblock(so, &sosp->so_snd, M_WAITOK)) != 0) {
- sbunlock(&so->so_rcv);
+ sbunlock(so, &so->so_rcv);
FRELE(fp, curproc);
return (error);
}
@@ -1183,8 +1183,8 @@ sosplice(struct socket *so, int fd, off_t max, struct timeval *tv)
}
release:
- sbunlock(&sosp->so_snd);
- sbunlock(&so->so_rcv);
+ sbunlock(sosp, &sosp->so_snd);
+ sbunlock(so, &so->so_rcv);
FRELE(fp, curproc);
return (error);
}
diff --git a/sys/kern/uipc_socket2.c b/sys/kern/uipc_socket2.c
index 5fd36ea8156..8c903859175 100644
--- a/sys/kern/uipc_socket2.c
+++ b/sys/kern/uipc_socket2.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uipc_socket2.c,v 1.86 2017/08/11 21:24:19 mpi Exp $ */
+/* $OpenBSD: uipc_socket2.c,v 1.87 2017/11/23 13:42:53 mpi Exp $ */
/* $NetBSD: uipc_socket2.c,v 1.11 1996/02/04 02:17:55 christos Exp $ */
/*
@@ -342,7 +342,6 @@ sblock(struct socket *so, struct sockbuf *sb, int wait)
{
int error, prio = (sb->sb_flags & SB_NOINTR) ? PSOCK : PSOCK | PCATCH;
- KERNEL_ASSERT_LOCKED();
soassertlocked(so);
if ((sb->sb_flags & SB_LOCK) == 0) {
@@ -363,9 +362,9 @@ sblock(struct socket *so, struct sockbuf *sb, int wait)
}
void
-sbunlock(struct sockbuf *sb)
+sbunlock(struct socket *so, struct sockbuf *sb)
{
- KERNEL_ASSERT_LOCKED();
+ soassertlocked(so);
sb->sb_flags &= ~SB_LOCK;
if (sb->sb_flags & SB_WANT) {
diff --git a/sys/sys/socketvar.h b/sys/sys/socketvar.h
index f4b54bce2c1..5b33317fb6c 100644
--- a/sys/sys/socketvar.h
+++ b/sys/sys/socketvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: socketvar.h,v 1.77 2017/11/04 14:13:53 mpi Exp $ */
+/* $OpenBSD: socketvar.h,v 1.78 2017/11/23 13:42:53 mpi Exp $ */
/* $NetBSD: socketvar.h,v 1.18 1996/02/09 18:25:38 christos Exp $ */
/*-
@@ -244,7 +244,7 @@ soreadable(struct socket *so)
int sblock(struct socket *, struct sockbuf *, int);
/* release lock on sockbuf sb */
-void sbunlock(struct sockbuf *);
+void sbunlock(struct socket *, struct sockbuf *);
#define SB_EMPTY_FIXUP(sb) do { \
if ((sb)->sb_mb == NULL) { \