Skip to content

Commit 03f1700

Browse files
dmantipovVudentz
authored andcommitted
Bluetooth: MGMT: reject malformed HCI_CMD_SYNC commands
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: [email protected] Closes: https://syzkaller.appspot.com/bug?extid=5fe2d5bfbfbec0b675a0 Fixes: 827af47 ("Bluetooth: MGMT: Add initial implementation of MGMT_OP_HCI_CMD_SYNC") Signed-off-by: Dmitry Antipov <[email protected]> Signed-off-by: Luiz Augusto von Dentz <[email protected]>
1 parent d3faab9 commit 03f1700

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

net/bluetooth/mgmt.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2566,7 +2566,8 @@ static int mgmt_hci_cmd_sync(struct sock *sk, struct hci_dev *hdev,
25662566
struct mgmt_pending_cmd *cmd;
25672567
int err;
25682568

2569-
if (len < sizeof(*cp))
2569+
if (len != (offsetof(struct mgmt_cp_hci_cmd_sync, params) +
2570+
le16_to_cpu(cp->params_len)))
25702571
return mgmt_cmd_status(sk, hdev->id, MGMT_OP_HCI_CMD_SYNC,
25712572
MGMT_STATUS_INVALID_PARAMS);
25722573

0 commit comments

Comments
 (0)