btintel_diagnostics() accesses tlv->val[0] without first validating that the diagnostics VSE is long enough to contain that field, so may cause reading data beyond the received frame. Fix by validating the length before access.
Unified · Split
| @@ -3771,6 +3771,9 @@ static int btintel_diagnostics(struct hci_dev *hdev, struct sk_buff *skb) · 3770 unmodified lines | ||
| 3771 | 3771 | { |
| 3772 | 3772 | struct intel_tlv *tlv = (void *)&skb->data[5]; |
| 3773 | 3773 | |
| 3774 | + if (skb->len < 5 + sizeof(*tlv) + sizeof(tlv->val[0])) | |
| 3775 | + goto recv_frame; | |
| 3776 | + | |
| 3774 | 3777 | /* The first event is always an event type TLV */ |
| 3775 | 3778 | if (tlv->type != INTEL_TLV_TYPE_ID) |
| 3776 | 3779 | goto recv_frame; |