mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "jiale yao" <19888972804@163.com>
To: "Marcel Holtmann" <marcel@holtmann.org>,
	"Luiz Augusto von Dentz" <luiz.dentz@gmail.com>,
	linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re:[PATCH 1/2] Bluetooth: MGMT: free remove monitor command on cancel
Date: Sat, 17 Oct 2026 15:36:46 +0800 (CST)	[thread overview]
Message-ID: <3e436213.18ae.1a148cab430.Coremail.19888972804@163.com> (raw)
In-Reply-To: <20261017030939.3615701-1-yaojiale02@163.com>

At 2026-10-17 11:09:39, "Jiale Yao" <yaojiale02@163.com> wrote:
>remove_adv_monitor() allocates its queued command with
>mgmt_pending_new(), so the command is not linked into
>hdev->mgmt_pending. If the command-sync entry is cancelled, its
>completion callback returns without freeing the command, leaking both
>the allocation and its socket reference.
>
>Free the pending command before returning from the cancellation path.
>

Fixes: e6ed54e86aae ("Bluetooth: MGMT: Fix UAF on mgmt_remove_adv_monitor_complete")

>Signed-off-by: Jiale Yao <yaojiale02@163.com>
>---
> net/bluetooth/mgmt.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
>diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
>index 251a896babd5..e54a838aeada 100644
>--- a/net/bluetooth/mgmt.c
>+++ b/net/bluetooth/mgmt.c
>@@ -5682,8 +5682,10 @@ static void mgmt_remove_adv_monitor_complete(struct hci_dev *hdev,
> 	struct mgmt_pending_cmd *cmd = data;
> 	struct mgmt_cp_remove_adv_monitor *cp;
> 
>-	if (status == -ECANCELED)
>+	if (status == -ECANCELED) {
>+		mgmt_pending_free(cmd);
> 		return;
>+	}
> 
> 	hci_dev_lock(hdev);
> 
>-- 
>2.34.1

      reply	other threads:[~2026-10-17  7:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-17  3:09 [PATCH " Jiale Yao
2026-10-17  7:36 ` jiale yao [this message]

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=3e436213.18ae.1a148cab430.Coremail.19888972804@163.com \
    --to=19888972804@163.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luiz.dentz@gmail.com \
    --cc=marcel@holtmann.org \
    /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

all inboxes | Powered by JetHome®