nfsd: Fix NFSv3 atomicity bugs in nfsd_setattr()
authorTrond Myklebust <trond.myklebust@hammerspace.com>
Fri, 16 Feb 2024 01:24:51 +0000 (20:24 -0500)
committerChuck Lever <chuck.lever@oracle.com>
Fri, 1 Mar 2024 14:12:33 +0000 (09:12 -0500)
commit24d92de9186ebc340687caf7356e1070773e67bc
tree5ce32cf2925b847c755d5f3b4a9daf91390264e0
parent6412e44c40aaf8f1d7320b2099c5bdd6cb9126ac
nfsd: Fix NFSv3 atomicity bugs in nfsd_setattr()

The main point of the guarded SETATTR is to prevent races with other
WRITE and SETATTR calls. That requires that the check of the guard time
against the inode ctime be done after taking the inode lock.

Furthermore, we need to take into account the 32-bit nature of
timestamps in NFSv3, and the possibility that files may change at a
faster rate than once a second.

Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Reviewed-by: NeilBrown <neilb@suse.de>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
fs/nfsd/nfs3proc.c
fs/nfsd/nfs3xdr.c
fs/nfsd/nfs4proc.c
fs/nfsd/nfs4state.c
fs/nfsd/nfsproc.c
fs/nfsd/vfs.c
fs/nfsd/vfs.h
fs/nfsd/xdr3.h