Linux bluetooth development
 help / color / mirror / Atom feed
* [syzbot] [bluetooth?] WARNING: bad unlock balance in l2cap_recv_frame
@ 2023-04-15 11:54 syzbot
  2023-04-17  2:27 ` [PATCH] Bluetooth: L2CAP: fix "bad unlock balance" in l2cap_disconnect_rsp Min Li
  2023-04-17  5:34 ` [syzbot] [bluetooth?] WARNING: bad unlock balance in l2cap_recv_frame Dmitry Vyukov
  0 siblings, 2 replies; 5+ messages in thread
From: syzbot @ 2023-04-15 11:54 UTC (permalink / raw)
  To: davem, edumazet, johan.hedberg, kuba, linux-bluetooth,
	linux-kernel, luiz.dentz, marcel, netdev, pabeni, syzkaller-bugs

Hello,

syzbot found the following issue on:

HEAD commit:    95abc817ab3a Merge tag 'acpi-6.3-rc7' of git://git.kernel...
git tree:       upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=13c85123c80000
kernel config:  https://syzkaller.appspot.com/x/.config?x=c21559e740385326
dashboard link: https://syzkaller.appspot.com/bug?extid=9519d6b5b79cf7787cf3
compiler:       gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2

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

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/87e400f90ed9/disk-95abc817.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/cf7aa6546e50/vmlinux-95abc817.xz
kernel image: https://storage.googleapis.com/syzbot-assets/a44d83ac79a7/bzImage-95abc817.xz

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

=====================================
WARNING: bad unlock balance detected!
6.3.0-rc6-syzkaller-00168-g95abc817ab3a #0 Not tainted
-------------------------------------
kworker/u5:7/5124 is trying to release lock (&conn->chan_lock) at:
[<ffffffff89148e14>] l2cap_disconnect_rsp net/bluetooth/l2cap_core.c:4697 [inline]
[<ffffffff89148e14>] l2cap_le_sig_cmd net/bluetooth/l2cap_core.c:6426 [inline]
[<ffffffff89148e14>] l2cap_le_sig_channel net/bluetooth/l2cap_core.c:6464 [inline]
[<ffffffff89148e14>] l2cap_recv_frame+0x85a4/0x9390 net/bluetooth/l2cap_core.c:7796
but there are no more locks to release!

other info that might help us debug this:
2 locks held by kworker/u5:7/5124:
 #0: ffff88801ecca938 ((wq_completion)hci1#2){+.+.}-{0:0}, at: arch_atomic64_set arch/x86/include/asm/atomic64_64.h:34 [inline]
 #0: ffff88801ecca938 ((wq_completion)hci1#2){+.+.}-{0:0}, at: arch_atomic_long_set include/linux/atomic/atomic-long.h:41 [inline]
 #0: ffff88801ecca938 ((wq_completion)hci1#2){+.+.}-{0:0}, at: atomic_long_set include/linux/atomic/atomic-instrumented.h:1280 [inline]
 #0: ffff88801ecca938 ((wq_completion)hci1#2){+.+.}-{0:0}, at: set_work_data kernel/workqueue.c:639 [inline]
 #0: ffff88801ecca938 ((wq_completion)hci1#2){+.+.}-{0:0}, at: set_work_pool_and_clear_pending kernel/workqueue.c:666 [inline]
 #0: ffff88801ecca938 ((wq_completion)hci1#2){+.+.}-{0:0}, at: process_one_work+0x87a/0x15c0 kernel/workqueue.c:2361
 #1: ffffc9000468fda8 ((work_completion)(&hdev->rx_work)){+.+.}-{0:0}, at: process_one_work+0x8ae/0x15c0 kernel/workqueue.c:2365

stack backtrace:
CPU: 1 PID: 5124 Comm: kworker/u5:7 Not tainted 6.3.0-rc6-syzkaller-00168-g95abc817ab3a #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/30/2023
Workqueue: hci1 hci_rx_work
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0xd9/0x150 lib/dump_stack.c:106
 __lock_release kernel/locking/lockdep.c:5346 [inline]
 lock_release+0x4f1/0x670 kernel/locking/lockdep.c:5689
 __mutex_unlock_slowpath+0x99/0x5e0 kernel/locking/mutex.c:907
 l2cap_disconnect_rsp net/bluetooth/l2cap_core.c:4697 [inline]
 l2cap_le_sig_cmd net/bluetooth/l2cap_core.c:6426 [inline]
 l2cap_le_sig_channel net/bluetooth/l2cap_core.c:6464 [inline]
 l2cap_recv_frame+0x85a4/0x9390 net/bluetooth/l2cap_core.c:7796
 l2cap_recv_acldata+0xa80/0xbf0 net/bluetooth/l2cap_core.c:8504
 hci_acldata_packet net/bluetooth/hci_core.c:3828 [inline]
 hci_rx_work+0x709/0x1340 net/bluetooth/hci_core.c:4063
 process_one_work+0x991/0x15c0 kernel/workqueue.c:2390
 worker_thread+0x669/0x1090 kernel/workqueue.c:2537
 kthread+0x2e8/0x3a0 kernel/kthread.c:376
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:308
 </TASK>


---
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 syzkaller@googlegroups.com.

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] Bluetooth: L2CAP: fix "bad unlock balance" in l2cap_disconnect_rsp
  2023-04-15 11:54 [syzbot] [bluetooth?] WARNING: bad unlock balance in l2cap_recv_frame syzbot
@ 2023-04-17  2:27 ` Min Li
  2023-04-17  3:06   ` bluez.test.bot
  2023-04-17 18:30   ` [PATCH] " patchwork-bot+bluetooth
  2023-04-17  5:34 ` [syzbot] [bluetooth?] WARNING: bad unlock balance in l2cap_recv_frame Dmitry Vyukov
  1 sibling, 2 replies; 5+ messages in thread
From: Min Li @ 2023-04-17  2:27 UTC (permalink / raw)
  To: syzbot+9519d6b5b79cf7787cf3
  Cc: davem, edumazet, johan.hedberg, kuba, linux-bluetooth,
	linux-kernel, luiz.dentz, marcel, netdev, pabeni, syzkaller-bugs,
	Min Li

conn->chan_lock isn't acquired before l2cap_get_chan_by_scid,
if l2cap_get_chan_by_scid returns NULL, then 'bad unlock balance'
is triggered.

Reported-by: syzbot+9519d6b5b79cf7787cf3@syzkaller.appspotmail.com
Link: https://lore.kernel.org/all/000000000000894f5f05f95e9f4d@google.com/
Signed-off-by: Min Li <lm0963hack@gmail.com>
---
 net/bluetooth/l2cap_core.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 55a7226233f9..24d075282996 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -4694,7 +4694,6 @@ static inline int l2cap_disconnect_rsp(struct l2cap_conn *conn,
 
 	chan = l2cap_get_chan_by_scid(conn, scid);
 	if (!chan) {
-		mutex_unlock(&conn->chan_lock);
 		return 0;
 	}
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* RE: Bluetooth: L2CAP: fix "bad unlock balance" in l2cap_disconnect_rsp
  2023-04-17  2:27 ` [PATCH] Bluetooth: L2CAP: fix "bad unlock balance" in l2cap_disconnect_rsp Min Li
@ 2023-04-17  3:06   ` bluez.test.bot
  2023-04-17 18:30   ` [PATCH] " patchwork-bot+bluetooth
  1 sibling, 0 replies; 5+ messages in thread
From: bluez.test.bot @ 2023-04-17  3:06 UTC (permalink / raw)
  To: linux-bluetooth, lm0963hack

[-- Attachment #1: Type: text/plain, Size: 1420 bytes --]

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=740288

---Test result---

Test Summary:
CheckPatch                    PASS      0.65 seconds
GitLint                       PASS      0.33 seconds
SubjectPrefix                 PASS      0.12 seconds
BuildKernel                   PASS      31.13 seconds
CheckAllWarning               PASS      34.38 seconds
CheckSparse                   PASS      38.65 seconds
CheckSmatch                   PASS      108.88 seconds
BuildKernel32                 PASS      30.23 seconds
TestRunnerSetup               PASS      430.89 seconds
TestRunner_l2cap-tester       PASS      16.20 seconds
TestRunner_iso-tester         PASS      19.26 seconds
TestRunner_bnep-tester        PASS      5.19 seconds
TestRunner_mgmt-tester        PASS      109.74 seconds
TestRunner_rfcomm-tester      PASS      8.39 seconds
TestRunner_sco-tester         PASS      7.82 seconds
TestRunner_ioctl-tester       PASS      8.98 seconds
TestRunner_mesh-tester        PASS      6.55 seconds
TestRunner_smp-tester         PASS      7.62 seconds
TestRunner_userchan-tester    PASS      5.47 seconds
IncrementalBuild              PASS      28.74 seconds



---
Regards,
Linux Bluetooth


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [syzbot] [bluetooth?] WARNING: bad unlock balance in l2cap_recv_frame
  2023-04-15 11:54 [syzbot] [bluetooth?] WARNING: bad unlock balance in l2cap_recv_frame syzbot
  2023-04-17  2:27 ` [PATCH] Bluetooth: L2CAP: fix "bad unlock balance" in l2cap_disconnect_rsp Min Li
@ 2023-04-17  5:34 ` Dmitry Vyukov
  1 sibling, 0 replies; 5+ messages in thread
From: Dmitry Vyukov @ 2023-04-17  5:34 UTC (permalink / raw)
  To: syzbot
  Cc: davem, edumazet, johan.hedberg, kuba, linux-bluetooth,
	linux-kernel, luiz.dentz, marcel, netdev, pabeni, syzkaller-bugs

On Sat, 15 Apr 2023 at 13:54, syzbot
<syzbot+9519d6b5b79cf7787cf3@syzkaller.appspotmail.com> wrote:
>
> Hello,
>
> syzbot found the following issue on:
>
> HEAD commit:    95abc817ab3a Merge tag 'acpi-6.3-rc7' of git://git.kernel...
> git tree:       upstream
> console output: https://syzkaller.appspot.com/x/log.txt?x=13c85123c80000
> kernel config:  https://syzkaller.appspot.com/x/.config?x=c21559e740385326
> dashboard link: https://syzkaller.appspot.com/bug?extid=9519d6b5b79cf7787cf3
> compiler:       gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2
>
> Unfortunately, I don't have any reproducer for this issue yet.
>
> Downloadable assets:
> disk image: https://storage.googleapis.com/syzbot-assets/87e400f90ed9/disk-95abc817.raw.xz
> vmlinux: https://storage.googleapis.com/syzbot-assets/cf7aa6546e50/vmlinux-95abc817.xz
> kernel image: https://storage.googleapis.com/syzbot-assets/a44d83ac79a7/bzImage-95abc817.xz
>
> IMPORTANT: if you fix the issue, please add the following tag to the commit:
> Reported-by: syzbot+9519d6b5b79cf7787cf3@syzkaller.appspotmail.com
>
> =====================================
> WARNING: bad unlock balance detected!
> 6.3.0-rc6-syzkaller-00168-g95abc817ab3a #0 Not tainted
> -------------------------------------
> kworker/u5:7/5124 is trying to release lock (&conn->chan_lock) at:
> [<ffffffff89148e14>] l2cap_disconnect_rsp net/bluetooth/l2cap_core.c:4697 [inline]
> [<ffffffff89148e14>] l2cap_le_sig_cmd net/bluetooth/l2cap_core.c:6426 [inline]
> [<ffffffff89148e14>] l2cap_le_sig_channel net/bluetooth/l2cap_core.c:6464 [inline]
> [<ffffffff89148e14>] l2cap_recv_frame+0x85a4/0x9390 net/bluetooth/l2cap_core.c:7796
> but there are no more locks to release!
>
> other info that might help us debug this:
> 2 locks held by kworker/u5:7/5124:
>  #0: ffff88801ecca938 ((wq_completion)hci1#2){+.+.}-{0:0}, at: arch_atomic64_set arch/x86/include/asm/atomic64_64.h:34 [inline]
>  #0: ffff88801ecca938 ((wq_completion)hci1#2){+.+.}-{0:0}, at: arch_atomic_long_set include/linux/atomic/atomic-long.h:41 [inline]
>  #0: ffff88801ecca938 ((wq_completion)hci1#2){+.+.}-{0:0}, at: atomic_long_set include/linux/atomic/atomic-instrumented.h:1280 [inline]
>  #0: ffff88801ecca938 ((wq_completion)hci1#2){+.+.}-{0:0}, at: set_work_data kernel/workqueue.c:639 [inline]
>  #0: ffff88801ecca938 ((wq_completion)hci1#2){+.+.}-{0:0}, at: set_work_pool_and_clear_pending kernel/workqueue.c:666 [inline]
>  #0: ffff88801ecca938 ((wq_completion)hci1#2){+.+.}-{0:0}, at: process_one_work+0x87a/0x15c0 kernel/workqueue.c:2361
>  #1: ffffc9000468fda8 ((work_completion)(&hdev->rx_work)){+.+.}-{0:0}, at: process_one_work+0x8ae/0x15c0 kernel/workqueue.c:2365
>
> stack backtrace:
> CPU: 1 PID: 5124 Comm: kworker/u5:7 Not tainted 6.3.0-rc6-syzkaller-00168-g95abc817ab3a #0
> Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/30/2023
> Workqueue: hci1 hci_rx_work
> Call Trace:
>  <TASK>
>  __dump_stack lib/dump_stack.c:88 [inline]
>  dump_stack_lvl+0xd9/0x150 lib/dump_stack.c:106
>  __lock_release kernel/locking/lockdep.c:5346 [inline]
>  lock_release+0x4f1/0x670 kernel/locking/lockdep.c:5689
>  __mutex_unlock_slowpath+0x99/0x5e0 kernel/locking/mutex.c:907
>  l2cap_disconnect_rsp net/bluetooth/l2cap_core.c:4697 [inline]
>  l2cap_le_sig_cmd net/bluetooth/l2cap_core.c:6426 [inline]
>  l2cap_le_sig_channel net/bluetooth/l2cap_core.c:6464 [inline]
>  l2cap_recv_frame+0x85a4/0x9390 net/bluetooth/l2cap_core.c:7796
>  l2cap_recv_acldata+0xa80/0xbf0 net/bluetooth/l2cap_core.c:8504
>  hci_acldata_packet net/bluetooth/hci_core.c:3828 [inline]
>  hci_rx_work+0x709/0x1340 net/bluetooth/hci_core.c:4063

/\/\/\/\/\/\/\/\

This is on the receiving path. Can this be triggered remotely?

>  process_one_work+0x991/0x15c0 kernel/workqueue.c:2390
>  worker_thread+0x669/0x1090 kernel/workqueue.c:2537
>  kthread+0x2e8/0x3a0 kernel/kthread.c:376
>  ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:308
>  </TASK>
>
>
> ---
> 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 syzkaller@googlegroups.com.
>
> syzbot will keep track of this issue. See:
> https://goo.gl/tpsmEJ#status for how to communicate with syzbot.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Bluetooth: L2CAP: fix "bad unlock balance" in l2cap_disconnect_rsp
  2023-04-17  2:27 ` [PATCH] Bluetooth: L2CAP: fix "bad unlock balance" in l2cap_disconnect_rsp Min Li
  2023-04-17  3:06   ` bluez.test.bot
@ 2023-04-17 18:30   ` patchwork-bot+bluetooth
  1 sibling, 0 replies; 5+ messages in thread
From: patchwork-bot+bluetooth @ 2023-04-17 18:30 UTC (permalink / raw)
  To: Min Li
  Cc: syzbot+9519d6b5b79cf7787cf3, davem, edumazet, johan.hedberg, kuba,
	linux-bluetooth, linux-kernel, luiz.dentz, marcel, netdev, pabeni,
	syzkaller-bugs

Hello:

This patch was applied to bluetooth/bluetooth-next.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:

On Mon, 17 Apr 2023 10:27:54 +0800 you wrote:
> conn->chan_lock isn't acquired before l2cap_get_chan_by_scid,
> if l2cap_get_chan_by_scid returns NULL, then 'bad unlock balance'
> is triggered.
> 
> Reported-by: syzbot+9519d6b5b79cf7787cf3@syzkaller.appspotmail.com
> Link: https://lore.kernel.org/all/000000000000894f5f05f95e9f4d@google.com/
> Signed-off-by: Min Li <lm0963hack@gmail.com>
> 
> [...]

Here is the summary with links:
  - Bluetooth: L2CAP: fix "bad unlock balance" in l2cap_disconnect_rsp
    https://git.kernel.org/bluetooth/bluetooth-next/c/ed62f7eeea0d

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-04-17 18:30 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-15 11:54 [syzbot] [bluetooth?] WARNING: bad unlock balance in l2cap_recv_frame syzbot
2023-04-17  2:27 ` [PATCH] Bluetooth: L2CAP: fix "bad unlock balance" in l2cap_disconnect_rsp Min Li
2023-04-17  3:06   ` bluez.test.bot
2023-04-17 18:30   ` [PATCH] " patchwork-bot+bluetooth
2023-04-17  5:34 ` [syzbot] [bluetooth?] WARNING: bad unlock balance in l2cap_recv_frame Dmitry Vyukov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox