Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 10 Jul 2025 14:27:36 +0200
From:      =?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?= <des@FreeBSD.org>
To:        Rick Macklem <rmacklem@FreeBSD.org>
Cc:        src-committers@FreeBSD.org,  dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   Re: git: c5d72d29fe0e - main - nfsv4: Add support for the NFSv4 hidden and system attributes
Message-ID:  <867c0gcjt3.fsf@ltc.des.dev>
In-Reply-To: <202507062254.566MsbnL090918@gitrepo.freebsd.org> (Rick Macklem's message of "Sun, 6 Jul 2025 22:54:37 GMT")
References:  <202507062254.566MsbnL090918@gitrepo.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Rick Macklem <rmacklem@FreeBSD.org> writes:
> diff --git a/sys/fs/nfsclient/nfs_clvnops.c b/sys/fs/nfsclient/nfs_clvnop=
s.c
> index 0049d7edca33..fbfcdafaa06b 100644
> --- a/sys/fs/nfsclient/nfs_clvnops.c
> +++ b/sys/fs/nfsclient/nfs_clvnops.c
> [...]
> @@ -1092,7 +1100,8 @@ nfs_setattr(struct vop_setattr_args *ap)
>  	    vap->va_gid !=3D (gid_t)VNOVAL || vap->va_atime.tv_sec !=3D VNOVAL =
||
>  	    vap->va_mtime.tv_sec !=3D VNOVAL ||
>  	    vap->va_birthtime.tv_sec !=3D VNOVAL ||
> -	    vap->va_mode !=3D (mode_t)VNOVAL) &&
> +	    vap->va_mode !=3D (mode_t)VNOVAL ||
> +	    vap->va_flags !=3D (u_long)VNOVAL) &&
>  	    (vp->v_mount->mnt_flag & MNT_RDONLY))
>  		return (EROFS);
>  	if (vap->va_size !=3D VNOVAL) {

vap->va_flags was already checked (in the line just before the first
line of context), albeit without a cast.  Coverity erroneously claims
that this causes the entire expression to always be true, because it
thinks VNOVAL and (u_long)VNOVAL are two different values.  That's not
the case, but you probably still want this:

diff --git a/sys/fs/nfsclient/nfs_clvnops.c b/sys/fs/nfsclient/nfs_clvnops.c
index fbfcdafaa06b..fa451887e73e 100644
--- a/sys/fs/nfsclient/nfs_clvnops.c
+++ b/sys/fs/nfsclient/nfs_clvnops.c
@@ -1096,12 +1096,11 @@ nfs_setattr(struct vop_setattr_args *ap)
 	/*
 	 * Disallow write attempts if the filesystem is mounted read-only.
 	 */
-  	if ((vap->va_flags !=3D VNOVAL || vap->va_uid !=3D (uid_t)VNOVAL ||
+	if ((vap->va_flags !=3D (u_long)VNOVAL || vap->va_uid !=3D (uid_t)VNOVAL =
||
 	    vap->va_gid !=3D (gid_t)VNOVAL || vap->va_atime.tv_sec !=3D VNOVAL ||
 	    vap->va_mtime.tv_sec !=3D VNOVAL ||
 	    vap->va_birthtime.tv_sec !=3D VNOVAL ||
-	    vap->va_mode !=3D (mode_t)VNOVAL ||
-	    vap->va_flags !=3D (u_long)VNOVAL) &&
+	    vap->va_mode !=3D (mode_t)VNOVAL) &&
 	    (vp->v_mount->mnt_flag & MNT_RDONLY))
 		return (EROFS);
 	if (vap->va_size !=3D VNOVAL) {

DES
--=20
Dag-Erling Sm=C3=B8rgrav - des@FreeBSD.org



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?867c0gcjt3.fsf>