Skip to content

Commit 0f900f1

Browse files
author
Trond Myklebust
committed
NFS: Initialise verifiers for visible dentries in _nfs4_open_and_get_state
Ensure that the verifiers are initialised before calling d_splice_alias() in _nfs4_open_and_get_state(). Reported-by: Michael Stoler <michael.stoler@vastdata.com> Fixes: cf5b405 ("NFSv4: Fix races between open and dentry revalidation") Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
1 parent 518c32a commit 0f900f1

1 file changed

Lines changed: 14 additions & 13 deletions

File tree

fs/nfs/nfs4proc.c

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3174,18 +3174,6 @@ static int _nfs4_open_and_get_state(struct nfs4_opendata *opendata,
31743174
if (opendata->o_res.rflags & NFS4_OPEN_RESULT_PRESERVE_UNLINKED)
31753175
set_bit(NFS_INO_PRESERVE_UNLINKED, &NFS_I(state->inode)->flags);
31763176

3177-
dentry = opendata->dentry;
3178-
if (d_really_is_negative(dentry)) {
3179-
struct dentry *alias;
3180-
d_drop(dentry);
3181-
alias = d_splice_alias(igrab(state->inode), dentry);
3182-
/* d_splice_alias() can't fail here - it's a non-directory */
3183-
if (alias) {
3184-
dput(ctx->dentry);
3185-
ctx->dentry = dentry = alias;
3186-
}
3187-
}
3188-
31893177
switch(opendata->o_arg.claim) {
31903178
default:
31913179
break;
@@ -3196,7 +3184,20 @@ static int _nfs4_open_and_get_state(struct nfs4_opendata *opendata,
31963184
break;
31973185
if (opendata->o_res.delegation.type != 0)
31983186
dir_verifier = nfs_save_change_attribute(dir);
3199-
nfs_set_verifier(dentry, dir_verifier);
3187+
}
3188+
3189+
dentry = opendata->dentry;
3190+
nfs_set_verifier(dentry, dir_verifier);
3191+
if (d_really_is_negative(dentry)) {
3192+
struct dentry *alias;
3193+
d_drop(dentry);
3194+
alias = d_splice_alias(igrab(state->inode), dentry);
3195+
/* d_splice_alias() can't fail here - it's a non-directory */
3196+
if (alias) {
3197+
dput(ctx->dentry);
3198+
nfs_set_verifier(alias, dir_verifier);
3199+
ctx->dentry = dentry = alias;
3200+
}
32003201
}
32013202

32023203
/* Parse layoutget results before we check for access */

0 commit comments

Comments
 (0)