public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: syzbot <syzbot+479aff51bb361ef5aa18@syzkaller.appspotmail.com>
To: linux-kernel@vger.kernel.org, mazin@getstate.dev,
	 syzkaller-bugs@googlegroups.com
Subject: Re: [syzbot] [bluetooth?] KASAN: slab-use-after-free Read in mgmt_remove_adv_monitor_sync
Date: Thu, 05 Dec 2024 06:10:03 -0800	[thread overview]
Message-ID: <6751b43b.050a0220.b4160.01d5.GAE@google.com> (raw)
In-Reply-To: <D63TE6HWP7IF.2VGLGANFA6OGW@getstate.dev>

Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
possible deadlock in hci_dev_close

======================================================
WARNING: possible circular locking dependency detected
6.13.0-rc1-syzkaller-00025-gfeffde684ac2-dirty #0 Not tainted
------------------------------------------------------
syz.1.2844/12457 is trying to acquire lock:
ffff88805c0a45f0 ((work_completion)(&hdev->cmd_sync_work)){+.+.}-{0:0}, at: rcu_lock_acquire include/linux/rcupdate.h:337 [inline]
ffff88805c0a45f0 ((work_completion)(&hdev->cmd_sync_work)){+.+.}-{0:0}, at: rcu_read_lock include/linux/rcupdate.h:849 [inline]
ffff88805c0a45f0 ((work_completion)(&hdev->cmd_sync_work)){+.+.}-{0:0}, at: start_flush_work kernel/workqueue.c:4137 [inline]
ffff88805c0a45f0 ((work_completion)(&hdev->cmd_sync_work)){+.+.}-{0:0}, at: __flush_work+0xe7/0xc50 kernel/workqueue.c:4195

but task is already holding lock:
ffff88805c0a4d80 (&hdev->req_lock){+.+.}-{4:4}, at: hci_dev_do_close net/bluetooth/hci_core.c:481 [inline]
ffff88805c0a4d80 (&hdev->req_lock){+.+.}-{4:4}, at: hci_dev_close+0x10a/0x210 net/bluetooth/hci_core.c:508

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #1 (&hdev->req_lock){+.+.}-{4:4}:
       lock_acquire+0x1ed/0x550 kernel/locking/lockdep.c:5849
       __mutex_lock_common kernel/locking/mutex.c:585 [inline]
       __mutex_lock+0x1ac/0xee0 kernel/locking/mutex.c:735
       hci_cmd_sync_work+0x1ec/0x400 net/bluetooth/hci_sync.c:331
       process_one_work kernel/workqueue.c:3229 [inline]
       process_scheduled_works+0xa66/0x1840 kernel/workqueue.c:3310
       worker_thread+0x870/0xd30 kernel/workqueue.c:3391
       kthread+0x2f0/0x390 kernel/kthread.c:389
       ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:147
       ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244

-> #0 ((work_completion)(&hdev->cmd_sync_work)){+.+.}-{0:0}:
       check_prev_add kernel/locking/lockdep.c:3161 [inline]
       check_prevs_add kernel/locking/lockdep.c:3280 [inline]
       validate_chain+0x18ef/0x5920 kernel/locking/lockdep.c:3904
       __lock_acquire+0x1397/0x2100 kernel/locking/lockdep.c:5226
       lock_acquire+0x1ed/0x550 kernel/locking/lockdep.c:5849
       touch_work_lockdep_map kernel/workqueue.c:3909 [inline]
       start_flush_work kernel/workqueue.c:4163 [inline]
       __flush_work+0x74e/0xc50 kernel/workqueue.c:4195
       __cancel_work_sync+0xbc/0x110 kernel/workqueue.c:4351
       hci_cmd_sync_clear+0x30/0x220 net/bluetooth/hci_sync.c:655
       hci_dev_close_sync+0x5cc/0x11d0 net/bluetooth/hci_sync.c:5202
       hci_dev_do_close net/bluetooth/hci_core.c:483 [inline]
       hci_dev_close+0x112/0x210 net/bluetooth/hci_core.c:508
       sock_do_ioctl+0x158/0x460 net/socket.c:1209
       sock_ioctl+0x626/0x8e0 net/socket.c:1328
       vfs_ioctl fs/ioctl.c:51 [inline]
       __do_sys_ioctl fs/ioctl.c:906 [inline]
       __se_sys_ioctl+0xf5/0x170 fs/ioctl.c:892
       do_syscall_x64 arch/x86/entry/common.c:52 [inline]
       do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

other info that might help us debug this:

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&hdev->req_lock);
                               lock((work_completion)(&hdev->cmd_sync_work));
                               lock(&hdev->req_lock);
  lock((work_completion)(&hdev->cmd_sync_work));

 *** DEADLOCK ***

2 locks held by syz.1.2844/12457:
 #0: ffff88805c0a4d80 (&hdev->req_lock){+.+.}-{4:4}, at: hci_dev_do_close net/bluetooth/hci_core.c:481 [inline]
 #0: ffff88805c0a4d80 (&hdev->req_lock){+.+.}-{4:4}, at: hci_dev_close+0x10a/0x210 net/bluetooth/hci_core.c:508
 #1: ffffffff8e937aa0 (rcu_read_lock){....}-{1:3}, at: rcu_lock_acquire include/linux/rcupdate.h:337 [inline]
 #1: ffffffff8e937aa0 (rcu_read_lock){....}-{1:3}, at: rcu_read_lock include/linux/rcupdate.h:849 [inline]
 #1: ffffffff8e937aa0 (rcu_read_lock){....}-{1:3}, at: start_flush_work kernel/workqueue.c:4137 [inline]
 #1: ffffffff8e937aa0 (rcu_read_lock){....}-{1:3}, at: __flush_work+0xe7/0xc50 kernel/workqueue.c:4195

stack backtrace:
CPU: 1 UID: 0 PID: 12457 Comm: syz.1.2844 Not tainted 6.13.0-rc1-syzkaller-00025-gfeffde684ac2-dirty #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/2024
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:94 [inline]
 dump_stack_lvl+0x241/0x360 lib/dump_stack.c:120
 print_circular_bug+0x13a/0x1b0 kernel/locking/lockdep.c:2074
 check_noncircular+0x36a/0x4a0 kernel/locking/lockdep.c:2206
 check_prev_add kernel/locking/lockdep.c:3161 [inline]
 check_prevs_add kernel/locking/lockdep.c:3280 [inline]
 validate_chain+0x18ef/0x5920 kernel/locking/lockdep.c:3904
 __lock_acquire+0x1397/0x2100 kernel/locking/lockdep.c:5226
 lock_acquire+0x1ed/0x550 kernel/locking/lockdep.c:5849
 touch_work_lockdep_map kernel/workqueue.c:3909 [inline]
 start_flush_work kernel/workqueue.c:4163 [inline]
 __flush_work+0x74e/0xc50 kernel/workqueue.c:4195
 __cancel_work_sync+0xbc/0x110 kernel/workqueue.c:4351
 hci_cmd_sync_clear+0x30/0x220 net/bluetooth/hci_sync.c:655
 hci_dev_close_sync+0x5cc/0x11d0 net/bluetooth/hci_sync.c:5202
 hci_dev_do_close net/bluetooth/hci_core.c:483 [inline]
 hci_dev_close+0x112/0x210 net/bluetooth/hci_core.c:508
 sock_do_ioctl+0x158/0x460 net/socket.c:1209
 sock_ioctl+0x626/0x8e0 net/socket.c:1328
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:906 [inline]
 __se_sys_ioctl+0xf5/0x170 fs/ioctl.c:892
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f4dbc580849
Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 a8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f4dbd304058 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007f4dbc745fa0 RCX: 00007f4dbc580849
RDX: 0000000000000000 RSI: 00000000400448ca RDI: 0000000000000004
RBP: 00007f4dbc5f3986 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 00007f4dbc745fa0 R15: 00007ffd637354e8
 </TASK>


Tested on:

commit:         feffde68 Merge tag 'for-6.13-rc1-tag' of git://git.ker..
git tree:       upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=158da8df980000
kernel config:  https://syzkaller.appspot.com/x/.config?x=50c7a61469ce77e7
dashboard link: https://syzkaller.appspot.com/bug?extid=479aff51bb361ef5aa18
compiler:       Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
patch:          https://syzkaller.appspot.com/x/patch.diff?x=1315a8df980000


  reply	other threads:[~2024-12-05 14:10 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <D63E89JWB8QV.38E70BVWNMMVL@getstate.dev>
2024-12-05  2:24 ` [syzbot] [bluetooth?] KASAN: slab-use-after-free Read in mgmt_remove_adv_monitor_sync syzbot
2024-12-05  2:43   ` Mazin Alhaddad
2024-12-05  3:06     ` syzbot
2024-12-05  8:36       ` [PATCH] [PATCH] TEST Pei Xiao
2024-12-05  8:50         ` Aleksandr Nogikh
2024-12-05  9:47           ` Pei Xiao
2024-12-05 11:38       ` [syzbot] [bluetooth?] KASAN: slab-use-after-free Read in mgmt_remove_adv_monitor_sync Mazin Alhaddad
2024-12-05 12:04         ` syzbot
2024-12-05 12:18           ` Mazin Alhaddad
2024-12-05 12:39             ` syzbot
2024-12-05 12:20           ` Mazin Alhaddad
2024-12-05 12:48             ` syzbot
2024-12-05 13:01               ` Mazin Alhaddad
2024-12-05 13:44                 ` syzbot
2024-12-05 13:51                   ` Mazin Alhaddad
2024-12-05 14:10                     ` syzbot [this message]
2024-12-05 14:26                       ` Mazin Alhaddad
2024-12-05 15:06                         ` syzbot
2024-12-05 15:51                           ` Mazin Alhaddad
2024-12-05 16:42                             ` syzbot
2024-12-08 15:56                               ` Mazin Alhaddad
2024-12-08 16:41                                 ` syzbot
2024-12-08 18:24                                   ` Mazin Alhaddad
2024-12-08 18:47                                     ` syzbot
2024-12-08 19:12                                     ` Mazin Alhaddad
2024-12-08 21:42                                       ` syzbot
2024-12-08 21:44                                         ` Mazin Alhaddad
2024-12-08 22:06                                           ` syzbot
     [not found] <D6JFGS83KL11.2PX1Q2EA60PMZ@getstate.dev>
2024-12-23 22:43 ` syzbot
2024-12-05  9:45 [patch] test Pei Xiao
2024-12-05  9:55 ` [syzbot] [bluetooth?] KASAN: slab-use-after-free Read in mgmt_remove_adv_monitor_sync syzbot
  -- strict thread matches above, loose matches on Subject: below --
2024-12-05  9:30 [PATCH] test Pei Xiao
2024-12-05  9:38 ` [syzbot] [bluetooth?] KASAN: slab-use-after-free Read in mgmt_remove_adv_monitor_sync syzbot
     [not found] <de7743c9-1fd1-4dc3-9ed4-31c32a9118eb@kylinos.cn>
2024-12-05  9:13 ` syzbot
2024-07-24  8:59 syzbot
2024-11-28  6:53 ` syzbot

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=6751b43b.050a0220.b4160.01d5.GAE@google.com \
    --to=syzbot+479aff51bb361ef5aa18@syzkaller.appspotmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mazin@getstate.dev \
    --cc=syzkaller-bugs@googlegroups.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