aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGleb Smirnoff <glebius@FreeBSD.org>2025-01-17 02:31:15 +0000
committerGleb Smirnoff <glebius@FreeBSD.org>2025-01-17 02:31:15 +0000
commit4c0e435bfbad52358ad6c6508cf3dca2e7b45227 (patch)
tree99abb7e6ec6e775c3b4f7cf2bb6243a3e54c713e
parenta1be7978f1879313c141882a1e0812b468dead57 (diff)
unix: avoid VNET recursion in unp_connectat()
While that might be a cool feature, but you can't connect two sockets in different VNETs. It is just technically impossible right now. This CURVNET_SET() was always setting the same context.
-rw-r--r--sys/kern/uipc_usrreq.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/sys/kern/uipc_usrreq.c b/sys/kern/uipc_usrreq.c
index 3d7e5bcc5ad0..c1f1c07da268 100644
--- a/sys/kern/uipc_usrreq.c
+++ b/sys/kern/uipc_usrreq.c
@@ -1897,6 +1897,8 @@ unp_connectat(int fd, struct socket *so, struct sockaddr *nam,
int error, len;
bool connreq;
+ CURVNET_ASSERT_SET();
+
if (nam->sa_family != AF_UNIX)
return (EAFNOSUPPORT);
if (nam->sa_len > sizeof(struct sockaddr_un))
@@ -1991,11 +1993,9 @@ unp_connectat(int fd, struct socket *so, struct sockaddr *nam,
goto bad2;
}
if (connreq) {
- if (SOLISTENING(so2)) {
- CURVNET_SET(so2->so_vnet);
+ if (SOLISTENING(so2))
so2 = sonewconn(so2, 0);
- CURVNET_RESTORE();
- } else
+ else
so2 = NULL;
if (so2 == NULL) {
error = ECONNREFUSED;