[PATCH] Bluetooth: Fix use after free in l2cap_chan_timeout

Subsystems: bluetooth subsystem, the rest

STALE4160d

2 messages, 2 authors, 2015-03-19 · open the first message on its own page

[PATCH] Bluetooth: Fix use after free in l2cap_chan_timeout

From: Harish Jenny K N <hidden>
Date: 2015-03-19 08:20:00

There is a potential use after free in bt_sock_poll when a
socket gets killed without getting unlinked from accept_q.
Hence added code to unlink from accpept_q by calling teardown
before freeing the socket for channel type L2CAP_CHAN_CONN_ORIENTED.

Signed-off-by: Harish Jenny K N <redacted>
---
 net/bluetooth/l2cap_core.c |    5 +++++
 1 file changed, 5 insertions(+)
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 6ba33f9..c6955fb 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -415,6 +415,11 @@ static void l2cap_chan_timeout(struct work_struct *work)
 
 	l2cap_chan_close(chan, reason);
 
+	if ((chan->state == BT_CONNECTED || chan->state == BT_CONFIG) &&
+	    chan->chan_type == L2CAP_CHAN_CONN_ORIENTED) {
+		chan->ops->teardown(chan, 0);
+	}
+
 	l2cap_chan_unlock(chan);
 
 	chan->ops->close(chan);
-- 
1.7.9.5

Re: [PATCH] Bluetooth: Fix use after free in l2cap_chan_timeout

From: Sergei Shtylyov <hidden>
Date: 2015-03-19 14:59:22

Hello.

On 3/19/2015 11:19 AM, Harish Jenny K N wrote:
There is a potential use after free in bt_sock_poll when a
socket gets killed without getting unlinked from accept_q.
Hence added code to unlink from accpept_q by calling teardown
before freeing the socket for channel type L2CAP_CHAN_CONN_ORIENTED.
Signed-off-by: Harish Jenny K N <redacted>
---
  net/bluetooth/l2cap_core.c |    5 +++++
  1 file changed, 5 insertions(+)
quoted hunk
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 6ba33f9..c6955fb 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -415,6 +415,11 @@ static void l2cap_chan_timeout(struct work_struct *work)

  	l2cap_chan_close(chan, reason);

+	if ((chan->state == BT_CONNECTED || chan->state == BT_CONFIG) &&
+	    chan->chan_type == L2CAP_CHAN_CONN_ORIENTED) {
+		chan->ops->teardown(chan, 0);
+	}
+
    {} not needed here.

[...]

WBR, Sergei
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help