From nobody Sat Jun 6 03:29:10 2026 X-Original-To: dev-commits-src-main@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 4gXP131Cf4z6h49q for ; Sat, 06 Jun 2026 03:29:11 +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 "R13" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4gXP125XwTz45GW for ; Sat, 06 Jun 2026 03:29:10 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1780716550; 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=rXQBKeZGyy9SE3XhGd/m0k5gdSIsoEqU231JPCbIGXk=; b=SjYYTv2XEst69bqnl46qRx5oOym2KDwSasNWlA2+d19ys7Ly6pg4NXKg5M6M65xe4X75Qd ogd+km3Zqq81iewrITyVOHriYsBCtiAReRnvd/YUwnut4103xaMXZ5e2J+fy9WyZHnT5pf RKhlzxM4efpAMCJzoaEobuxT8mBD14QcXb9m11s1h0Lecsbj61QvQDGRsgVKyC4u9r+5Yf +taekcNfY/aO8OLv4y2tKzOOGip2IldNcs0yYHBQEjSWefKRf8ooyF0xBkT+IJnUe4Ru/l y7cHxau4bLb16tsqj2d2h6sEPhPK7oywro2n32ze+wCS0Ov0FyhYUm2Jg+iD+A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1780716550; a=rsa-sha256; cv=none; b=oe9z5PMtSdhzizItYRkavrtiFX8pTgG1GrBd5nvypHJJzKpG11oUwARySDslbZaA5rlvfs ShHC5wpWaor4bYriLzJypnxuFArqxumL3O4T5EZZvmUtqIr/pR29vhNmMLa5k3PWRo8hFj Ef/X6NbFs0pDd2kp4ub60zPIrMKRhocO94lwbSg/td1/OL5pCKxedOgTuy6dC8aF6Y38kW VF+g4HIa9A//TjW9cv8uP7V2VixLrkcEzmVOd+zospsduU2DTsx8HhVl0c9lp0zHR2qsfZ qMFhyVDdscVlXoAcBbT8uKnm+ljwQJLcRCTVOSqT1oHoxjaqrLutADWOJsbi3w== 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=1780716550; 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=rXQBKeZGyy9SE3XhGd/m0k5gdSIsoEqU231JPCbIGXk=; b=acWWoXpj6214AP2BfkN3G3cDnn4/not2UNiJU/SbKTC3fBt7zhBZa9igaT3Iw6BTfLcKc/ H9XEtWmSUm1Zh396SY6mbIrlZO6ysi4cUvyPP9rUbXFlNFiJK1cGO+zqnfiqSNFEjnTRf3 hnnq/bd90zYVbRvllr6m+pDoDpd2sGbu1uiBv1zpJrmr5T9wG3UkutGhHOb6GQqoJvhHUW cAR3xiVeIzrnXQ11K2gO50h6fOakPc/xihBY4eAPxKz6LuJ3tUQKLPQFJlmcHGtEf858zw DtemlRJEMVqbtse+LzHt3iscLwuaEQVrt6cgmoFLNYxnfUYoQth8PYz4Xp+v6w== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4gXP124VrbzyFT for ; Sat, 06 Jun 2026 03:29:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 45dbb by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sat, 06 Jun 2026 03:29:10 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: d53633bfcf24 - main - rename(2): do not allow to rename root vnode of the mounted filesystem List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: d53633bfcf24a3eb3711e24b597aa8301f92b958 Auto-Submitted: auto-generated Date: Sat, 06 Jun 2026 03:29:10 +0000 Message-Id: <6a239406.45dbb.7f54f054@gitrepo.freebsd.org> The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=d53633bfcf24a3eb3711e24b597aa8301f92b958 commit d53633bfcf24a3eb3711e24b597aa8301f92b958 Author: Konstantin Belousov AuthorDate: 2026-06-04 19:56:36 +0000 Commit: Konstantin Belousov CommitDate: 2026-06-06 03:28:28 +0000 rename(2): do not allow to rename root vnode of the mounted filesystem Check for tdvp being vp_crossmp. This cannot happen for the normal rename cases, but could if the target path specified by the syscall points to the nullfs mount over the regular file. In this case namei() cannot step over crossmp, and keep it in ni_dvp. Since crossmp VOP_GETWRITEMOUNT() returns NULL mp, we retry the locking dance since the belief is that NULL return is transient. PR: 295826 Reviewed by: markj Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D57453 --- sys/kern/vfs_lookup.c | 2 +- sys/kern/vfs_syscalls.c | 9 +++++++++ sys/sys/vnode.h | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/sys/kern/vfs_lookup.c b/sys/kern/vfs_lookup.c index c1363c0104d3..5d66070ca142 100644 --- a/sys/kern/vfs_lookup.c +++ b/sys/kern/vfs_lookup.c @@ -113,7 +113,7 @@ SDT_PROBE_DEFINE4(vfs, namei, lookup, return, "int", "struct vnode *", "bool", uma_zone_t namei_zone; /* Placeholder vnode for mp traversal. */ -static struct vnode *vp_crossmp; +struct vnode *vp_crossmp; static int crossmp_vop_islocked(struct vop_islocked_args *ap) diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index 71d37e08c65b..7ca7ccd582e1 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -3823,6 +3823,15 @@ again: } tdvp = tond.ni_dvp; tvp = tond.ni_vp; + if (tdvp == vp_crossmp) { + /* + * Rename of the root vnode of the mounted + * filesystem. It is possible to get there with the + * nullfs mount over the regular file. + */ + error = EBUSY; + goto out; + } if (tvp != NULL && (flags & AT_RENAME_NOREPLACE) != 0) { /* * Often filesystems need to relock the vnodes in diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h index 41b5e21fb879..99e90aa4187e 100644 --- a/sys/sys/vnode.h +++ b/sys/sys/vnode.h @@ -462,6 +462,7 @@ extern struct mount *rootdevmp; /* "/dev" mount */ extern u_long desiredvnodes; /* number of vnodes desired */ extern struct uma_zone *namei_zone; extern struct vattr va_null; /* predefined null vattr structure */ +extern struct vnode *vp_crossmp; extern u_int vn_lock_pair_pause_max;