]>
Commit | Line | Data |
---|---|---|
384ba1c4 GKH |
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 | |
5 | ||
6 | From: Sachin Prabhu <sprabhu@redhat.com> | |
7 | ||
8 | commit 3798f47aa276b332c30da499cb4df4577e2f8872 upstream. | |
9 | ||
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. | |
12 | ||
13 | This also prevents a crash in cifs_lookup() when it attempts to rehash | |
14 | the already hashed negative lookup dentry. | |
15 | ||
16 | The patch has been tested using the reproducer at | |
17 | https://bugzilla.redhat.com/show_bug.cgi?id=867344#c28 | |
18 | ||
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> | |
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 |