All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cifs: Do not lookup hashed negative dentry in cifs_atomic_open
@ 2012-10-30 16:43 Sachin Prabhu
       [not found] ` <1351615413-9182-1-git-send-email-sprabhu-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Sachin Prabhu @ 2012-10-30 16:43 UTC (permalink / raw)
  To: linux-cifs
  Cc: Steve French, Jeff Layton, vit.zahradka-IWqWACnzNjzrBKCeMvbIDA,
	linux-fsdevel-u79uwXL29TY76Z2rM5mHXA

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

Cc: <stable-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> # 3.6.x 
Reported-by: Vit Zahradka <vit.zahradka-IWqWACnzNjzrBKCeMvbIDA@public.gmane.org>
Signed-off-by: Sachin Prabhu <sprabhu-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
---
 fs/cifs/dir.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c
index 7c0a812..e26d0a6 100644
--- a/fs/cifs/dir.c
+++ b/fs/cifs/dir.c
@@ -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);
-- 
1.7.11.7

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] cifs: Do not lookup hashed negative dentry in cifs_atomic_open
       [not found] ` <1351615413-9182-1-git-send-email-sprabhu-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
@ 2012-10-30 16:46   ` Jeff Layton
  2012-10-30 18:30   ` Pavel Shilovsky
  1 sibling, 0 replies; 4+ messages in thread
From: Jeff Layton @ 2012-10-30 16:46 UTC (permalink / raw)
  To: Sachin Prabhu
  Cc: linux-cifs, Steve French, vit.zahradka-IWqWACnzNjzrBKCeMvbIDA,
	linux-fsdevel-u79uwXL29TY76Z2rM5mHXA

On Tue, 30 Oct 2012 16:43:33 +0000
Sachin Prabhu <sprabhu-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> wrote:

> 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
> 
> Cc: <stable-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> # 3.6.x 
> Reported-by: Vit Zahradka <vit.zahradka-IWqWACnzNjzrBKCeMvbIDA@public.gmane.org>
> Signed-off-by: Sachin Prabhu <sprabhu-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
> ---
>  fs/cifs/dir.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c
> index 7c0a812..e26d0a6 100644
> --- a/fs/cifs/dir.c
> +++ b/fs/cifs/dir.c
> @@ -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);

Acked-by: Jeff Layton <jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] cifs: Do not lookup hashed negative dentry in cifs_atomic_open
       [not found] ` <1351615413-9182-1-git-send-email-sprabhu-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
  2012-10-30 16:46   ` Jeff Layton
@ 2012-10-30 18:30   ` Pavel Shilovsky
  2012-10-30 19:20     ` Sachin Prabhu
  1 sibling, 1 reply; 4+ messages in thread
From: Pavel Shilovsky @ 2012-10-30 18:30 UTC (permalink / raw)
  To: Sachin Prabhu
  Cc: linux-cifs, Steve French, Jeff Layton,
	vit.zahradka-IWqWACnzNjzrBKCeMvbIDA,
	linux-fsdevel-u79uwXL29TY76Z2rM5mHXA

2012/10/30 Sachin Prabhu <sprabhu-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>:
> 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
>
> Cc: <stable-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> # 3.6.x
> Reported-by: Vit Zahradka <vit.zahradka-IWqWACnzNjzrBKCeMvbIDA@public.gmane.org>
> Signed-off-by: Sachin Prabhu <sprabhu-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
> ---
>  fs/cifs/dir.c | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c
> index 7c0a812..e26d0a6 100644
> --- a/fs/cifs/dir.c
> +++ b/fs/cifs/dir.c
> @@ -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.

> +               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 majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



-- 
Best regards,
Pavel Shilovsky.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] cifs: Do not lookup hashed negative dentry in cifs_atomic_open
  2012-10-30 18:30   ` Pavel Shilovsky
@ 2012-10-30 19:20     ` Sachin Prabhu
  0 siblings, 0 replies; 4+ messages in thread
From: Sachin Prabhu @ 2012-10-30 19:20 UTC (permalink / raw)
  To: Pavel Shilovsky
  Cc: linux-cifs, Steve French, Jeff Layton, vit.zahradka, linux-fsdevel

On Tue, 2012-10-30 at 22:30 +0400, Pavel Shilovsky wrote:
> >         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. 

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-10-30 19:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-30 16:43 [PATCH] cifs: Do not lookup hashed negative dentry in cifs_atomic_open Sachin Prabhu
     [not found] ` <1351615413-9182-1-git-send-email-sprabhu-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2012-10-30 16:46   ` Jeff Layton
2012-10-30 18:30   ` Pavel Shilovsky
2012-10-30 19:20     ` Sachin Prabhu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.