From nobody Wed May 03 16:00:48 2023 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 4QBM9s1ghFz4900L; Wed, 3 May 2023 16:00:49 +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 4QBM9s15s6z4C8n; Wed, 3 May 2023 16:00:49 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1683129649; 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=jsJEzC8HH53qkY3eyTwCS0lpwY9W0RNgdXlmYZ+4Mio=; b=cGbli2MqIPIKn19p3MaXPdd0uKyk12cm+TCnJ1LANPCNWmCHH2Qzh7iXSb1KPog9SFhH/Z BYRCKA7qkA1okjaeN6AgCXeGvZ7ZRMtPq+Bvdll8ekL7ypbbviWEM37cZ5BGuor3LjBGe7 jQyaRe8E7pFfRXL3ncPURgjLhOOnqFUMyR/xKI5OxGvCW1n6bP10JjaFFztgNS45Wh2EoO WviiTAl0h3KPmCC3OjzX3cYsn2ldSr9XQvbpacIcifhixBXh/7QVbP1Sr6tgXHzHzEnBJ+ MPuowiRxerE3XVN7dzOHqNuSdlTXovqHwC0au64t/aSFfEdR56Bv3dEDE+EDiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1683129649; 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=jsJEzC8HH53qkY3eyTwCS0lpwY9W0RNgdXlmYZ+4Mio=; b=ZJE+iGX4q7Zy+A7T1Vnm60F3bztsqg4b5w5e0E+uiME7X0ayYKf3E8NjWwjsWpRzKsUZj3 oKT7PQPOODhIqGu+Rz+OpmH2ShBrPTksyUNr5B9GtCyJTkxulY8p9xVN2xGy2pu76raAo4 S88xK2RyWoIBhiLPxkwyjYdoIxOSFEvpOX9a6Er403VWomKdezoZAN7/aYvV0OwstA+ofN qKXkTU5mCiYYitjR10HDc+LB1ZNOUN/U730dCQVuIVdr4iA0Hbu1Cz0lxLPRvqxReAW9Nf B3Z5QT6Ltmi/W5V9Bm0dP81CXCUQpL0EnoSwG35UpOHSIYde/SUIRMiveUlKlQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1683129649; a=rsa-sha256; cv=none; b=RIWoCIc3yKTK3pYPrRy7+KUyFu1toZCHMyG5qMI2xTuJE1bCZAqR3bW1ZaGWONvfIDTObm o256RKURHhXXEgH7dZjJsYuC+0rZzdJk87i3bh7Qq5ZkB/b/yIvxRgHcJNphySRlwiYmal +oX9/tG5cuGBnW+ZcfuPFch7HKiQrflUMdJ+nDbrHw8Rq3+iNT+KlMCqhf5JjGv8eX+kbi YcIrzEBUccgSXKZJ7EjfOfOFrSRBxAmU92SRfi8bdkJ+rch2HOYpOtr5iF/40aI40V9SkQ 3cv2DhnY6m4c66la3LEHd1slfU8CXhYL3GGp85PTgtnzKGuRlkRmUZG77sr6nw== 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 4QBM9s09MPzcDT; Wed, 3 May 2023 16:00:49 +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 343G0m5q017166; Wed, 3 May 2023 16:00:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 343G0m91017165; Wed, 3 May 2023 16:00:48 GMT (envelope-from git) Date: Wed, 3 May 2023 16:00:48 GMT Message-Id: <202305031600.343G0m91017165@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: e8f6e5b2d969 - main - unix: Fix locking in uipc_peeraddr() 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: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: e8f6e5b2d969fdf7e8f0a9a0a87eede357618fe9 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=e8f6e5b2d969fdf7e8f0a9a0a87eede357618fe9 commit e8f6e5b2d969fdf7e8f0a9a0a87eede357618fe9 Author: Mark Johnston AuthorDate: 2023-05-03 15:56:46 +0000 Commit: Mark Johnston CommitDate: 2023-05-03 15:56:46 +0000 unix: Fix locking in uipc_peeraddr() After the locking protocol changed in commit 75a67bf3d00d ("AF_UNIX: make unix socket locking finer grained"), uipc_peeraddr() was not updated accordingly. The link lock now only protects global socket lists. The PCB lock is used to protect the link between connected PCBs, so use that. Remove an old comment which appears to be noting that unp_conn is not set for connected SOCK_DGRAM sockets (in one direction anyway). Reviewed by: glebius MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D39855 --- sys/kern/uipc_usrreq.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/sys/kern/uipc_usrreq.c b/sys/kern/uipc_usrreq.c index 294ef807416c..bd7a2cca245f 100644 --- a/sys/kern/uipc_usrreq.c +++ b/sys/kern/uipc_usrreq.c @@ -885,15 +885,10 @@ uipc_peeraddr(struct socket *so, struct sockaddr **nam) KASSERT(unp != NULL, ("uipc_peeraddr: unp == NULL")); *nam = malloc(sizeof(struct sockaddr_un), M_SONAME, M_WAITOK); - UNP_LINK_RLOCK(); - /* - * XXX: It seems that this test always fails even when connection is - * established. So, this else clause is added as workaround to - * return PF_LOCAL sockaddr. - */ - unp2 = unp->unp_conn; + + UNP_PCB_LOCK(unp); + unp2 = unp_pcb_lock_peer(unp); if (unp2 != NULL) { - UNP_PCB_LOCK(unp2); if (unp2->unp_addr != NULL) sa = (struct sockaddr *) unp2->unp_addr; else @@ -904,7 +899,7 @@ uipc_peeraddr(struct socket *so, struct sockaddr **nam) sa = &sun_noname; bcopy(sa, *nam, sa->sa_len); } - UNP_LINK_RUNLOCK(); + UNP_PCB_UNLOCK(unp); return (0); }