Commit b40b1ba3 authored by Jeff Layton's avatar Jeff Layton Committed by Chuck Lever
Browse files

nfsd: fix timestamp updates in CB_GETATTR



When updating the local timestamps from CB_GETATTR, the updated values
are not being properly vetted.

Compare the update times vs. the saved times in the delegation rather
than the current times in the inode. Also, ensure that the ctime is
properly vetted vs. its original value.

Fixes: 6ae30d6e ("nfsd: add support for delegated timestamps")
Signed-off-by: default avatarJeff Layton <jlayton@kernel.org>
Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
parent 3952f1cb
Loading
Loading
Loading
Loading
+5 −6
Original line number Diff line number Diff line
@@ -9175,20 +9175,19 @@ static int cb_getattr_update_times(struct dentry *dentry, struct nfs4_delegation
	int ret;

	if (deleg_attrs_deleg(dp->dl_type)) {
		struct timespec64 atime = inode_get_atime(inode);
		struct timespec64 mtime = inode_get_mtime(inode);
		struct timespec64 now = current_time(inode);

		attrs.ia_atime = ncf->ncf_cb_atime;
		attrs.ia_mtime = ncf->ncf_cb_mtime;

		if (nfsd4_vet_deleg_time(&attrs.ia_atime, &atime, &now))
		if (nfsd4_vet_deleg_time(&attrs.ia_atime, &dp->dl_atime, &now))
			attrs.ia_valid |= ATTR_ATIME | ATTR_ATIME_SET;

		if (nfsd4_vet_deleg_time(&attrs.ia_mtime, &mtime, &now)) {
			attrs.ia_valid |= ATTR_CTIME | ATTR_CTIME_SET |
					  ATTR_MTIME | ATTR_MTIME_SET;
		if (nfsd4_vet_deleg_time(&attrs.ia_mtime, &dp->dl_mtime, &now)) {
			attrs.ia_valid |= ATTR_MTIME | ATTR_MTIME_SET;
			attrs.ia_ctime = attrs.ia_mtime;
			if (nfsd4_vet_deleg_time(&attrs.ia_ctime, &dp->dl_ctime, &now))
				attrs.ia_valid |= ATTR_CTIME | ATTR_CTIME_SET;
		}
	} else {
		attrs.ia_valid |= ATTR_MTIME | ATTR_CTIME;