Skip to content

Commit 5b2f3e0

Browse files
committed
NFSD: Decode NFSv4 birth time attribute
NFSD has advertised support for the NFSv4 time_create attribute since commit e377a3e ("nfsd: Add support for the birth time attribute"). Igor Mammedov reports that Mac OS clients attempt to set the NFSv4 birth time attribute via OPEN(CREATE) and SETATTR if the server indicates that it supports it, but since the above commit was merged, those attempts now fail. Table 5 in RFC 8881 lists the time_create attribute as one that can be both set and retrieved, but the above commit did not add server support for clients to provide a time_create attribute. IMO that's a bug in our implementation of the NFSv4 protocol, which this commit addresses. Whether NFSD silently ignores the new birth time or actually sets it is another matter. I haven't found another filesystem service in the Linux kernel that enables users or clients to modify a file's birth time attribute. This commit reflects my (perhaps incorrect) understanding of whether Linux users can set a file's birth time. NFSD will now recognize a time_create attribute but it ignores its value. It clears the time_create bit in the returned attribute bitmask to indicate that the value was not used. Reported-by: Igor Mammedov <imammedo@redhat.com> Fixes: e377a3e ("nfsd: Add support for the birth time attribute") Tested-by: Igor Mammedov <imammedo@redhat.com> Reviewed-by: Jeff Layton <jlayton@kernel.org> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
1 parent a23dd54 commit 5b2f3e0

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

fs/nfsd/nfs4xdr.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,15 @@ nfsd4_decode_fattr4(struct nfsd4_compoundargs *argp, u32 *bmval, u32 bmlen,
470470
return nfserr_bad_xdr;
471471
}
472472
}
473+
if (bmval[1] & FATTR4_WORD1_TIME_CREATE) {
474+
struct timespec64 ts;
475+
476+
/* No Linux filesystem supports setting this attribute. */
477+
bmval[1] &= ~FATTR4_WORD1_TIME_CREATE;
478+
status = nfsd4_decode_nfstime4(argp, &ts);
479+
if (status)
480+
return status;
481+
}
473482
if (bmval[1] & FATTR4_WORD1_TIME_MODIFY_SET) {
474483
u32 set_it;
475484

fs/nfsd/nfsd.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,8 @@ static inline bool nfsd_attrs_supported(u32 minorversion, const u32 *bmval)
465465
(FATTR4_WORD0_SIZE | FATTR4_WORD0_ACL)
466466
#define NFSD_WRITEABLE_ATTRS_WORD1 \
467467
(FATTR4_WORD1_MODE | FATTR4_WORD1_OWNER | FATTR4_WORD1_OWNER_GROUP \
468-
| FATTR4_WORD1_TIME_ACCESS_SET | FATTR4_WORD1_TIME_MODIFY_SET)
468+
| FATTR4_WORD1_TIME_ACCESS_SET | FATTR4_WORD1_TIME_CREATE \
469+
| FATTR4_WORD1_TIME_MODIFY_SET)
469470
#ifdef CONFIG_NFSD_V4_SECURITY_LABEL
470471
#define MAYBE_FATTR4_WORD2_SECURITY_LABEL \
471472
FATTR4_WORD2_SECURITY_LABEL

0 commit comments

Comments
 (0)