NFS: Fix a race in nfs_call_unlink()

We should check that the filehandles match before transferring the
sillyrename data to the newly looked-up dentry in case the name was
reused on the server.

Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
This commit is contained in:
Trond Myklebust 2022-11-16 11:11:53 -05:00
parent 35e3b6ae84
commit 5776a9cd2a
1 changed files with 1 additions and 0 deletions

View File

@ -139,6 +139,7 @@ static int nfs_call_unlink(struct dentry *dentry, struct inode *inode, struct nf
*/ */
spin_lock(&alias->d_lock); spin_lock(&alias->d_lock);
if (d_really_is_positive(alias) && if (d_really_is_positive(alias) &&
!nfs_compare_fh(NFS_FH(inode), NFS_FH(d_inode(alias))) &&
!(alias->d_flags & DCACHE_NFSFS_RENAMED)) { !(alias->d_flags & DCACHE_NFSFS_RENAMED)) {
devname_garbage = alias->d_fsdata; devname_garbage = alias->d_fsdata;
alias->d_fsdata = data; alias->d_fsdata = data;