From nobody Sun Sep 24 10:44:20 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 4RtjLD43F0z4tnGw; Sun, 24 Sep 2023 10:44:20 +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 4RtjLD34zXz4Jlk; Sun, 24 Sep 2023 10:44:20 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1695552260; 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=gmhkI+4/AxWoloDxpgNTfB/bJvElpGvfJ0pICrmPRJs=; b=lVuzLv69JNb9cekQEDdiH7nme2uc+cDUFzNNB6uaYgD8HQQXpLi2x/cmuM0RmkKotxb8Kp poqxwQzgsNJ1SH4bWd/ljocbne6u+13zN0c7+wS49OkPRKYtCcZTQACf89fYAkWudOzaaK 7OmG8JgxWnjEX2BWP+MLnSLU8hTSTAC79BgohN8EfY69KDVW3rcoI7CIE4Y5ZiSHfOC61E cyWPCynAVtWim8OfHO99e81fdTQvv5gGM3Ado+X4ebcajuNAl8a46A3CKgsnaoIE5dNhv6 uvJ4U1SBuBNsszu4S6ts+DULXiWJKcNZguUqr7D5QVKZ5946cO2an07L6Kk9jQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1695552260; a=rsa-sha256; cv=none; b=RX5+iBlTJ4XulmL4Hwo1mWOZmcksKyqO7MHtB+KFIp5l0LLpNysx+7FGEDXyCuIp/BDKGy lVLDD1phVvgh8l88tVvC57VE/1fj2var53xqA81nIdxqpVXlqEJKLP/vdpSBi152+gQsRy ISUYR3MggMEgBx/V+OsK7DBKKCKbtjfKU3PatyovlLc4nO2x8eQJa57v8TLiwDK+/GUx3i 1ANAofk4pLBE/f1pxYD8ZiSzvQjZ4urzAGOmw688Ys5t2za3rEx+MO28Jc8lDVASpltWah wOwzj2nB68BAFlvLHaze3u/eMaIOmIkiR6cGRKHzAkIHnttozSW+OlshP0Za7w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1695552260; 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=gmhkI+4/AxWoloDxpgNTfB/bJvElpGvfJ0pICrmPRJs=; b=kDXyNZUakD3A4JTmABS8vV4pCs4gonNR2R4swle/mDil2U1qMRsYpgy9VGd/sT4Pav1Kfq brZHvq8abdCkIhHNfPnNroEBvgbh8yW54Iz9HzRvN3+1nid2+6dO6k7rpTkRr5GkCY2xCd ve7TDzSH+YPdlBqyeF05GMc4DmsatZFP4+wuvylDnQvyTHp9NoT2KzSsp45Pd0ADin/DWK c9i4TtJGqXB5tDcFo7KEgURraVUnmXVdMzJCmrdmpaSOluxiajL5B9ebbI+m3RiCmtK6bg mgfjpGIfb0KS+siCnV51CWz4a13QKHOIdNp40/wmKPYHHSKKzniEy0ynDke4YA== 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 4RtjLD27Dszk3f; Sun, 24 Sep 2023 10:44:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 38OAiKX3029581; Sun, 24 Sep 2023 10:44:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 38OAiKSJ029578; Sun, 24 Sep 2023 10:44:20 GMT (envelope-from git) Date: Sun, 24 Sep 2023 10:44:20 GMT Message-Id: <202309241044.38OAiKSJ029578@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mateusz Guzik Subject: git: c76dfb929e70 - stable/14 - vfs: fix reference counting/locking on LK_UPGRADE error 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: mjg X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: c76dfb929e70c80a2d0280a1371c07738d910c11 Auto-Submitted: auto-generated The branch stable/14 has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=c76dfb929e70c80a2d0280a1371c07738d910c11 commit c76dfb929e70c80a2d0280a1371c07738d910c11 Author: Olivier Certner AuthorDate: 2023-09-22 20:57:20 +0000 Commit: Mateusz Guzik CommitDate: 2023-09-24 10:44:11 +0000 vfs: fix reference counting/locking on LK_UPGRADE error Factoring out this code unfortunately introduced reference and lock leaks in case of failure in the lock upgrade path under VV_CROSSLOCK. In terms of practical use, this impacts unionfs (and nullfs in a corner case). Fixes: 80bd5ef07025 ("vfs: factor out mount point traversal to a dedicated routine") MFC after: 3 days MFC to: stable/14 releng/14.0 Sponsored by: The FreeBSD Foundation Reviewed by: mjg [mjg: massaged the commit message a little bit] Differential Revision: https://reviews.freebsd.org/D41731 (cherry picked from commit 02cbc029dac936b4ddbc38cef969c4b30c9a7d1f) --- sys/kern/vfs_lookup.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/sys/kern/vfs_lookup.c b/sys/kern/vfs_lookup.c index 151253ffa0f5..d75351c34314 100644 --- a/sys/kern/vfs_lookup.c +++ b/sys/kern/vfs_lookup.c @@ -905,8 +905,15 @@ vfs_lookup_cross_mount(struct nameidata *ndp) crosslkflags |= LK_EXCLUSIVE | LK_CANRECURSE; } else if ((crosslkflags & LK_EXCLUSIVE) != 0) { error = vn_lock(dp, LK_UPGRADE); - if (error != 0) + if (error != 0) { + MPASS(error == ENOENT); + vrele(dp); + if (dp != ndp->ni_dvp) + vput(ndp->ni_dvp); + else + vrele(ndp->ni_dvp); break; + } if (dp->v_mountedhere != mp) { continue; }