public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Hillf Danton <hdanton@sina.com>
To: syzbot <syzbot+cc0cc52e7f43dc9e6df1@syzkaller.appspotmail.com>
Cc: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com
Subject: Re: [syzbot] [bluetooth?] BUG: corrupted list in mgmt_pending_remove
Date: Thu, 28 Nov 2024 19:11:01 +0800	[thread overview]
Message-ID: <20241128111101.1788-1-hdanton@sina.com> (raw)
In-Reply-To: <67482f4a.050a0220.253251.0078.GAE@google.com>

On Thu, 28 Nov 2024 00:52:26 -0800
> syzbot has found a reproducer for the following issue on:
> 
> HEAD commit:    5dfd7d940094 Merge branch 'bnxt_en-bug-fixes'
> git tree:       net
> C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=10c5ef5f980000

#stz test

--- x/net/bluetooth/hci_sync.c
+++ y/net/bluetooth/hci_sync.c
@@ -308,6 +308,7 @@ static void hci_cmd_sync_work(struct wor
 
 	bt_dev_dbg(hdev, "");
 
+	hci_req_sync_lock(hdev);
 	/* Dequeue all entries and run them */
 	while (1) {
 		struct hci_cmd_sync_work_entry *entry;
@@ -328,15 +329,14 @@ static void hci_cmd_sync_work(struct wor
 		if (entry->func) {
 			int err;
 
-			hci_req_sync_lock(hdev);
 			err = entry->func(hdev, entry->data);
 			if (entry->destroy)
 				entry->destroy(hdev, entry->data, err);
-			hci_req_sync_unlock(hdev);
 		}
 
 		kfree(entry);
 	}
+	hci_req_sync_unlock(hdev);
 }
 
 static void hci_cmd_sync_cancel_work(struct work_struct *work)
@@ -5192,6 +5192,15 @@ int hci_dev_close_sync(struct hci_dev *h
 			cancel_delayed_work_sync(&adv_instance->rpa_expired_cb);
 	}
 
+	do {
+		struct hci_cmd_sync_work_entry *entry, *tmp;
+
+		mutex_lock(&hdev->cmd_sync_work_lock);
+		list_for_each_entry_safe(entry, tmp, &hdev->cmd_sync_work_list, list)
+			_hci_cmd_sync_cancel_entry(hdev, entry, -ECANCELED);
+		mutex_unlock(&hdev->cmd_sync_work_lock);
+	} while (0);
+
 	/* Avoid potential lockdep warnings from the *_flush() calls by
 	 * ensuring the workqueue is empty up front.
 	 */
--

  reply	other threads:[~2024-11-28 11:11 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-01  8:24 [syzbot] [bluetooth?] BUG: corrupted list in mgmt_pending_remove syzbot
2024-11-28  8:52 ` syzbot
2024-11-28 11:11   ` Hillf Danton [this message]
2025-05-23  8:22 ` [syzbot] #syz test https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 94305e83eccb3120c921cd3a015cd74731140bac syzbot
2025-05-28 20:33 ` [syzbot] Re: [PATCH v1] Bluetooth: MGMT: Use RCU-protected in mgmt_pending list syzbot
2025-06-02 18:02 ` [syzbot] Re: [PATCH v3] Bluetooth: MGMT: Protect mgmt_pending list with its own lock syzbot
     [not found] <e9b691c9-f3b9-4bcb-841f-771b24281ecf@yandex.ru>
2025-05-23  9:35 ` [syzbot] [bluetooth?] BUG: corrupted list in mgmt_pending_remove syzbot
     [not found] <CABBYNZJn9-u_w5OWKL0+F6zFTs8JQJLuC8f-FTRQiBgY2w6EBw@mail.gmail.com>
2025-05-28 21:05 ` syzbot
     [not found] <CABBYNZ+kXi5iRrJN3UuK2ddQW49jHUwRQToEZ2fphEJRiVA4jQ@mail.gmail.com>
2025-06-02 19:06 ` 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=20241128111101.1788-1-hdanton@sina.com \
    --to=hdanton@sina.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=syzbot+cc0cc52e7f43dc9e6df1@syzkaller.appspotmail.com \
    --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