From nobody Thu May 11 13:32:57 2023 X-Original-To: dev-commits-src-branches@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 4QHCWY588Fz4BFTw; Thu, 11 May 2023 13:32:57 +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 4QHCWY4gYdz4GTm; Thu, 11 May 2023 13:32:57 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1683811977; 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=oDRRomhDTYPHd4V5yr/wY+8KMhkGjNFXsZTHZaAVxgM=; b=NNtGdr0x1KgFyVCNrSrojuZTS65p0yCTyc63wj3ZlpacceINEA0jgru2vPBrtvbfbqUo3X INuRrIBEkw4jlC6Er3MxBypaLCR2J5YOV5MoLZAC6lOd9x7HmS6Wsln8Q2TIHN6OX3CTeQ dc+mMXhmCJDKHDUSztWmk3nVdPFRcD9z75xw2Gx7pEQE9hK9wylIvEkTDdbd+cZpI8Al90 9rPa9thq1+4mzFJEzj9evZ6WHNOojxLhWZ7rmp0bHmTEls6m3Adwq+5CGcUX6NGFa6IR4M Mq05NbtJcCi9K0E90hhaFk2Rhc4LFHDRYa3t11NXHLrKgEt4T7BrYPg2AIERxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1683811977; 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=oDRRomhDTYPHd4V5yr/wY+8KMhkGjNFXsZTHZaAVxgM=; b=Gs5U+dnlEeSzwqqbqFwlByxvM25n7qhLer03rwgenbH+OiSBWydkYmDl4HZVPNbLzX8KPN /QxFMRY1ic5uG9K9m00/IjRvokFJ1eVBvPpZaqjLbQMRO5kPpZ3iq+n3Hw6OsKJbTFfrRF hSeDqsOX30aNSMmZ6pJsQs7w3mxjL6gj+gnKBRpR8htAwiFXWHYx6vRpPnZG57Ub86xOUD FBHAYQPZ33uY96BE3XYTQDS+cac+a2O7ioOCLlKtCjzLe31twr4HvKF6Tqtpojmw6O0YJH TzCEZULr0VTFrPFTLHeqZLJXHTUa28eTttEUtwlxz47Tvqk6zJBK4FedhcEINA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1683811977; a=rsa-sha256; cv=none; b=wcxXKbYPZ4ShfF9GanB4DR9uIB+eRt3V/JK8QMFtkehWhSkhKvP4yeYGWX7ldLg2kioo4i AqCJs1YN6q16jboIZ4w3jypAOkWR1bX1BJAWAyinlJ1C4fqm7wyg8LNf8Pn0da5NuZC6UQ xtBjky2uAbgijTHZUZ2n4pb5sbwXTNr1wLYYmufeCJS3eg2YF36rISFpwAhN5tMASe18ZA raTn2HZ5ozzPpHVg21lIJnxGpqE53ybvS4HBR19WfPleocH/ZMjJPj2gQ8KvvCc5YpKivE ykIk23+xD/8l66fNMB9SX4A86Neycjct/FAGjByzfmL6tQSLjyxkkHdAIllFUg== 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 4QHCWY3dfkzv4h; Thu, 11 May 2023 13:32:57 +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 34BDWvw2076733; Thu, 11 May 2023 13:32:57 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 34BDWv7U076732; Thu, 11 May 2023 13:32:57 GMT (envelope-from git) Date: Thu, 11 May 2023 13:32:57 GMT Message-Id: <202305111332.34BDWv7U076732@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: dba2eb1dc02d - stable/13 - unix: Fix locking in uipc_peeraddr() List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@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/stable/13 X-Git-Reftype: branch X-Git-Commit: dba2eb1dc02d6ef876aa38b7b9612703dde5d635 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=dba2eb1dc02d6ef876aa38b7b9612703dde5d635 commit dba2eb1dc02d6ef876aa38b7b9612703dde5d635 Author: Mark Johnston AuthorDate: 2023-05-10 13:18:16 +0000 Commit: Mark Johnston CommitDate: 2023-05-11 13:32:32 +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 (cherry picked from commit e8f6e5b2d969fdf7e8f0a9a0a87eede357618fe9) --- 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 9c46e8588ed4..4d602341f514 100644 --- a/sys/kern/uipc_usrreq.c +++ b/sys/kern/uipc_usrreq.c @@ -921,15 +921,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 @@ -940,7 +935,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); }