summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormvs <mvs@openbsd.org>2020-06-18 14:05:21 +0000
committermvs <mvs@openbsd.org>2020-06-18 14:05:21 +0000
commit6a4f7213e40fa1e06c0f29499c22abd45246ff7c (patch)
tree6fc136913347b3301f2d89259e4e6eb6833557a9
parentIntroduce stoeplitz_hash_n32() and use it to simplify the hash_ip* (diff)
downloadwireguard-openbsd-6a4f7213e40fa1e06c0f29499c22abd45246ff7c.tar.xz
wireguard-openbsd-6a4f7213e40fa1e06c0f29499c22abd45246ff7c.zip
Compare `so' and `sosp' types just after `sosp' obtaining. We can't splice
sockets from different domains so there is no reason to have locking and memory allocation in this error path. Also in this case only `so' will be locked by solock() so we should avoid `sosp' modification. ok mpi@
-rw-r--r--sys/kern/uipc_socket.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c
index 68685c0d83f..3d6e12e88bc 100644
--- a/sys/kern/uipc_socket.c
+++ b/sys/kern/uipc_socket.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uipc_socket.c,v 1.245 2020/06/15 15:29:40 mpi Exp $ */
+/* $OpenBSD: uipc_socket.c,v 1.246 2020/06/18 14:05:21 mvs Exp $ */
/* $NetBSD: uipc_socket.c,v 1.21 1996/02/04 02:17:52 christos Exp $ */
/*
@@ -1200,6 +1200,10 @@ sosplice(struct socket *so, int fd, off_t max, struct timeval *tv)
if ((error = getsock(curproc, fd, &fp)) != 0)
return (error);
sosp = fp->f_data;
+ if (sosp->so_proto->pr_usrreq != so->so_proto->pr_usrreq) {
+ error = EPROTONOSUPPORT;
+ goto frele;
+ }
if (sosp->so_sp == NULL) {
sp = pool_get(&sosplice_pool, PR_WAITOK | PR_ZERO);
if (sosp->so_sp == NULL)
@@ -1221,10 +1225,6 @@ sosplice(struct socket *so, int fd, off_t max, struct timeval *tv)
error = EBUSY;
goto release;
}
- if (sosp->so_proto->pr_usrreq != so->so_proto->pr_usrreq) {
- error = EPROTONOSUPPORT;
- goto release;
- }
if (sosp->so_options & SO_ACCEPTCONN) {
error = EOPNOTSUPP;
goto release;