Skip to content

Commit 410666a

Browse files
Roberto Bergantinos CorpasAnna Schumaker
authored andcommitted
nfs: return EISDIR on nfs3_proc_create if d_alias is a dir
If we found an alias through nfs3_do_create/nfs_add_or_obtain /d_splice_alias which happens to be a dir dentry, we don't return any error, and simply forget about this alias, but the original dentry we were adding and passed as parameter remains negative. This later causes an oops on nfs_atomic_open_v23/finish_open since we supply a negative dentry to do_dentry_open. This has been observed running lustre-racer, where dirs and files are created/removed concurrently with the same name and O_EXCL is not used to open files (frequent file redirection). While d_splice_alias typically returns a directory alias or NULL, we explicitly check d_is_dir() to ensure that we don't attempt to perform file operations (like finish_open) on a directory inode, which triggers the observed oops. Fixes: 7c6c524 ("NFS: add atomic_open for NFSv3 to handle O_TRUNC correctly.") Reviewed-by: Olga Kornievskaia <[email protected]> Reviewed-by: Scott Mayhew <[email protected]> Signed-off-by: Roberto Bergantinos Corpas <[email protected]> Signed-off-by: Anna Schumaker <[email protected]>
1 parent 6de23f8 commit 410666a

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

fs/nfs/nfs3proc.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,8 +392,13 @@ nfs3_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr,
392392
if (status != 0)
393393
goto out_release_acls;
394394

395-
if (d_alias)
395+
if (d_alias) {
396+
if (d_is_dir(d_alias)) {
397+
status = -EISDIR;
398+
goto out_dput;
399+
}
396400
dentry = d_alias;
401+
}
397402

398403
/* When we created the file with exclusive semantics, make
399404
* sure we set the attributes afterwards. */

0 commit comments

Comments
 (0)