Skip to content

Commit 284987a

Browse files
committed
Merge tag 'for-net-2025-10-31' of git://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth
Luiz Augusto von Dentz says: ==================== bluetooth pull request for net: - btrtl: Fix memory leak in rtlbt_parse_firmware_v2() - MGMT: Fix OOB access in parse_adv_monitor_pattern() - hci_event: validate skb length for unknown CC opcode * tag 'for-net-2025-10-31' of git://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth: Bluetooth: MGMT: Fix OOB access in parse_adv_monitor_pattern() Bluetooth: btrtl: Fix memory leak in rtlbt_parse_firmware_v2() Bluetooth: hci_event: validate skb length for unknown CC opcode ==================== Link: https://patch.msgid.link/20251031170959.590470-1-luiz.dentz@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2 parents b790432 + 8d59fba commit 284987a

4 files changed

Lines changed: 14 additions & 5 deletions

File tree

drivers/bluetooth/btrtl.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -625,8 +625,10 @@ static int rtlbt_parse_firmware_v2(struct hci_dev *hdev,
625625
len += entry->len;
626626
}
627627

628-
if (!len)
628+
if (!len) {
629+
kvfree(ptr);
629630
return -EPERM;
631+
}
630632

631633
*_buf = ptr;
632634
return len;

include/net/bluetooth/mgmt.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,7 @@ struct mgmt_adv_pattern {
780780
__u8 ad_type;
781781
__u8 offset;
782782
__u8 length;
783-
__u8 value[31];
783+
__u8 value[HCI_MAX_AD_LENGTH];
784784
} __packed;
785785

786786
#define MGMT_OP_ADD_ADV_PATTERNS_MONITOR 0x0052

net/bluetooth/hci_event.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4218,6 +4218,13 @@ static void hci_cmd_complete_evt(struct hci_dev *hdev, void *data,
42184218
}
42194219

42204220
if (i == ARRAY_SIZE(hci_cc_table)) {
4221+
if (!skb->len) {
4222+
bt_dev_err(hdev, "Unexpected cc 0x%4.4x with no status",
4223+
*opcode);
4224+
*status = HCI_ERROR_UNSPECIFIED;
4225+
return;
4226+
}
4227+
42214228
/* Unknown opcode, assume byte 0 contains the status, so
42224229
* that e.g. __hci_cmd_sync() properly returns errors
42234230
* for vendor specific commands send by HCI drivers.

net/bluetooth/mgmt.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5395,9 +5395,9 @@ static u8 parse_adv_monitor_pattern(struct adv_monitor *m, u8 pattern_count,
53955395
for (i = 0; i < pattern_count; i++) {
53965396
offset = patterns[i].offset;
53975397
length = patterns[i].length;
5398-
if (offset >= HCI_MAX_EXT_AD_LENGTH ||
5399-
length > HCI_MAX_EXT_AD_LENGTH ||
5400-
(offset + length) > HCI_MAX_EXT_AD_LENGTH)
5398+
if (offset >= HCI_MAX_AD_LENGTH ||
5399+
length > HCI_MAX_AD_LENGTH ||
5400+
(offset + length) > HCI_MAX_AD_LENGTH)
54015401
return MGMT_STATUS_INVALID_PARAMS;
54025402

54035403
p = kmalloc(sizeof(*p), GFP_KERNEL);

0 commit comments

Comments
 (0)