Dave Jones 4721953
From 2a5a5ec620a29d4ba07743c3151cdf0a417c8f8c Mon Sep 17 00:00:00 2001
Dave Jones 4721953
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Dave Jones 4721953
Date: Thu, 2 Feb 2012 10:32:18 +0200
Dave Jones 4721953
Subject: [PATCH] Bluetooth: Use list _safe deleting from conn chan_list
Dave Jones 4721953
Dave Jones 4721953
Fixes possible bug when deleting element from the list in
Dave Jones 4721953
function hci_chan_list_flush. list_for_each_entry_rcu is used
Dave Jones 4721953
and after deleting element from the list we also free pointer
Dave Jones 4721953
and then list_entry_rcu is taken from freed pointer.
Dave Jones 4721953
Dave Jones 4721953
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Dave Jones 4721953
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Dave Jones 4721953
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Dave Jones 4721953
---
Dave Jones 4721953
 net/bluetooth/hci_conn.c |    4 ++--
Dave Jones 4721953
 1 files changed, 2 insertions(+), 2 deletions(-)
Dave Jones 4721953
Dave Jones 4721953
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
Dave Jones 4721953
index b074bd6..b4ecdde 100644
Dave Jones 4721953
--- a/net/bluetooth/hci_conn.c
Dave Jones 4721953
+++ b/net/bluetooth/hci_conn.c
Dave Jones 4721953
@@ -975,10 +975,10 @@ int hci_chan_del(struct hci_chan *chan)
Dave Jones 4721953
 
Dave Jones 4721953
 void hci_chan_list_flush(struct hci_conn *conn)
Dave Jones 4721953
 {
Dave Jones 4721953
-	struct hci_chan *chan;
Dave Jones 4721953
+	struct hci_chan *chan, *n;
Dave Jones 4721953
 
Dave Jones 4721953
 	BT_DBG("conn %p", conn);
Dave Jones 4721953
 
Dave Jones 4721953
-	list_for_each_entry_rcu(chan, &conn->chan_list, list)
Dave Jones 4721953
+	list_for_each_entry_safe(chan, n, &conn->chan_list, list)
Dave Jones 4721953
 		hci_chan_del(chan);
Dave Jones 4721953
 }
Dave Jones 4721953
-- 
Dave Jones 4721953
1.7.6.5
Dave Jones 4721953
Dave Jones 4721953
From 3c4e0df028935618d052235ba85bc7079be13394 Mon Sep 17 00:00:00 2001
Dave Jones 4721953
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Dave Jones 4721953
Date: Thu, 2 Feb 2012 10:32:17 +0200
Dave Jones 4721953
Subject: [PATCH] Bluetooth: Use list _safe deleting from conn_hash_list
Dave Jones 4721953
Dave Jones 4721953
Use list_for_each_entry_safe which is safe version against removal
Dave Jones 4721953
of list entry. Otherwise we remove hci_conn element and reference
Dave Jones 4721953
next element which result in accessing LIST_POISON.
Dave Jones 4721953
Dave Jones 4721953
[   95.571834] Bluetooth: unknown link type 127
Dave Jones 4721953
[   95.578349] BUG: unable to handle kernel paging request at 20002000
Dave Jones 4721953
[   95.580236] IP: [<20002000>] 0x20001fff
Dave Jones 4721953
[   95.580763] *pde = 00000000
Dave Jones 4721953
[   95.581196] Oops: 0000 [#1] SMP
Dave Jones 4721953
...
Dave Jones 4721953
[   95.582298] Pid: 3355, comm: hciconfig Tainted: G   O 3.2.0-VirttualBox
Dave Jones 4721953
[   95.582298] EIP: 0060:[<20002000>] EFLAGS: 00210206 CPU: 0
Dave Jones 4721953
[   95.582298] EIP is at 0x20002000
Dave Jones 4721953
...
Dave Jones 4721953
[   95.582298] Call Trace:
Dave Jones 4721953
[   95.582298]  [<f8231ab6>] ? hci_conn_hash_flush+0x76/0xf0 [bluetooth]
Dave Jones 4721953
[   95.582298]  [<f822bcb1>] hci_dev_do_close+0xc1/0x2e0 [bluetooth]
Dave Jones 4721953
[   95.582298]  [<f822d679>] ? hci_dev_get+0x69/0xb0 [bluetooth]
Dave Jones 4721953
[   95.582298]  [<f822e1da>] hci_dev_close+0x2a/0x50 [bluetooth]
Dave Jones 4721953
[   95.582298]  [<f824102f>] hci_sock_ioctl+0x1af/0x3f0 [bluetooth]
Dave Jones 4721953
[   95.582298]  [<c11153ea>] ? handle_pte_fault+0x8a/0x8f0
Dave Jones 4721953
[   95.582298]  [<c146becf>] sock_ioctl+0x5f/0x260
Dave Jones 4721953
[   95.582298]  [<c146be70>] ? sock_fasync+0x90/0x90
Dave Jones 4721953
[   95.582298]  [<c1152b33>] do_vfs_ioctl+0x83/0x5b0
Dave Jones 4721953
[   95.582298]  [<c1563f87>] ? do_page_fault+0x297/0x500
Dave Jones 4721953
[   95.582298]  [<c1563cf0>] ? spurious_fault+0xd0/0xd0
Dave Jones 4721953
[   95.582298]  [<c107165b>] ? up_read+0x1b/0x30
Dave Jones 4721953
[   95.582298]  [<c1563f87>] ? do_page_fault+0x297/0x500
Dave Jones 4721953
[   95.582298]  [<c100aa9f>] ? init_fpu+0xef/0x160
Dave Jones 4721953
[   95.582298]  [<c15617c0>] ? do_debug+0x180/0x180
Dave Jones 4721953
[   95.582298]  [<c100a958>] ? fpu_finit+0x28/0x80
Dave Jones 4721953
[   95.582298]  [<c11530e7>] sys_ioctl+0x87/0x90
Dave Jones 4721953
[   95.582298]  [<c156795f>] sysenter_do_call+0x12/0x38
Dave Jones 4721953
...
Dave Jones 4721953
Dave Jones 4721953
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Dave Jones 4721953
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Dave Jones 4721953
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Dave Jones 4721953
---
Dave Jones 4721953
 net/bluetooth/hci_conn.c |    4 ++--
Dave Jones 4721953
 1 files changed, 2 insertions(+), 2 deletions(-)
Dave Jones 4721953
Dave Jones 4721953
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
Dave Jones 4721953
index aca71c0..b074bd6 100644
Dave Jones 4721953
--- a/net/bluetooth/hci_conn.c
Dave Jones 4721953
+++ b/net/bluetooth/hci_conn.c
Dave Jones 4721953
@@ -795,11 +795,11 @@ timer:
Dave Jones 4721953
 void hci_conn_hash_flush(struct hci_dev *hdev)
Dave Jones 4721953
 {
Dave Jones 4721953
 	struct hci_conn_hash *h = &hdev->conn_hash;
Dave Jones 4721953
-	struct hci_conn *c;
Dave Jones 4721953
+	struct hci_conn *c, *n;
Dave Jones 4721953
 
Dave Jones 4721953
 	BT_DBG("hdev %s", hdev->name);
Dave Jones 4721953
 
Dave Jones 4721953
-	list_for_each_entry_rcu(c, &h->list, list) {
Dave Jones 4721953
+	list_for_each_entry_safe(c, n, &h->list, list) {
Dave Jones 4721953
 		c->state = BT_CLOSED;
Dave Jones 4721953
 
Dave Jones 4721953
 		hci_proto_disconn_cfm(c, HCI_ERROR_LOCAL_HOST_TERM);
Dave Jones 4721953
-- 
Dave Jones 4721953
1.7.6.5
Dave Jones 4721953