[PATCH v4 2/9] nfs: fix nfs_call_unlink()

From: NeilBrown

Date: Wed Oct 28 2026 - 00:11:48 EST


From: NeilBrown <neil@xxxxxxxxxx>

nfs_call_unlink() calls d_alloc_parallel() on a dentry which has not had
the d_hash calculated. d_alloc_parallel() assumes this is calculated and
doesn't calculate it itself.
So this will never find an existing dentry and so will not detect
the races it aims to detect.

(This dentry ("alias") is never hashed so there is no lasting
inconsistency in the dcache.)

Fix this by calling full_name_hash()

Acked-by: Anna Schumaker <anna.schumaker@xxxxxxxxxxxxxxx>
Fixes: 565277f63c61 ("NFS: Fix a race in sillyrename")
Signed-off-by: NeilBrown <neil@xxxxxxxxxx>
---
fs/nfs/unlink.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/fs/nfs/unlink.c b/fs/nfs/unlink.c
index c8d712204e64..11a46a993e11 100644
--- a/fs/nfs/unlink.c
+++ b/fs/nfs/unlink.c
@@ -125,6 +125,9 @@ static int nfs_call_unlink(struct dentry *dentry, struct inode *inode, struct nf
struct dentry *alias;

down_read_non_owner(&NFS_I(dir)->rmdir_sem);
+ data->args.name.hash = full_name_hash(dentry->d_parent,
+ data->args.name.name,
+ data->args.name.len);
alias = d_alloc_parallel(dentry->d_parent, &data->args.name);
if (IS_ERR(alias)) {
up_read_non_owner(&NFS_I(dir)->rmdir_sem);
--
2.50.0.107.gf914562f5916.dirty