summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormvs <mvs@cvs.openbsd.org>2020-06-18 14:05:22 +0000
committermvs <mvs@cvs.openbsd.org>2020-06-18 14:05:22 +0000
commitdf3a889ab1c8d37a858314ca44a76d78a11249cb (patch)
tree37cd47ea94364b7bea17d0cdc9b5af21dd67f67d
parentec8d2bafb722687c7a655be4f31f1ed7ca38b526 (diff)
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;