nfs_nfsdserv.c: Fix handling of archive flag for mkdir

An NFSv4.1/4.2 client can set/clear the archive, hidden
and system flags when creating non-regular files, such
as directories.

Without this patch, the setting of va_flags causes an
EPERM failure, since they are specified for VOP_MKDIR(),
VOP_MKNOD() and VOP_SYMLINK().

This patch sets va_flags == VNOVAL for the above VOP_xxx()
calls and then sets/clears the flags after creation,
which fixes the problem.

This bug only affects the Windows NFSv4.1/4.2 client.

PR:	293691
Tested by:	Dan Shelton <[email protected]>
MFC after:	2 weeks
This commit is contained in:
Rick Macklem committed 2026-03-16 16:22:37 -07:00
1 parent e39d3a6b32
commit 6580d04086
1 file changed
+13 -1
+13 -1
View File
@@ -1438,7 +1438,7 @@ nfsrvd_mknod(struct nfsrv_descript *nd, __unused int isdgram,
vnode_t vp, dirp = NULL;
nfsattrbit_t attrbits;
char *bufp = NULL, *pathcp = NULL;
u_long *hashp, cnflags;
u_long *hashp, cnflags, setflags;
NFSACL_T *aclp = NULL, *daclp = NULL;
struct thread *p = curthread;
@@ -1605,9 +1605,13 @@ nfsrvd_mknod(struct nfsrv_descript *nd, __unused int isdgram,
}
}
/* For NFSv4, set na_flags via nfsrv_fixattr(). */
setflags = nva.na_flags;
nva.na_flags = VNOVAL;
nd->nd_repstat = nfsvno_mknod(&named, &nva, nd->nd_cred, p);
if (!nd->nd_repstat) {
vp = named.ni_vp;
nva.na_flags = setflags;
nfsrv_fixattr(nd, vp, &nva, aclp, daclp, p, &attrbits, false);
nd->nd_repstat = nfsvno_getfh(vp, fhp, p);
if ((nd->nd_flag & ND_NFSV3) && !nd->nd_repstat)
@@ -2115,10 +2119,14 @@ nfsrvd_symlinksub(struct nfsrv_descript *nd, struct nameidata *ndp,
int pathlen)
{
u_int32_t *tl;
u_long setflags;
setflags = nvap->na_flags;
nvap->na_flags = (u_long)VNOVAL;
nd->nd_repstat = nfsvno_symlink(ndp, nvap, pathcp, pathlen,
!(nd->nd_flag & ND_NFSV2), nd->nd_saveduid, nd->nd_cred, p, exp);
if (!nd->nd_repstat && !(nd->nd_flag & ND_NFSV2)) {
nvap->na_flags = setflags;
nfsrv_fixattr(nd, ndp->ni_vp, nvap, aclp, NULL, p, attrbitp,
false);
if (nd->nd_flag & ND_NFSV3) {
@@ -2249,12 +2257,16 @@ nfsrvd_mkdirsub(struct nfsrv_descript *nd, struct nameidata *ndp,
{
vnode_t vp;
u_int32_t *tl;
u_long setflags;
setflags = nvap->na_flags;
nvap->na_flags = (u_long)VNOVAL;
NFSVNO_SETATTRVAL(nvap, type, VDIR);
nd->nd_repstat = nfsvno_mkdir(ndp, nvap, nd->nd_saveduid,
nd->nd_cred, p, exp);
if (!nd->nd_repstat) {
vp = ndp->ni_vp;
nvap->na_flags = setflags;
nfsrv_fixattr(nd, vp, nvap, aclp, daclp, p, attrbitp, false);
nd->nd_repstat = nfsvno_getfh(vp, fhp, p);
if (!(nd->nd_flag & ND_NFSV4) && !nd->nd_repstat)