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: 6ae30d6eb26b ("nfsd: add support for delegated timestamps")
Signed-off-by: Jeff Layton <jlay...@kernel.org>
---
 fs/nfsd/nfs4state.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index 
f2fd0cbe256b9519eaa5cb0cc18872e08020edd3..205ee8cc6fa2b9f74d08f7938b323d03bdf8286c
 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -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;

-- 
2.50.1


Reply via email to