From nobody Thu May 12 20:22:52 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id C61F31AC484E; Thu, 12 May 2022 20:22:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4KzjrX4ZnRz4dMr; Thu, 12 May 2022 20:22:52 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1652386972; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=HnQnxfC4qkfkbolmO2zDD9HE+UvSy944xeY3c27dC+Q=; b=V2cSVRl9MA3iqYheP2L1f5937rDjgZp7eqe7n33YZTAXN7FhWvzyWl0rguYs2IXM+mka1v eGkOAfNC4nYJB0pKGTgEREyerW+Amx3fqovz5rW1HBZny3dRxp7w5EWYc5KX9jZTvIKw3y PkgHsH95cCi89SAgv7wo7a5i6BFENXku6q1l3LBFrFLw/zrvfXgAfFt+Y4+v5GkXqeZ0j8 sowBOd2KXV0eWrqdybuk+OYjwmXMCn4jvAQJ0Ytxz5Hohyfytg8rop9SnrOoMLvYnvo3k+ i0/fyPsXcronx+dWRYIcs5LDl0RGSoq+k70cy7sQcQrYt6ts0wBCs+wJxfEK8Q== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6725D1543E; Thu, 12 May 2022 20:22:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 24CKMqEq016350; Thu, 12 May 2022 20:22:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 24CKMq2I016349; Thu, 12 May 2022 20:22:52 GMT (envelope-from git) Date: Thu, 12 May 2022 20:22:52 GMT Message-Id: <202205122022.24CKMq2I016349@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gleb Smirnoff Subject: git: 08f17d143289 - main - unix: make unp_connect2() void List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: glebius X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 08f17d1432893f9434ce2e32aa62cc691e3f37cf Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1652386972; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=HnQnxfC4qkfkbolmO2zDD9HE+UvSy944xeY3c27dC+Q=; b=mCOyBNKxCfzewxeN4Rx1FRZQHU0NbPb98dHIws+2wpFi7lF3ZbC648uzUmc7YNsreCVC1J V+S0v9nYHZ1uwWnzp2WETCui4BlGLby/6HgSE+F6UbB7Y5POeMt6BwTO71DeWFZXCta2qq 4CvlglV3THk3dh4i8vzU8eNJGnMPHnvCnymV5S2jfkffNIt82QhhpaUQvaPphD6cr7Tk9k ZDa+LcBZ088r1Secu00UZ+eVmlAwkAlnei7vuA1AySvTqFV+TruFjqNY96rNoPu2x2qHhn e2zQ1FlofZUDIGoHBpYidswMfVrpoby/3+uc5D1wHr0uCtQGJyizqNrPmZiuAw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1652386972; a=rsa-sha256; cv=none; b=R8Gy1OrFOSumhgDwnR0sQ6JWtpoid3e/CcuSOJXRcLwLregWRQ8hqWbxbNSsyeNzasqZIv TNsitgJPZjIDpKCH2ip1nQblmtoKVgKDglxtkcnPeGy3APdXOe4mS82SxUfJ+yD8o0IUhb zlukZbSAUHocLvoiPvUWue/ricZwWPTsp/hzb++UyhA8KGFZiUxmvUz2nE9X9ZpotSHBCJ WTcSbgoJIhP+Ty9rnIyEITDI8k+J3be3Hcxv+e3tRDmtbXJqUghcP/ae6W9q01ya8w9Alz /RXWGKB7FbLDC2/7aK6XVrl8ABFWtvsmpN8CnwUR2/ZXrK3gW8Drw9zrrSTN/w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=08f17d1432893f9434ce2e32aa62cc691e3f37cf commit 08f17d1432893f9434ce2e32aa62cc691e3f37cf Author: Gleb Smirnoff AuthorDate: 2022-05-12 20:22:39 +0000 Commit: Gleb Smirnoff CommitDate: 2022-05-12 20:22:39 +0000 unix: make unp_connect2() void Assert that sockets are of the same type. unp_connectat() already did this check. Add the check to uipc_connect2(). Reviewed by: markj Differential revision: https://reviews.freebsd.org/D35181 --- sys/kern/uipc_usrreq.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/sys/kern/uipc_usrreq.c b/sys/kern/uipc_usrreq.c index b326dbd825a6..13fa7acfcdf3 100644 --- a/sys/kern/uipc_usrreq.c +++ b/sys/kern/uipc_usrreq.c @@ -293,7 +293,7 @@ static int unp_connect(struct socket *, struct sockaddr *, struct thread *); static int unp_connectat(int, struct socket *, struct sockaddr *, struct thread *); -static int unp_connect2(struct socket *so, struct socket *so2, int); +static void unp_connect2(struct socket *so, struct socket *so2, int); static void unp_disconnect(struct unpcb *unp, struct unpcb *unp2); static void unp_dispose(struct socket *so); static void unp_dispose_mbuf(struct mbuf *); @@ -764,16 +764,19 @@ static int uipc_connect2(struct socket *so1, struct socket *so2) { struct unpcb *unp, *unp2; - int error; + + if (so1->so_type != so2->so_type) + return (EPROTOTYPE); unp = so1->so_pcb; KASSERT(unp != NULL, ("uipc_connect2: unp == NULL")); unp2 = so2->so_pcb; KASSERT(unp2 != NULL, ("uipc_connect2: unp2 == NULL")); unp_pcb_lock_pair(unp, unp2); - error = unp_connect2(so1, so2, PRU_CONNECT2); + unp_connect2(so1, so2, PRU_CONNECT2); unp_pcb_unlock_pair(unp, unp2); - return (error); + + return (0); } static void @@ -1630,7 +1633,7 @@ unp_connectat(int fd, struct socket *so, struct sockaddr *nam, KASSERT(unp2 != NULL && so2 != NULL && unp2->unp_socket == so2 && sotounpcb(so2) == unp2, ("%s: unp2 %p so2 %p", __func__, unp2, so2)); - error = unp_connect2(so, so2, PRU_CONNECT); + unp_connect2(so, so2, PRU_CONNECT); unp_pcb_unlock_pair(unp, unp2); bad2: mtx_unlock(vplock); @@ -1667,12 +1670,13 @@ unp_copy_peercred(struct thread *td, struct unpcb *client_unp, client_unp->unp_flags |= (listen_unp->unp_flags & UNP_WANTCRED_MASK); } -static int +static void unp_connect2(struct socket *so, struct socket *so2, int req) { struct unpcb *unp; struct unpcb *unp2; + MPASS(so2->so_type == so->so_type); unp = sotounpcb(so); KASSERT(unp != NULL, ("unp_connect2: unp == NULL")); unp2 = sotounpcb(so2); @@ -1683,8 +1687,6 @@ unp_connect2(struct socket *so, struct socket *so2, int req) KASSERT(unp->unp_conn == NULL, ("%s: socket %p is already connected", __func__, unp)); - if (so2->so_type != so->so_type) - return (EPROTOTYPE); unp->unp_conn = unp2; unp_pcb_hold(unp2); unp_pcb_hold(unp); @@ -1712,7 +1714,6 @@ unp_connect2(struct socket *so, struct socket *so2, int req) default: panic("unp_connect2"); } - return (0); } static void