Linux CIFS filesystem development
 help / color / mirror / Atom feed
From: Jeff Layton <jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
To: Steve French <smfrench-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: Suresh Jayaraman <sjayaraman-l3A5Bk7waGM@public.gmane.org>,
	linux-cifs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	shirishpargaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Subject: Re: [PATCH] cifs: fix potential double put of TCP session reference
Date: Tue, 14 Sep 2010 11:34:17 -0400	[thread overview]
Message-ID: <20100914113417.3084824b@corrin.poochiereds.net> (raw)
In-Reply-To: <AANLkTi=RDgXd50Qu1G1ifZOdrzVEz2YC3f0z2pzyhrRn-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>

On Tue, 14 Sep 2010 10:19:56 -0500
Steve French <smfrench-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:

> On Tue, Sep 14, 2010 at 6:39 AM, Jeff Layton <jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> wrote:
> > On Tue, 14 Sep 2010 15:18:32 +0530
> > Suresh Jayaraman <sjayaraman-l3A5Bk7waGM@public.gmane.org> wrote:
> >
> >> On 09/13/2010 11:32 PM, Jeff Layton wrote:
> >> > cifs_get_smb_ses must be called on a server pointer on which it holds an
> >> > active reference. It first does a search for an existing SMB session. If
> >> > it finds one, it'll put the server reference and then try to ensure that
> >> > the negprot is done, etc.
> >> >
> >> > If it encounters an error at that point then it'll return an error.
> >> > There's a potential problem here though. When cifs_get_smb_ses returns
> >> > an error, the caller will also put the TCP server reference leading to a
> >> > double-put.
> >> >
> >> > Fix this by having cifs_get_smb_ses only put the server reference if
> >> > it found an existing session that it could use and isn't returning an
> >> > error.
> >> >
> >> > Signed-off-by: Jeff Layton <jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
> >> > ---
> >> >  fs/cifs/connect.c |    6 +++---
> >> >  1 files changed, 3 insertions(+), 3 deletions(-)
> >> >
> >> > diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
> >> > index 67dad54..88c84a3 100644
> >> > --- a/fs/cifs/connect.c
> >> > +++ b/fs/cifs/connect.c
> >> > @@ -1706,9 +1706,6 @@ cifs_get_smb_ses(struct TCP_Server_Info *server, struct smb_vol *volume_info)
> >> >     if (ses) {
> >> >             cFYI(1, "Existing smb sess found (status=%d)", ses->status);
> >> >
> >> > -           /* existing SMB ses has a server reference already */
> >> > -           cifs_put_tcp_session(server);
> >> > -
> >> >             mutex_lock(&ses->session_mutex);
> >> >             rc = cifs_negotiate_protocol(xid, ses);
> >> >             if (rc) {
> >> > @@ -1731,6 +1728,9 @@ cifs_get_smb_ses(struct TCP_Server_Info *server, struct smb_vol *volume_info)
> >> >                     }
> >> >             }
> >> >             mutex_unlock(&ses->session_mutex);
> >> > +
> >> > +           /* existing SMB ses has a server reference already */
> >> > +           cifs_put_tcp_session(server);
> >> >             FreeXid(xid);
> >> >             return ses;
> >> >     }
> >>
> >> Looks correct to me.
> >>
> >> Reviewed-by: Suresh Jayaraman <sjayaraman-l3A5Bk7waGM@public.gmane.org>
> >
> > Thanks. In hindsight, I should have probably sent this to stable too.
> >
> > Steve, would you like me to resend and cc stable? We probably want this
> > in 2.6.36 too, if possible.
> 
> Yes - I agree makes sense.  Any other candidate patches for 2.6.36?
> 

No, that's all I've got for now. I'll resend in a bit and cc stable.

Thanks,
-- 
Jeff Layton <jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>

  parent reply	other threads:[~2010-09-14 15:34 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-13 18:02 [PATCH] cifs: fix potential double put of TCP session reference Jeff Layton
     [not found] ` <1284400930-24134-1-git-send-email-jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2010-09-14  9:48   ` Suresh Jayaraman
     [not found]     ` <4C8F44F0.30803-l3A5Bk7waGM@public.gmane.org>
2010-09-14 11:39       ` Jeff Layton
     [not found]         ` <20100914073954.5c818d3c-4QP7MXygkU+dMjc06nkz3ljfA9RmPOcC@public.gmane.org>
2010-09-14 15:19           ` Steve French
     [not found]             ` <AANLkTi=RDgXd50Qu1G1ifZOdrzVEz2YC3f0z2pzyhrRn-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-09-14 15:34               ` Jeff Layton [this message]
  -- strict thread matches above, loose matches on Subject: below --
2010-09-14 15:38 Jeff Layton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100914113417.3084824b@corrin.poochiereds.net \
    --to=jlayton-h+wxahxf7alqt0dzr+alfa@public.gmane.org \
    --cc=linux-cifs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=shirishpargaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=sjayaraman-l3A5Bk7waGM@public.gmane.org \
    --cc=smfrench-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox