Skip to content

Commit 3798f47

Browse files
spuiukjtlayton
authored andcommitted
cifs: Do not lookup hashed negative dentry in cifs_atomic_open
We do not need to lookup a hashed negative directory since we have already revalidated it before and have found it to be fine. This also prevents a crash in cifs_lookup() when it attempts to rehash the already hashed negative lookup dentry. The patch has been tested using the reproducer at https://bugzilla.redhat.com/show_bug.cgi?id=867344#c28 Cc: <stable@kernel.org> # 3.6.x Reported-by: Vit Zahradka <vit.zahradka@tiscali.cz> Signed-off-by: Sachin Prabhu <sprabhu@redhat.com>
1 parent 36960e4 commit 3798f47

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

‎fs/cifs/dir.c‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,16 @@ cifs_atomic_open(struct inode *inode, struct dentry *direntry,
398398
* in network traffic in the other paths.
399399
*/
400400
if (!(oflags & O_CREAT)) {
401-
struct dentry *res = cifs_lookup(inode, direntry, 0);
401+
struct dentry *res;
402+
403+
/*
404+
* Check for hashed negative dentry. We have already revalidated
405+
* the dentry and it is fine. No need to perform another lookup.
406+
*/
407+
if (!d_unhashed(direntry))
408+
return -ENOENT;
409+
410+
res = cifs_lookup(inode, direntry, 0);
402411
if (IS_ERR(res))
403412
return PTR_ERR(res);
404413

0 commit comments

Comments
 (0)