@@ -69,6 +69,18 @@ static void *hci_cc_skb_pull(struct hci_dev *hdev, struct sk_buff *skb,
6969 return data ;
7070}
7171
72+ static void * hci_le_ev_skb_pull (struct hci_dev * hdev , struct sk_buff * skb ,
73+ u8 ev , size_t len )
74+ {
75+ void * data ;
76+
77+ data = skb_pull_data (skb , len );
78+ if (!data )
79+ bt_dev_err (hdev , "Malformed LE Event: 0x%2.2x" , ev );
80+
81+ return data ;
82+ }
83+
7284static void hci_cc_inquiry_cancel (struct hci_dev * hdev , struct sk_buff * skb ,
7385 u8 * new_status )
7486{
@@ -6119,7 +6131,12 @@ static void le_conn_complete_evt(struct hci_dev *hdev, u8 status,
61196131
61206132static void hci_le_conn_complete_evt (struct hci_dev * hdev , struct sk_buff * skb )
61216133{
6122- struct hci_ev_le_conn_complete * ev = (void * ) skb -> data ;
6134+ struct hci_ev_le_conn_complete * ev ;
6135+
6136+ ev = hci_le_ev_skb_pull (hdev , skb , HCI_EV_LE_CONN_COMPLETE ,
6137+ sizeof (* ev ));
6138+ if (!ev )
6139+ return ;
61236140
61246141 BT_DBG ("%s status 0x%2.2x" , hdev -> name , ev -> status );
61256142
@@ -6133,7 +6150,12 @@ static void hci_le_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
61336150static void hci_le_enh_conn_complete_evt (struct hci_dev * hdev ,
61346151 struct sk_buff * skb )
61356152{
6136- struct hci_ev_le_enh_conn_complete * ev = (void * ) skb -> data ;
6153+ struct hci_ev_le_enh_conn_complete * ev ;
6154+
6155+ ev = hci_le_ev_skb_pull (hdev , skb , HCI_EV_LE_ENHANCED_CONN_COMPLETE ,
6156+ sizeof (* ev ));
6157+ if (!ev )
6158+ return ;
61376159
61386160 BT_DBG ("%s status 0x%2.2x" , hdev -> name , ev -> status );
61396161
@@ -6146,10 +6168,15 @@ static void hci_le_enh_conn_complete_evt(struct hci_dev *hdev,
61466168
61476169static void hci_le_ext_adv_term_evt (struct hci_dev * hdev , struct sk_buff * skb )
61486170{
6149- struct hci_evt_le_ext_adv_set_term * ev = ( void * ) skb -> data ;
6171+ struct hci_evt_le_ext_adv_set_term * ev ;
61506172 struct hci_conn * conn ;
61516173 struct adv_info * adv , * n ;
61526174
6175+ ev = hci_le_ev_skb_pull (hdev , skb , HCI_EV_LE_EXT_ADV_SET_TERM ,
6176+ sizeof (* ev ));
6177+ if (!ev )
6178+ return ;
6179+
61536180 BT_DBG ("%s status 0x%2.2x" , hdev -> name , ev -> status );
61546181
61556182 adv = hci_find_adv_instance (hdev , ev -> handle );
@@ -6211,9 +6238,14 @@ static void hci_le_ext_adv_term_evt(struct hci_dev *hdev, struct sk_buff *skb)
62116238static void hci_le_conn_update_complete_evt (struct hci_dev * hdev ,
62126239 struct sk_buff * skb )
62136240{
6214- struct hci_ev_le_conn_update_complete * ev = ( void * ) skb -> data ;
6241+ struct hci_ev_le_conn_update_complete * ev ;
62156242 struct hci_conn * conn ;
62166243
6244+ ev = hci_le_ev_skb_pull (hdev , skb , HCI_EV_LE_CONN_UPDATE_COMPLETE ,
6245+ sizeof (* ev ));
6246+ if (!ev )
6247+ return ;
6248+
62176249 BT_DBG ("%s status 0x%2.2x" , hdev -> name , ev -> status );
62186250
62196251 if (ev -> status )
@@ -6636,9 +6668,14 @@ static void hci_le_ext_adv_report_evt(struct hci_dev *hdev, struct sk_buff *skb)
66366668static void hci_le_remote_feat_complete_evt (struct hci_dev * hdev ,
66376669 struct sk_buff * skb )
66386670{
6639- struct hci_ev_le_remote_feat_complete * ev = ( void * ) skb -> data ;
6671+ struct hci_ev_le_remote_feat_complete * ev ;
66406672 struct hci_conn * conn ;
66416673
6674+ ev = hci_le_ev_skb_pull (hdev , skb , HCI_EV_LE_EXT_ADV_REPORT ,
6675+ sizeof (* ev ));
6676+ if (!ev )
6677+ return ;
6678+
66426679 BT_DBG ("%s status 0x%2.2x" , hdev -> name , ev -> status );
66436680
66446681 hci_dev_lock (hdev );
@@ -6677,12 +6714,16 @@ static void hci_le_remote_feat_complete_evt(struct hci_dev *hdev,
66776714
66786715static void hci_le_ltk_request_evt (struct hci_dev * hdev , struct sk_buff * skb )
66796716{
6680- struct hci_ev_le_ltk_req * ev = ( void * ) skb -> data ;
6717+ struct hci_ev_le_ltk_req * ev ;
66816718 struct hci_cp_le_ltk_reply cp ;
66826719 struct hci_cp_le_ltk_neg_reply neg ;
66836720 struct hci_conn * conn ;
66846721 struct smp_ltk * ltk ;
66856722
6723+ ev = hci_le_ev_skb_pull (hdev , skb , HCI_EV_LE_LTK_REQ , sizeof (* ev ));
6724+ if (!ev )
6725+ return ;
6726+
66866727 BT_DBG ("%s handle 0x%4.4x" , hdev -> name , __le16_to_cpu (ev -> handle ));
66876728
66886729 hci_dev_lock (hdev );
@@ -6754,11 +6795,16 @@ static void send_conn_param_neg_reply(struct hci_dev *hdev, u16 handle,
67546795static void hci_le_remote_conn_param_req_evt (struct hci_dev * hdev ,
67556796 struct sk_buff * skb )
67566797{
6757- struct hci_ev_le_remote_conn_param_req * ev = ( void * ) skb -> data ;
6798+ struct hci_ev_le_remote_conn_param_req * ev ;
67586799 struct hci_cp_le_conn_param_req_reply cp ;
67596800 struct hci_conn * hcon ;
67606801 u16 handle , min , max , latency , timeout ;
67616802
6803+ ev = hci_le_ev_skb_pull (hdev , skb , HCI_EV_LE_REMOTE_CONN_PARAM_REQ ,
6804+ sizeof (* ev ));
6805+ if (!ev )
6806+ return ;
6807+
67626808 handle = le16_to_cpu (ev -> handle );
67636809 min = le16_to_cpu (ev -> interval_min );
67646810 max = le16_to_cpu (ev -> interval_max );
@@ -6831,9 +6877,14 @@ static void hci_le_direct_adv_report_evt(struct hci_dev *hdev,
68316877
68326878static void hci_le_phy_update_evt (struct hci_dev * hdev , struct sk_buff * skb )
68336879{
6834- struct hci_ev_le_phy_update_complete * ev = ( void * ) skb -> data ;
6880+ struct hci_ev_le_phy_update_complete * ev ;
68356881 struct hci_conn * conn ;
68366882
6883+ ev = hci_le_ev_skb_pull (hdev , skb , HCI_EV_LE_PHY_UPDATE_COMPLETE ,
6884+ sizeof (* ev ));
6885+ if (ev )
6886+ return ;
6887+
68376888 BT_DBG ("%s status 0x%2.2x" , hdev -> name , ev -> status );
68386889
68396890 if (ev -> status )
@@ -6854,11 +6905,13 @@ static void hci_le_phy_update_evt(struct hci_dev *hdev, struct sk_buff *skb)
68546905
68556906static void hci_le_meta_evt (struct hci_dev * hdev , struct sk_buff * skb )
68566907{
6857- struct hci_ev_le_meta * le_ev = ( void * ) skb -> data ;
6908+ struct hci_ev_le_meta * ev ;
68586909
6859- skb_pull (skb , sizeof (* le_ev ));
6910+ ev = hci_ev_skb_pull (hdev , skb , HCI_EV_LE_META , sizeof (* ev ));
6911+ if (!ev )
6912+ return ;
68606913
6861- switch (le_ev -> subevent ) {
6914+ switch (ev -> subevent ) {
68626915 case HCI_EV_LE_CONN_COMPLETE :
68636916 hci_le_conn_complete_evt (hdev , skb );
68646917 break ;
0 commit comments