Skip to contentSkip to conversation

Patch "NFS: Fix inode corruption in nfs_prime_dcache()" has been added to the 4.8-stable tree

PATCH [email protected] 1 participant 1 message Oct 26, 2016

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

NFS: Fix inode corruption in nfs_prime_dcache()

to the 4.8-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
nfs-fix-inode-corruption-in-nfs_prime_dcache.patch
and it can be found in the queue-4.8 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

Quoted 1 line

From 7dc72d5f7a0ec97a53e126c46e2cbd2560757955 Mon Sep 17 00:00:00 2001

From: Trond Myklebust <[email protected]>
Date: Thu, 22 Sep 2016 13:38:52 -0400
Subject: NFS: Fix inode corruption in nfs_prime_dcache()

From: Trond Myklebust <[email protected]>

commit 7dc72d5f7a0ec97a53e126c46e2cbd2560757955 upstream.

Due to inode number reuse in filesystems, we can end up corrupting the inode on our client if we apply the file attributes without ensuring that the filehandle matches.
Typical symptoms include spurious "mode changed" reports in the syslog.

We still do want to ensure that we don't invalidate the dentry if the inode number matches, but we don't have a filehandle.

Fixes fa9233699cc1 ("NFS: Don't require a filehandle to refresh...")
---
 fs/nfs/dir.c |   16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)
fs/nfs/dir.c +11 -5
@@ -435,11 +435,11 @@ int nfs_same_file(struct dentry *dentry,
 		return 0;
 
 	nfsi = NFS_I(inode);
-	if (entry->fattr->fileid == nfsi->fileid)
-		return 1;
-	if (nfs_compare_fh(entry->fh, &nfsi->fh) == 0)
-		return 1;
-	return 0;
+	if (entry->fattr->fileid != nfsi->fileid)
+		return 0;
+	if (entry->fh->size && nfs_compare_fh(entry->fh, &nfsi->fh) != 0)
+		return 0;
+	return 1;
 }
 
 static
@@ -517,6 +517,8 @@ again:
 					&entry->fattr->fsid))
 			goto out;
 		if (nfs_same_file(dentry, entry)) {
+			if (!entry->fh->size)
+				goto out;
 			nfs_set_verifier(dentry, nfs_save_change_attribute(dir));
 			status = nfs_refresh_inode(d_inode(dentry), entry->fattr);
 			if (!status)
@@ -529,6 +531,10 @@ again:
 			goto again;
 		}
 	}
+	if (!entry->fh->size) {
+		d_lookup_done(dentry);
+		goto out;
+	}
 
 	inode = nfs_fhget(dentry->d_sb, entry->fh, entry->fattr, entry->label);
 	alias = d_splice_alias(inode, dentry);

Patches currently in stable-queue which might be from [email protected] are

queue-4.8/nfsv4-don-t-report-revoked-delegations-as-valid-in-nfs_have_delegation.patch queue-4.8/nfs-fix-inode-corruption-in-nfs_prime_dcache.patch queue-4.8/nfsv4.2-fix-a-reference-leak-in-nfs42_proc_layoutstats_generic.patch queue-4.8/nfsv4-open-state-recovery-must-account-for-file-permission-changes.patch queue-4.8/nfsv4-nfs4_copy_delegation_stateid-must-fail-if-the-delegation-is-invalid.patch