From nobody Sun Sep 24 21:47:02 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 4Rv02t6MVCz4tWwP; Sun, 24 Sep 2023 21:47:02 +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 4Rv02t5HhRz4ZrS; Sun, 24 Sep 2023 21:47:02 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1695592022; 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=T5Rf20rUmcEM3uisYW/6Ab7e1fUxgRYxgNhh5s858OU=; b=em5S4kxHUWWWo73pig9nH3c6VwmMRHhCp9ESduWdx0ckgtXxFhMpJU1+GBwdjC1JIkSf52 kqpqVzavNzZCgYz6ndl3yR00iVRb6Rp0sp7oDDhAVM44Ui2HnbAZPYJmX2QSZ4U4bDeStT dgfaM7UHUvgHMlRZupxX1RIhJnavBTE9Q3NtzwXOobZpqDzS61/ZSIkrkmQWDfQCwa99YQ Y1ylYcMGlnC24l0a1U83WLnER2Pm8XSwFh2IeVdzJ0lhUgd06mztfvCWhpDdsM/Rw76GeX il3D2j+f7T7SK2CxJ1X/I5Sh0+DWc9mfhOxKFJU3gE0Ot9w9SxledmSrm+FMmw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1695592022; a=rsa-sha256; cv=none; b=Yd3ZUW/sOGSl/y2aOqrCQw59B2M5MWmMSjan5scuGMKL3m1gqpdCWEf5XpCvGmRfA7ZTQk fGdx9Q55s2rBrVutGtpOr10sV37yGJH693J5hTHONArIbHJfKCQQkt1XD/TzM3gEnUvaFv Isk+4ikw6fRt4/uVFtTVIVc21D3olPkOfq0fOGZyoxnSjsTE+RaN6+zDD5Y4/jB4fhF/p9 U/0f3+hWVIffJTRx/a5+88OjhMLdL4KgxAhxR8JXP89tAqp6TW56SZG3DkzGgOH17K7bTy 9re7B8nqcgHzC5FRqbwxvjE9tSGqoMl6WgBj0LQmiAZi3tqMljLEfOnKRh0LJw== 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=1695592022; 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=T5Rf20rUmcEM3uisYW/6Ab7e1fUxgRYxgNhh5s858OU=; b=SNNoLzV67W3JXh19GqmoAQzo507JL1Ec2hbUTVE/VY6YO0bwLgJLcaU/sZzR4+y7JRNQSw fFoc6o+KStERzVcN+WyZRSMjyT1B6w8EZvDztU+Q2U1x8GN9sNyFbaBHz+2BC0OMe9j+Rr 4g3fy35UJhCykPg2G9sUI6PWLcpUMwb53H4ks5MEbGbg+O0v8UHcDZA93mSrE3eEOd10rO JhZZbG452WA0IbjcfYuOUje+pOPV2TAypDfMWoXIXJDjZkVkNgVfaunDpCYPSl8s4AsjQM NIL60PRAi4NRFUYguoqyK+kwQSZ9Xxk+RPMVqmZ2Js/BLS4DqLq1j4GPHRoo2g== 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 4Rv02t4MdPz13j3; Sun, 24 Sep 2023 21:47:02 +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 38OLl2E7031003; Sun, 24 Sep 2023 21:47:02 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 38OLl2iv031000; Sun, 24 Sep 2023 21:47:02 GMT (envelope-from git) Date: Sun, 24 Sep 2023 21:47:02 GMT Message-Id: <202309242147.38OLl2iv031000@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: aaeaba324335 - releng/14.0 - 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/releng/14.0 X-Git-Reftype: branch X-Git-Commit: aaeaba3243354f02a7a7c4ff519efd88edc22572 Auto-Submitted: auto-generated The branch releng/14.0 has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=aaeaba3243354f02a7a7c4ff519efd88edc22572 commit aaeaba3243354f02a7a7c4ff519efd88edc22572 Author: Olivier Certner AuthorDate: 2023-09-22 20:57:20 +0000 Commit: Mateusz Guzik CommitDate: 2023-09-24 21:46:25 +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 Approved by: re (gjb) (cherry picked from commit 02cbc029dac936b4ddbc38cef969c4b30c9a7d1f) (cherry picked from commit c76dfb929e70c80a2d0280a1371c07738d910c11) --- 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; }