cifs: Do not lookup hashed negative dentry in cifs_atomic_open
Subsystems (3)
PATCH 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 | 6 ++++++ 1 file changed, 6 insertions(+)
fs/cifs/dir.c +6 -0
@@ -398,6 +398,12 @@ 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
A message that is not in the archive (sent off-list or not yet received): 1351615413-9182-1-git-send-email-sprabhu-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
Jeff Layton
Acked-byQuoted 23 lines · On Tue, 30 Oct 2012 16:43:33 +0000 Sachin Prabhu…
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#c28Cc <[email protected]> # 3.6.xReported-by Vit Zahradka <[email protected]>Signed-off-by Sachin Prabhu <[email protected]>--- fs/cifs/dir.c | 6 ++++++ 1 file changed, 6 insertions(+)fs/cifs/dir.c +0
-0@@ -398,6 +398,12 @@ cifs_atomic_open(struct inode *inode, struct dentry *direntry,* in network traffic in the other paths. */
fs/cifs/dir.c cifs_atomic_open(struct inode *inode, struct dentry *direntry, · line 409
Quoted 10 lines
fs/cifs/dir.c +6
-0if (!(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);
2012/10/30 Sachin Prabhu <[email protected]>:
Quoted 21 lines
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#c28Cc <[email protected]> # 3.6.xReported-by Vit Zahradka <[email protected]>Signed-off-by Sachin Prabhu <[email protected]>--- fs/cifs/dir.c | 6 ++++++ 1 file changed, 6 insertions(+)fs/cifs/dir.c +0
-0
fs/cifs/dir.c cifs_atomic_open(struct inode *inode, struct dentry *direntry, · line 403
Quoted 6 lines
fs/cifs/dir.c +3
-0@@ -398,6 +398,12 @@ 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. +*/
Patch looks ok, but the comment above doesn't match the kernel CodingStyle for block comments. While cifs code has a many places where it doesn't follow the style, we should keep new code as clean as possible.
Quoted 13 lines
fs/cifs/dir.c +3
-1+if (!d_unhashed (direntry)) +return -ENOENT ; +struct dentry *res =cifs_lookup (inode, direntry,0 );if (IS_ERR (res))return PTR_ERR (res); --1.7.11.7
--
To unsubscribe from this list: send the line "unsubscribe linux-cifs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 2 lines
Best regards, Pavel Shilovsky.
Quoted 11 lines · Pavel Shilovsky
Quoted 2 lines
if (!(oflags & O_CREAT)) {+ /* Check for hashed negative dentry. We have already
revalidated
Quoted 1 line
+ * the dentry and it is fine. No need to perform
another lookup.
Quoted 1 line
+ */
Patch looks ok, but the comment above doesn't match the kernel CodingStyle for block comments. While cifs code has a many places where it doesn't follow the style, we should keep new code as clean as possible.
Sorry about that. I had passed it through checkpatch.pl and it came out fine. I checked the codestyle document and it appears that this style is preferred only for files in net/ and drivers/net/. I am sending a v2 of the patch with the small cosmetic change to ensure that it follows the Coding Style.
Sachin Prabhu