public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Mazin Alhaddad" <mazin@getstate.dev>
To: "syzbot" <syzbot+479aff51bb361ef5aa18@syzkaller.appspotmail.com>,
	<linux-kernel@vger.kernel.org>, <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 15:20:10 +0300	[thread overview]
Message-ID: <D63RG2V1SJD8.3JVR47OT0IN39@getstate.dev> (raw)
In-Reply-To: <675196b3.050a0220.17bd51.009c.GAE@google.com>


[-- Attachment #1.1: Type: text/plain, Size: 84 bytes --]

#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master

[-- Attachment #2: 0001-TEST.patch --]
[-- Type: text/plain, Size: 2134 bytes --]

From 986f27666874745aad6b722cb77ceeacb6a62427 Mon Sep 17 00:00:00 2001
From: Mazin AlHaddad <mazin@getstate.dev>
Date: Thu, 5 Dec 2024 04:55:43 +0300
Subject: [PATCH] TEST

---
 net/bluetooth/hci_sync.c |  5 ++++-
 net/bluetooth/mgmt.c     | 18 +++++++++++++++---
 2 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c
index c86f4e42e..b89cad94f 100644
--- a/net/bluetooth/hci_sync.c
+++ b/net/bluetooth/hci_sync.c
@@ -5212,6 +5212,7 @@ int hci_dev_close_sync(struct hci_dev *hdev)
 	hci_conn_hash_flush(hdev);
 	/* Prevent data races on hdev->smp_data or hdev->smp_bredr_data */
 	smp_unregister(hdev);
+	hci_cmd_sync_clear(hdev);
 	hci_dev_unlock(hdev);
 
 	hci_sock_dev_event(hdev, HCI_DEV_DOWN);
@@ -5235,7 +5236,9 @@ int hci_dev_close_sync(struct hci_dev *hdev)
 	}
 
 	/* flush cmd  work */
-	flush_work(&hdev->cmd_work);
+	cancel_work_sync(&hdev->cmd_work);
+
+	
 
 	/* Drop queues */
 	skb_queue_purge(&hdev->rx_q);
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index b31192d47..cbf4fb1ff 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -5519,7 +5519,12 @@ static void mgmt_remove_adv_monitor_complete(struct hci_dev *hdev,
 {
 	struct mgmt_rp_remove_adv_monitor rp;
 	struct mgmt_pending_cmd *cmd = data;
-	struct mgmt_cp_remove_adv_monitor *cp = cmd->param;
+	struct mgmt_cp_remove_adv_monitor *cp;
+	
+	if (cmd != pending_find(MGMT_OP_REMOVE_ADV_MONITOR, hdev)) {
+		return -ECANCELED;
+	}
+	cp = cmd->param;
 
 	hci_dev_lock(hdev);
 
@@ -5540,8 +5545,15 @@ static void mgmt_remove_adv_monitor_complete(struct hci_dev *hdev,
 static int mgmt_remove_adv_monitor_sync(struct hci_dev *hdev, void *data)
 {
 	struct mgmt_pending_cmd *cmd = data;
-	struct mgmt_cp_remove_adv_monitor *cp = cmd->param;
-	u16 handle = __le16_to_cpu(cp->monitor_handle);
+	struct mgmt_cp_remove_adv_monitor *cp;
+	u16 handle; 
+
+	if (cmd != pending_find(MGMT_OP_REMOVE_ADV_MONITOR, hdev)) {
+		return -ECANCELED;
+	}
+
+	cp = cmd->param;
+	handle == __le16_to_cpu(cp->monitor_handle);
 
 	if (!handle)
 		return hci_remove_all_adv_monitor(hdev);
-- 
2.46.0


  parent reply	other threads:[~2024-12-05 12:20 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 [this message]
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
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=D63RG2V1SJD8.3JVR47OT0IN39@getstate.dev \
    --to=mazin@getstate.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=syzbot+479aff51bb361ef5aa18@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