git: 503ab844cece - stable/13 - namei: Fix cn_flags width in various places

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Fri, 21 Nov 2025 15:19:28 UTC
The branch stable/13 has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=503ab844ceced16c7e8736c0caa586ff0bab5f0e

commit 503ab844ceced16c7e8736c0caa586ff0bab5f0e
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2025-05-27 13:29:14 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2025-11-19 20:47:50 +0000

    namei: Fix cn_flags width in various places
    
    This truncation is mostly harmless today, but fix it anyway to avoid
    pain later down the road.
    
    Reviewed by:    olce, kib
    MFC after:      2 weeks
    Differential Revision:  https://reviews.freebsd.org/D50417
    
    (cherry picked from commit 0d224af399a66f00a5b33e5512fc018062cabf1d)
---
 sys/fs/cd9660/cd9660_lookup.c |  2 +-
 sys/fs/fuse/fuse_vnops.c      | 11 +++++------
 sys/fs/smbfs/smbfs_vnops.c    |  2 +-
 sys/fs/unionfs/union_vnops.c  |  3 ++-
 sys/kern/uipc_mqueue.c        |  3 ++-
 sys/kern/vfs_cache.c          |  2 +-
 6 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/sys/fs/cd9660/cd9660_lookup.c b/sys/fs/cd9660/cd9660_lookup.c
index 961745f45afc..be594d46cf40 100644
--- a/sys/fs/cd9660/cd9660_lookup.c
+++ b/sys/fs/cd9660/cd9660_lookup.c
@@ -134,7 +134,7 @@ cd9660_lookup(ap)
 	char *name;
 	struct vnode **vpp = ap->a_vpp;
 	struct componentname *cnp = ap->a_cnp;
-	int flags = cnp->cn_flags;
+	uint64_t flags = cnp->cn_flags;
 	int nameiop = cnp->cn_nameiop;
 
 	ep2 = ep = NULL;
diff --git a/sys/fs/fuse/fuse_vnops.c b/sys/fs/fuse/fuse_vnops.c
index 79317e4e4cd2..d5166559fbdc 100644
--- a/sys/fs/fuse/fuse_vnops.c
+++ b/sys/fs/fuse/fuse_vnops.c
@@ -1433,9 +1433,9 @@ fuse_vnop_lookup(struct vop_lookup_args *ap)
 	struct timespec now;
 
 	int nameiop = cnp->cn_nameiop;
-	int flags = cnp->cn_flags;
-	int wantparent = flags & (LOCKPARENT | WANTPARENT);
-	int islastcn = flags & ISLASTCN;
+	bool wantparent = cnp->cn_flags & (LOCKPARENT | WANTPARENT);
+	bool isdotdot = cnp->cn_flags & ISDOTDOT;
+	bool islastcn = cnp->cn_flags & ISLASTCN;
 	struct mount *mp = vnode_mount(dvp);
 	struct fuse_data *data = fuse_get_mpdata(mp);
 	int default_permissions = data->dataflags & FSESS_DEFAULT_PERMISSIONS;
@@ -1468,8 +1468,7 @@ fuse_vnop_lookup(struct vop_lookup_args *ap)
 		return err;
 
 	is_dot = cnp->cn_namelen == 1 && *(cnp->cn_nameptr) == '.';
-	if ((flags & ISDOTDOT) && !(data->dataflags & FSESS_EXPORT_SUPPORT))
-	{
+	if (isdotdot && !(data->dataflags & FSESS_EXPORT_SUPPORT)) {
 		if (!(VTOFUD(dvp)->flag & FN_PARENT_NID)) {
 			/*
 			 * Since the file system doesn't support ".." lookups,
@@ -1590,7 +1589,7 @@ fuse_vnop_lookup(struct vop_lookup_args *ap)
 		}
 	} else {
 		/* Entry was found */
-		if (flags & ISDOTDOT) {
+		if (isdotdot) {
 			struct fuse_lookup_alloc_arg flaa;
 
 			flaa.nid = nid;
diff --git a/sys/fs/smbfs/smbfs_vnops.c b/sys/fs/smbfs/smbfs_vnops.c
index b03d39a65191..3c86b5a6e3f1 100644
--- a/sys/fs/smbfs/smbfs_vnops.c
+++ b/sys/fs/smbfs/smbfs_vnops.c
@@ -1044,7 +1044,7 @@ smbfs_lookup(struct vop_lookup_args *ap)
 	struct smbfattr fattr, *fap;
 	struct smb_cred *scred;
 	char *name = cnp->cn_nameptr;
-	int flags = cnp->cn_flags;
+	uint64_t flags = cnp->cn_flags;
 	int nameiop = cnp->cn_nameiop;
 	int nmlen = cnp->cn_namelen;
 	int error, islastcn, isdot;
diff --git a/sys/fs/unionfs/union_vnops.c b/sys/fs/unionfs/union_vnops.c
index 153a5db323d9..aaff77dcb13d 100644
--- a/sys/fs/unionfs/union_vnops.c
+++ b/sys/fs/unionfs/union_vnops.c
@@ -97,8 +97,9 @@ unionfs_lookup(struct vop_cachedlookup_args *ap)
 	int		iswhiteout;
 	int		lockflag;
 	int		error , uerror, lerror;
+	uint64_t	cnflags;
 	u_long		nameiop;
-	u_long		cnflags, cnflagsbk;
+	u_long		cnflagsbk;
 	struct unionfs_node *dunp;
 	struct vnode   *dvp, *udvp, *ldvp, *vp, *uvp, *lvp, *dtmpvp;
 	struct vattr	va;
diff --git a/sys/kern/uipc_mqueue.c b/sys/kern/uipc_mqueue.c
index 14fbe9a7f281..926a9d311b67 100644
--- a/sys/kern/uipc_mqueue.c
+++ b/sys/kern/uipc_mqueue.c
@@ -846,7 +846,8 @@ mqfs_lookupx(struct vop_cachedlookup_args *ap)
 	struct mqfs_node *pd;
 	struct mqfs_node *pn;
 	struct mqfs_info *mqfs;
-	int nameiop, flags, error, namelen;
+	uint64_t flags;
+	int nameiop, error, namelen;
 	char *pname;
 	struct thread *td;
 
diff --git a/sys/kern/vfs_cache.c b/sys/kern/vfs_cache.c
index cdd882e09075..e6cf39c09f19 100644
--- a/sys/kern/vfs_cache.c
+++ b/sys/kern/vfs_cache.c
@@ -4006,7 +4006,7 @@ SYSCTL_PROC(_vfs_cache_param, OID_AUTO, fast_lookup, CTLTYPE_INT|CTLFLAG_RW|CTLF
  */
 struct nameidata_outer {
 	size_t ni_pathlen;
-	int cn_flags;
+	uint64_t cn_flags;
 };
 
 struct nameidata_saved {