1 From 3798f47aa276b332c30da499cb4df4577e2f8872 Mon Sep 17 00:00:00 2001
2 From: Sachin Prabhu <sprabhu@redhat.com>
3 Date: Mon, 5 Nov 2012 11:39:32 +0000
4 Subject: cifs: Do not lookup hashed negative dentry in cifs_atomic_open
6 From: Sachin Prabhu <sprabhu@redhat.com>
8 commit 3798f47aa276b332c30da499cb4df4577e2f8872 upstream.
10 We do not need to lookup a hashed negative directory since we have
11 already revalidated it before and have found it to be fine.
13 This also prevents a crash in cifs_lookup() when it attempts to rehash
14 the already hashed negative lookup dentry.
16 The patch has been tested using the reproducer at
17 https://bugzilla.redhat.com/show_bug.cgi?id=867344#c28
19 Reported-by: Vit Zahradka <vit.zahradka@tiscali.cz>
20 Signed-off-by: Sachin Prabhu <sprabhu@redhat.com>
21 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
24 fs/cifs/dir.c | 11 ++++++++++-
25 1 file changed, 10 insertions(+), 1 deletion(-)
29 @@ -392,7 +392,16 @@ cifs_atomic_open(struct inode *inode, st
30 * in network traffic in the other paths.
32 if (!(oflags & O_CREAT)) {
33 - struct dentry *res = cifs_lookup(inode, direntry, 0);
37 + * Check for hashed negative dentry. We have already revalidated
38 + * the dentry and it is fine. No need to perform another lookup.
40 + if (!d_unhashed(direntry))
43 + res = cifs_lookup(inode, direntry, 0);