diff options
author | Sachin Prabhu <sprabhu@redhat.com> | 2012-11-05 11:39:32 +0000 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-11-26 12:14:07 -0800 |
commit | 50d4bcc3701d7f6173e3e8727234a4dd81518a3d (patch) | |
tree | 76a099f8acef8e5bd09dd3c092eb5b750b67fcba | |
parent | ea617a2c5150f9914c57215545575abf394df7bc (diff) | |
download | linux-stable-50d4bcc3701d7f6173e3e8727234a4dd81518a3d.tar.gz linux-stable-50d4bcc3701d7f6173e3e8727234a4dd81518a3d.tar.bz2 linux-stable-50d4bcc3701d7f6173e3e8727234a4dd81518a3d.zip |
cifs: Do not lookup hashed negative dentry in cifs_atomic_open
commit 3798f47aa276b332c30da499cb4df4577e2f8872 upstream.
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
Reported-by: Vit Zahradka <vit.zahradka@tiscali.cz>
Signed-off-by: Sachin Prabhu <sprabhu@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | fs/cifs/dir.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c index 781025be48bc..2b33b2ce894a 100644 --- a/fs/cifs/dir.c +++ b/fs/cifs/dir.c @@ -392,7 +392,16 @@ cifs_atomic_open(struct inode *inode, struct dentry *direntry, * in network traffic in the other paths. */ if (!(oflags & O_CREAT)) { - struct dentry *res = cifs_lookup(inode, direntry, 0); + struct dentry *res; + + /* + * Check for hashed negative dentry. We have already revalidated + * the dentry and it is fine. No need to perform another lookup. + */ + if (!d_unhashed(direntry)) + return -ENOENT; + + res = cifs_lookup(inode, direntry, 0); if (IS_ERR(res)) return PTR_ERR(res); |