From: caitao <294305068@qq.com>
To: linux-bluetooth@vger.kernel.org
Cc: caitao <caitao@kylinos.cn>
Subject: [PATCH] Bluetooth: MGMT: Add length check in confirm_name
Date: Thu, 9 Jul 2026 15:19:44 +0800 [thread overview]
Message-ID: <tencent_3C5C860091EDE98DB4B649EA03E82587A607@qq.com> (raw)
From: caitao <caitao@kylinos.cn>
The confirm_name function did not validate the length of the incoming
data before accessing the mgmt_cp_confirm_name structure, which could
lead to out-of-bounds reads if a short packet was sent.
Add a length check at the beginning of the function to ensure the data
is at least sizeof(struct mgmt_cp_confirm_name). If the check fails,
return MGMT_STATUS_INVALID_PARAMS without accessing the invalid data.
Signed-off-by: caitao <caitao@kylinos.cn>
---
net/bluetooth/mgmt.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index a0a491e5311e..aab8e64283aa 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -6271,6 +6271,10 @@ static int confirm_name(struct sock *sk, struct hci_dev *hdev, void *data,
bt_dev_dbg(hdev, "sock %p", sk);
+ if (len < sizeof(*cp))
+ return mgmt_cmd_complete(sk, hdev->id, MGMT_OP_CONFIRM_NAME,
+ MGMT_STATUS_INVALID_PARAMS, NULL, 0);
+
hci_dev_lock(hdev);
if (!hci_discovery_active(hdev)) {
--
2.43.0
next reply other threads:[~2026-07-09 7:20 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-09 7:19 caitao [this message]
2026-07-09 9:22 ` Bluetooth: MGMT: Add length check in confirm_name bluez.test.bot
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=tencent_3C5C860091EDE98DB4B649EA03E82587A607@qq.com \
--to=294305068@qq.com \
--cc=caitao@kylinos.cn \
--cc=linux-bluetooth@vger.kernel.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