general protection fault in l2cap_chan_timeout

17 views
Skip to first unread message

syzbot

unread,
Nov 30, 2020, 1:30:18 AM11/30/20
to da...@davemloft.net, johan....@gmail.com, ku...@kernel.org, linux-b...@vger.kernel.org, linux-...@vger.kernel.org, mar...@holtmann.org, net...@vger.kernel.org, syzkall...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: fa02fcd9 Merge tag 'media/v5.10-2' of git://git.kernel.org..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=14a36fa5500000
kernel config: https://syzkaller.appspot.com/x/.config?x=7be70951fca93701
dashboard link: https://syzkaller.appspot.com/bug?extid=e7edf1d784c283324076
compiler: clang version 11.0.0 (https://github.com/llvm/llvm-project.git ca2dcbd030eadbf0aa9b660efe864ff08af6e18b)

Unfortunately, I don't have any reproducer for this issue yet.

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+e7edf1...@syzkaller.appspotmail.com

general protection fault, probably for non-canonical address 0xdffffc000000005a: 0000 [#1] PREEMPT SMP KASAN
KASAN: null-ptr-deref in range [0x00000000000002d0-0x00000000000002d7]
CPU: 1 PID: 16756 Comm: kworker/1:8 Not tainted 5.10.0-rc5-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Workqueue: events l2cap_chan_timeout
RIP: 0010:__mutex_lock_common+0x9b/0x2f20 kernel/locking/mutex.c:938
Code: 8a bc 24 28 01 00 00 83 3d 01 69 0f 06 00 75 34 48 8b 44 24 08 48 8d 78 60 48 89 f8 48 c1 e8 03 48 b9 00 00 00 00 00 fc ff df <80> 3c 08 00 74 05 e8 ba 7f 77 f8 48 8b 44 24 08 48 39 40 60 0f 85
RSP: 0018:ffffc9000245fb78 EFLAGS: 00010206
RAX: 000000000000005a RBX: ffff8880708d8110 RCX: dffffc0000000000
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 00000000000002d0
RBP: 0000000000000000 R08: ffffffff8876a063 R09: 0000000000000000
R10: fffffbfff1a1c3ee R11: 0000000000000000 R12: 0000000000000000
R13: dffffc0000000000 R14: 0000000000000000 R15: ffff8880b9d33c00
FS: 0000000000000000(0000) GS:ffff8880b9d00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007ffde459fd3c CR3: 00000000186a5000 CR4: 00000000001506e0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
__mutex_lock kernel/locking/mutex.c:1103 [inline]
mutex_lock_nested+0x1a/0x20 kernel/locking/mutex.c:1118
l2cap_chan_timeout+0x53/0x280 net/bluetooth/l2cap_core.c:422
process_one_work+0x789/0xfc0 kernel/workqueue.c:2272
worker_thread+0xaa4/0x1460 kernel/workqueue.c:2418
kthread+0x39a/0x3c0 kernel/kthread.c:292
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:296
Modules linked in:
---[ end trace c01f537d4b85904a ]---
RIP: 0010:__mutex_lock_common+0x9b/0x2f20 kernel/locking/mutex.c:938
Code: 8a bc 24 28 01 00 00 83 3d 01 69 0f 06 00 75 34 48 8b 44 24 08 48 8d 78 60 48 89 f8 48 c1 e8 03 48 b9 00 00 00 00 00 fc ff df <80> 3c 08 00 74 05 e8 ba 7f 77 f8 48 8b 44 24 08 48 39 40 60 0f 85
RSP: 0018:ffffc9000245fb78 EFLAGS: 00010206
RAX: 000000000000005a RBX: ffff8880708d8110 RCX: dffffc0000000000
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 00000000000002d0
RBP: 0000000000000000 R08: ffffffff8876a063 R09: 0000000000000000
R10: fffffbfff1a1c3ee R11: 0000000000000000 R12: 0000000000000000
R13: dffffc0000000000 R14: 0000000000000000 R15: ffff8880b9d33c00
FS: 0000000000000000(0000) GS:ffff8880b9d00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007fbbcfa32740 CR3: 000000006d47f000 CR4: 00000000001506e0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400


---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzk...@googlegroups.com.

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.

Hillf Danton

unread,
Nov 30, 2020, 4:55:55 AM11/30/20
to syzbot, da...@davemloft.net, johan....@gmail.com, ku...@kernel.org, linux-b...@vger.kernel.org, linux-...@vger.kernel.org, mar...@holtmann.org, net...@vger.kernel.org, syzkall...@googlegroups.com
On Sun, 29 Nov 2020 22:30:17 -0800
Flush chan->chan_timer before killing chan.

--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -1881,6 +1881,30 @@ static void l2cap_conn_del(struct hci_co
hcon->disc_timeout = 0;

mutex_lock(&conn->chan_lock);
+ l = NULL;
+ while (!list_empty(&conn->chan_l)) {
+ chan = list_first_entry(&conn->chan_l, struct l2cap_chan, list);
+ if (!l)
+ l = chan;
+ else if (l == chan)
+ break;
+
+ list_move_tail(&chan->list, &conn->chan_l);
+ l2cap_chan_hold(chan);
+ /*
+ * l2cap_chan_del(chan, err);
+ * __clear_chan_timer(chan);
+ * l2cap_clear_timer(c, &c->chan_timer);
+ * cancel_delayed_work(work);
+ *
+ * we dont flush work under conn->chan_lock otherwise
+ * we see deadlock; do it now.
+ */
+ mutex_unlock(&conn->chan_lock);
+ cancel_delayed_work_sync(&chan->chan_timer);
+ l2cap_chan_put(chan);
+ mutex_lock(&conn->chan_lock);
+ }

/* Kill channels */
list_for_each_entry_safe(chan, l, &conn->chan_l, list) {

Hillf Danton

unread,
Dec 1, 2020, 3:28:24 AM12/1/20
to syzbot, da...@davemloft.net, johan....@gmail.com, ku...@kernel.org, linux-b...@vger.kernel.org, linux-...@vger.kernel.org, mar...@holtmann.org, net...@vger.kernel.org, syzkall...@googlegroups.com
On Sun, 29 Nov 2020 22:30:17 -0800
Flush the chan->chan_timer delayed work before putting conn.

--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -624,8 +624,6 @@ void l2cap_chan_del(struct l2cap_chan *c

l2cap_chan_put(chan);

- chan->conn = NULL;
-
/* Reference was only held for non-fixed channels or
* fixed channels that explicitly requested it using the
* FLAG_HOLD_HCI_CONN flag.
@@ -1855,6 +1853,7 @@ static void l2cap_conn_del(struct hci_co
{
struct l2cap_conn *conn = hcon->l2cap_data;
struct l2cap_chan *chan, *l;
+ LIST_HEAD(channels);

if (!conn)
return;
@@ -1890,13 +1889,27 @@ static void l2cap_conn_del(struct hci_co
l2cap_chan_del(chan, err);

chan->ops->close(chan);
-
l2cap_chan_unlock(chan);
- l2cap_chan_put(chan);
+ /*
+ * l2cap_chan_del(chan, err);
+ * __clear_chan_timer(chan);
+ * l2cap_clear_timer(c, &c->chan_timer);
+ * cancel_delayed_work(work);
+ *
+ * we dont flush work under conn->chan_lock otherwise
+ * we may see deadlock; just add chan to the todo list
+ * and flush them a couple of lines down.
+ */
+ list_add_tail(&chan->list, &channels);
}

mutex_unlock(&conn->chan_lock);

+ list_for_each_entry_safe(chan, l, &channels, list) {
+ list_del(&chan->list);
+ flush_delayed_work(&chan->chan_timer);
+ l2cap_chan_put(chan);
+ }
hci_chan_del(conn->hchan);

if (conn->info_state & L2CAP_INFO_FEAT_MASK_REQ_SENT)

syzbot

unread,
Mar 25, 2021, 7:40:19 PM3/25/21
to syzkall...@googlegroups.com
Auto-closing this bug as obsolete.
Crashes did not happen for a while, no reproducer and no activity.
Reply all
Reply to author
Forward
0 new messages