From: "Gustavo F. Padovan" <padovan@profusion.mobi>
To: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH] bluetooth: fix shutdown on SCO sockets
Date: Wed, 11 May 2011 14:09:51 -0300 [thread overview]
Message-ID: <20110511170951.GB22065@joana> (raw)
In-Reply-To: <BANLkTikgZBh5SyXJvFE6z+F2V-JxC5Y9YQ@mail.gmail.com>
Hi Luiz,
* Luiz Augusto von Dentz <luiz.dentz@gmail.com> [2011-05-05 17:50:53 +0300]:
> Hi Gustavo,
>
> On Mon, Apr 18, 2011 at 8:56 PM, Gustavo F. Padovan
> <padovan@profusion.mobi> wrote:
> > * Luiz Augusto von Dentz <luiz.dentz@gmail.com> [2011-04-17 20:26:53 +0300]:
> >
> >> Hi Gustavo,
> >>
> >> On Fri, Apr 15, 2011 at 9:58 PM, Gustavo F. Padovan
> >> <padovan@profusion.mobi> wrote:
> >> > Hi Luiz,
> >> >
> >> > * Luiz Augusto von Dentz <luiz.dentz@gmail.com> [2011-04-08 17:10:41 +0300]:
> >> >
> >> >> From: Luiz Augusto von Dentz <luiz.dentz-von@nokia.com>
> >> >>
> >> >> shutdown should wait for SCO link to be properly disconnected before
> >> >> detroying the socket, otherwise an application using the socket may
> >> >> assume link is properly disconnected before it really happens which
> >> >> can be a problem when e.g synchronizing profile switch.
> >> >>
> >> >> Signed-off-by: Luiz Augusto von Dentz <luiz.dentz-von@nokia.com>
> >> >
> >> > I applied it, but in bluetooth-next. Let's see its behaviour there and if no
> >> > problems show up we can move it to bluetooth-2.6
> >>
> >> I tested this against Nokia BH-504 and Sony Ericsson W600, both have
> >> problem when switching from hfp to a2dp where the avdtp start is sent
> >> before SCO is fully disconnected, this patch fixes with those
> >> headsets.
> >
> > Ok, I also pushed it to bluetooth-2.6.
>
>
> Apparently this cause a regression, since we set conn to NULL but an
> application may not wait for shutdown to complete and call
> close/release which will cause sco_chan_del to be called which destroy
> the socket without resetting conn->sk to NULL so on disconn_cfm it
> will access invalid memory.
>
> To fix this what about the following:
>
> diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c
> index 94954c7..cb4fb78 100644
> --- a/net/bluetooth/sco.c
> +++ b/net/bluetooth/sco.c
> @@ -373,7 +373,7 @@ static void __sco_sock_close(struct sock *sk)
> sk->sk_state = BT_DISCONN;
> sco_sock_set_timer(sk, SCO_DISCONN_TIMEOUT);
> hci_conn_put(sco_pi(sk)->conn->hcon);
> - sco_pi(sk)->conn = NULL;
> + sco_pi(sk)->conn->hcon = NULL;
> } else
> sco_chan_del(sk, ECONNRESET);
> break;
> @@ -828,7 +828,9 @@ static void sco_chan_del(struct sock *sk, int err)
> conn->sk = NULL;
> sco_pi(sk)->conn = NULL;
> sco_conn_unlock(conn);
> - hci_conn_put(conn->hcon);
> +
> + if (conn->hcon)
> + hci_conn_put(conn->hcon);
I think first we need to revert the patch on linus' tree. There isn't time to
a proper fix and test. It may have introduced other bugs too. I don't wanna
take this risk.
--
Gustavo F. Padovan
http://profusion.mobi
next prev parent reply other threads:[~2011-05-11 17:09 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-08 14:10 [PATCH] bluetooth: fix shutdown on SCO sockets Luiz Augusto von Dentz
2011-04-15 18:58 ` Gustavo F. Padovan
2011-04-17 17:26 ` Luiz Augusto von Dentz
2011-04-18 17:56 ` Gustavo F. Padovan
2011-05-05 14:50 ` Luiz Augusto von Dentz
2011-05-11 17:09 ` Gustavo F. Padovan [this message]
2011-05-11 20:49 ` Luiz Augusto von Dentz
2011-05-11 20:52 ` Gustavo F. Padovan
-- strict thread matches above, loose matches on Subject: below --
2011-05-12 8:13 Luiz Augusto von Dentz
2011-05-19 22:27 ` Gustavo F. Padovan
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=20110511170951.GB22065@joana \
--to=padovan@profusion.mobi \
--cc=linux-bluetooth@vger.kernel.org \
--cc=luiz.dentz@gmail.com \
/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;
as well as URLs for NNTP newsgroup(s).