]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/3.6.8/cifs-do-not-lookup-hashed-negative-dentry-in-cifs_atomic_open.patch
Fixes for 4.19
[thirdparty/kernel/stable-queue.git] / releases / 3.6.8 / cifs-do-not-lookup-hashed-negative-dentry-in-cifs_atomic_open.patch
CommitLineData
384ba1c4
GKH
1From 3798f47aa276b332c30da499cb4df4577e2f8872 Mon Sep 17 00:00:00 2001
2From: Sachin Prabhu <sprabhu@redhat.com>
3Date: Mon, 5 Nov 2012 11:39:32 +0000
4Subject: cifs: Do not lookup hashed negative dentry in cifs_atomic_open
5
6From: Sachin Prabhu <sprabhu@redhat.com>
7
8commit 3798f47aa276b332c30da499cb4df4577e2f8872 upstream.
9
10We do not need to lookup a hashed negative directory since we have
11already revalidated it before and have found it to be fine.
12
13This also prevents a crash in cifs_lookup() when it attempts to rehash
14the already hashed negative lookup dentry.
15
16The patch has been tested using the reproducer at
17https://bugzilla.redhat.com/show_bug.cgi?id=867344#c28
18
19Reported-by: Vit Zahradka <vit.zahradka@tiscali.cz>
20Signed-off-by: Sachin Prabhu <sprabhu@redhat.com>
21Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
22
23---
24 fs/cifs/dir.c | 11 ++++++++++-
25 1 file changed, 10 insertions(+), 1 deletion(-)
26
27--- a/fs/cifs/dir.c
28+++ b/fs/cifs/dir.c
29@@ -392,7 +392,16 @@ cifs_atomic_open(struct inode *inode, st
30 * in network traffic in the other paths.
31 */
32 if (!(oflags & O_CREAT)) {
33- struct dentry *res = cifs_lookup(inode, direntry, 0);
34+ struct dentry *res;
35+
36+ /*
37+ * Check for hashed negative dentry. We have already revalidated
38+ * the dentry and it is fine. No need to perform another lookup.
39+ */
40+ if (!d_unhashed(direntry))
41+ return -ENOENT;
42+
43+ res = cifs_lookup(inode, direntry, 0);
44 if (IS_ERR(res))
45 return PTR_ERR(res);
46