public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Bluetooth: MGMT: reject malformed HCI_CMD_SYNC commands
@ 2025-05-22 18:16 Dmitry Antipov
  2025-05-22 19:07 ` bluez.test.bot
  2025-05-23 14:40 ` [PATCH] " patchwork-bot+bluetooth
  0 siblings, 2 replies; 3+ messages in thread
From: Dmitry Antipov @ 2025-05-22 18:16 UTC (permalink / raw)
  To: Luiz Augusto von Dentz
  Cc: Marcel Holtmann, Johan Hedberg, linux-bluetooth, Dmitry Antipov,
	syzbot+5fe2d5bfbfbec0b675a0

In 'mgmt_hci_cmd_sync()', check whether the size of parameters passed
in 'struct mgmt_cp_hci_cmd_sync' matches the total size of the data
(i.e. 'sizeof(struct mgmt_cp_hci_cmd_sync)' plus trailing bytes).
Otherwise, large invalid 'params_len' will cause 'hci_cmd_sync_alloc()'
to do 'skb_put_data()' from an area beyond the one actually passed to
'mgmt_hci_cmd_sync()'.

Reported-by: syzbot+5fe2d5bfbfbec0b675a0@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=5fe2d5bfbfbec0b675a0
Fixes: 827af4787e74 ("Bluetooth: MGMT: Add initial implementation of MGMT_OP_HCI_CMD_SYNC")
Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
---
 net/bluetooth/mgmt.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 46b22708dfbd..86f4d0f172ab 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -2566,7 +2566,8 @@ static int mgmt_hci_cmd_sync(struct sock *sk, struct hci_dev *hdev,
 	struct mgmt_pending_cmd *cmd;
 	int err;
 
-	if (len < sizeof(*cp))
+	if (len != (offsetof(struct mgmt_cp_hci_cmd_sync, params) +
+		    le16_to_cpu(cp->params_len)))
 		return mgmt_cmd_status(sk, hdev->id, MGMT_OP_HCI_CMD_SYNC,
 				       MGMT_STATUS_INVALID_PARAMS);
 
-- 
2.49.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* RE: Bluetooth: MGMT: reject malformed HCI_CMD_SYNC commands
  2025-05-22 18:16 [PATCH] Bluetooth: MGMT: reject malformed HCI_CMD_SYNC commands Dmitry Antipov
@ 2025-05-22 19:07 ` bluez.test.bot
  2025-05-23 14:40 ` [PATCH] " patchwork-bot+bluetooth
  1 sibling, 0 replies; 3+ messages in thread
From: bluez.test.bot @ 2025-05-22 19:07 UTC (permalink / raw)
  To: linux-bluetooth, dmantipov

[-- Attachment #1: Type: text/plain, Size: 2030 bytes --]

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=965515

---Test result---

Test Summary:
CheckPatch                    PENDING   0.26 seconds
GitLint                       PENDING   0.24 seconds
SubjectPrefix                 PASS      0.24 seconds
BuildKernel                   PASS      24.63 seconds
CheckAllWarning               PASS      26.99 seconds
CheckSparse                   PASS      30.10 seconds
BuildKernel32                 PASS      24.20 seconds
TestRunnerSetup               PASS      456.42 seconds
TestRunner_l2cap-tester       PASS      25.30 seconds
TestRunner_iso-tester         PASS      39.65 seconds
TestRunner_bnep-tester        PASS      5.86 seconds
TestRunner_mgmt-tester        FAIL      131.82 seconds
TestRunner_rfcomm-tester      PASS      9.29 seconds
TestRunner_sco-tester         PASS      14.75 seconds
TestRunner_ioctl-tester       PASS      10.15 seconds
TestRunner_mesh-tester        PASS      7.26 seconds
TestRunner_smp-tester         PASS      8.69 seconds
TestRunner_userchan-tester    PASS      6.13 seconds
IncrementalBuild              PENDING   0.76 seconds

Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script
Output:

##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:

##############################
Test: TestRunner_mgmt-tester - FAIL
Desc: Run mgmt-tester with test-runner
Output:
Total: 490, Passed: 484 (98.8%), Failed: 2, Not Run: 4

Failed Test Cases
LL Privacy - Set Flags 3 (2 Devices to RL)           Failed       0.215 seconds
LL Privacy - Set Device Flag 1 (Device Privacy)      Failed       0.170 seconds
##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series
Output:



---
Regards,
Linux Bluetooth


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Bluetooth: MGMT: reject malformed HCI_CMD_SYNC commands
  2025-05-22 18:16 [PATCH] Bluetooth: MGMT: reject malformed HCI_CMD_SYNC commands Dmitry Antipov
  2025-05-22 19:07 ` bluez.test.bot
@ 2025-05-23 14:40 ` patchwork-bot+bluetooth
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+bluetooth @ 2025-05-23 14:40 UTC (permalink / raw)
  To: Dmitry Antipov
  Cc: luiz.dentz, marcel, johan.hedberg, linux-bluetooth,
	syzbot+5fe2d5bfbfbec0b675a0

Hello:

This patch was applied to bluetooth/bluetooth-next.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:

On Thu, 22 May 2025 21:16:02 +0300 you wrote:
> In 'mgmt_hci_cmd_sync()', check whether the size of parameters passed
> in 'struct mgmt_cp_hci_cmd_sync' matches the total size of the data
> (i.e. 'sizeof(struct mgmt_cp_hci_cmd_sync)' plus trailing bytes).
> Otherwise, large invalid 'params_len' will cause 'hci_cmd_sync_alloc()'
> to do 'skb_put_data()' from an area beyond the one actually passed to
> 'mgmt_hci_cmd_sync()'.
> 
> [...]

Here is the summary with links:
  - Bluetooth: MGMT: reject malformed HCI_CMD_SYNC commands
    https://git.kernel.org/bluetooth/bluetooth-next/c/2ab3abab237b

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-05-23 14:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-22 18:16 [PATCH] Bluetooth: MGMT: reject malformed HCI_CMD_SYNC commands Dmitry Antipov
2025-05-22 19:07 ` bluez.test.bot
2025-05-23 14:40 ` [PATCH] " patchwork-bot+bluetooth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox