Skip to contentSkip to conversation

cifs: Do not lookup hashed negative dentry in cifs_atomic_open

PATCH New Sachin Prabhu 1 participant 1 message Oct 30, 2012

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 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

---
 fs/cifs/dir.c | 7 +++++++
 1 file changed, 7 insertions(+)
fs/cifs/dir.c +7 -0
index 7c0a812..d903647 100644
@@ -398,6 +398,13 @@ cifs_atomic_open(struct inode *inode, struct dentry *direntry,
 	 * in network traffic in the other paths.
 	 */
 	if (!(oflags & O_CREAT)) {
+		/*
+		 * 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;
+
 		struct dentry *res = cifs_lookup(inode, direntry, 0);
 		if (IS_ERR(res))
 			return PTR_ERR(res);
Signature · 1 line
1.7.11.7