From b916b9a2d8631b886310aa8a24fedb7d464e0c36 Mon Sep 17 00:00:00 2001 From: Moein Date: Sat, 20 Jun 2026 19:56:39 +0330 Subject: [PATCH] Fix kernel 6.3+ compatibility (eth_hw_addr_set, key buffer, UBSAN) --- hal/phydm/phydm_phystatus.c | 4 ++-- include/ieee80211.h | 2 +- include/wlan_bssdef.h | 4 ++-- os_dep/linux/os_intfs.c | 8 ++++---- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/hal/phydm/phydm_phystatus.c b/hal/phydm/phydm_phystatus.c index b87a144..14e4e88 100644 --- a/hal/phydm/phydm_phystatus.c +++ b/hal/phydm/phydm_phystatus.c @@ -1714,7 +1714,7 @@ phydm_process_rssi_for_dm( } if (sta->rssi_stat.ofdm_pkt_cnt != 64) { i = 63; - sta->rssi_stat.ofdm_pkt_cnt -= (u8)(((sta->rssi_stat.packet_map >> i) & BIT(0)) - 1); + sta->rssi_stat.ofdm_pkt_cnt -= (u8)((((u64)sta->rssi_stat.packet_map >> i) & BIT(0)) - 1); } sta->rssi_stat.packet_map = (sta->rssi_stat.packet_map << 1) | BIT(0); @@ -1751,7 +1751,7 @@ phydm_process_rssi_for_dm( } } i = 63; - sta->rssi_stat.ofdm_pkt_cnt -= (u8)((sta->rssi_stat.packet_map >> i) & BIT(0)); + sta->rssi_stat.ofdm_pkt_cnt -= (u8)(((u64)sta->rssi_stat.packet_map >> i) & BIT(0)); sta->rssi_stat.packet_map = sta->rssi_stat.packet_map << 1; } diff --git a/include/ieee80211.h b/include/ieee80211.h index 0341cda..cd73b93 100644 --- a/include/ieee80211.h +++ b/include/ieee80211.h @@ -263,7 +263,7 @@ typedef struct ieee_param { u8 idx; u8 seq[8]; /* sequence counter (set: RX, get: TX) */ u16 key_len; - u8 key[0]; + u8 key[32]; } crypt; #ifdef CONFIG_AP_MODE struct { diff --git a/include/wlan_bssdef.h b/include/wlan_bssdef.h index e7ae359..539efb2 100644 --- a/include/wlan_bssdef.h +++ b/include/wlan_bssdef.h @@ -95,7 +95,7 @@ typedef struct _NDIS_802_11_FIXED_IEs { typedef struct _NDIS_802_11_VARIABLE_IEs { UCHAR ElementID; UCHAR Length; - UCHAR data[1]; + UCHAR data[]; } NDIS_802_11_VARIABLE_IEs, *PNDIS_802_11_VARIABLE_IEs; @@ -343,7 +343,7 @@ typedef struct _NDIS_802_11_FIXED_IEs { typedef struct _NDIS_802_11_VARIABLE_IEs { UCHAR ElementID; UCHAR Length; - UCHAR data[1]; + UCHAR data[]; } NDIS_802_11_VARIABLE_IEs, *PNDIS_802_11_VARIABLE_IEs; diff --git a/os_dep/linux/os_intfs.c b/os_dep/linux/os_intfs.c index 73e06e6..3ee6f0b 100644 --- a/os_dep/linux/os_intfs.c +++ b/os_dep/linux/os_intfs.c @@ -1196,7 +1196,7 @@ static int rtw_net_set_mac_address(struct net_device *pnetdev, void *addr) } _rtw_memcpy(adapter_mac_addr(padapter), sa->sa_data, ETH_ALEN); /* set mac addr to adapter */ - _rtw_memcpy((void*)pnetdev->dev_addr, sa->sa_data, ETH_ALEN); /* set mac addr to net_device */ + eth_hw_addr_set(pnetdev, sa->sa_data); /* set mac addr to net_device */ #if 0 if (rtw_is_hw_init_completed(padapter)) @@ -1629,7 +1629,7 @@ int rtw_os_ndev_register(_adapter *adapter, const char *name) /* alloc netdev name */ rtw_init_netdev_name(ndev, name); - _rtw_memcpy((void*)ndev->dev_addr, adapter_mac_addr(adapter), ETH_ALEN); + eth_hw_addr_set(ndev, adapter_mac_addr(adapter)); #if defined(CONFIG_NET_NS) dev_net_set(ndev, wiphy_net(adapter_to_wiphy(adapter))); #endif //defined(CONFIG_NET_NS) @@ -2572,7 +2572,7 @@ int _netdev_vir_if_open(struct net_device *pnetdev) rtw_mbid_camid_alloc(padapter, adapter_mac_addr(padapter)); #endif rtw_init_wifidirect_addrs(padapter, adapter_mac_addr(padapter), adapter_mac_addr(padapter)); - _rtw_memcpy(pnetdev->dev_addr, adapter_mac_addr(padapter), ETH_ALEN); + eth_hw_addr_set(pnetdev, adapter_mac_addr(padapter)); } #endif /*CONFIG_PLATFORM_INTEL_BYT*/ @@ -3219,7 +3219,7 @@ int _netdev_open(struct net_device *pnetdev) rtw_mbid_camid_alloc(padapter, adapter_mac_addr(padapter)); #endif rtw_init_wifidirect_addrs(padapter, adapter_mac_addr(padapter), adapter_mac_addr(padapter)); - _rtw_memcpy(pnetdev->dev_addr, adapter_mac_addr(padapter), ETH_ALEN); + eth_hw_addr_set(pnetdev, adapter_mac_addr(padapter)); #endif /* CONFIG_PLATFORM_INTEL_BYT */ rtw_clr_surprise_removed(padapter);