mirror of
https://github.com/nxp-imx/mwifiex.git
synced 2026-11-20 18:39:49 -05:00
MA-24369 Fix use-after-free in station info with cached data
When a WiFi driver caches station_info and later copies it back using memcpy(), the newly allocated sinfo->links[] pointers are overwritten with stale pointers from the cache. This causes use-after-free and double-free errors when cfg80211_sinfo_release_content() attempts to free the already-freed cached pointers. The issue occurs in this sequence: 1. nl80211_get_station() allocates fresh sinfo.links[] arrays 2. Driver's get_station() does memcpy(sinfo, cached_sinfo, ...) 3. This overwrites new link pointers with old freed pointers 4. cfg80211_sinfo_release_content() in nl80211_send_station() frees the stale pointers 5. It triggers KASAN use-after-free/double-free Fix by preserving the newly allocated link pointers across the memcpy operation. KASAN report: BUG: KASAN: slab-use-after-free in cfg80211_sinfo_release_content+0x90/0xc8 [cfg80211] Call trace: show_stack+0x18/0x28 (C) dump_stack_lvl+0x40/0xbc print_report+0x144/0x6f4 kasan_report+0xdc/0x13c __asan_report_load8_noabort+0x20/0x30 cfg80211_sinfo_release_content+0x90/0xc8 [cfg80211] nl80211_send_station+0x167c/0x1bc4 [cfg80211] nl80211_get_station+0x530/0x660 [cfg80211] genl_family_rcv_msg_doit+0x17c/0x258 genl_rcv_msg+0x334/0x478 netlink_rcv_skb+0x1a0/0x2f8 genl_rcv+0x34/0x50 netlink_unicast+0x4e8/0x76c netlink_sendmsg+0x460/0x6ec Freed by task 992: kasan_save_track+0x40/0x7c __kasan_save_free_info+0x54/0x70 __kasan_slab_free+0x6c/0xa0 kfree+0x104/0x48c cfg80211_sinfo_release_content+0x50/0xc8 [cfg80211] nl80211_send_station+0x167c/0x1bc4 [cfg80211] nl80211_get_station+0x530/0x660 [cfg80211] Change-Id: Ib7b715c953170b0cd31b7b3557a907debfdf1d6f Signed-off-by: Jindong Yue <jindong.yue@nxp.com>
This commit is contained in:
parent
eadd45baa0
commit
b08958dc25
1 changed files with 15 additions and 1 deletions
|
|
@ -4621,10 +4621,24 @@ static mlan_status woal_cfg80211_dump_station_info(moal_private *priv,
|
|||
ENTER();
|
||||
|
||||
if (priv->phandle->scan_pending_on_block) {
|
||||
if (priv->sinfo)
|
||||
if (priv->sinfo) {
|
||||
#if CFG80211_VERSION_CODE >= KERNEL_VERSION(6, 18, 0)
|
||||
struct link_station_info *saved_links[IEEE80211_MLD_MAX_NUM_LINKS];
|
||||
|
||||
for (int i = 0; i < IEEE80211_MLD_MAX_NUM_LINKS; i++) {
|
||||
saved_links[i] = sinfo->links[i];
|
||||
}
|
||||
#endif
|
||||
moal_memcpy_ext(priv->phandle, sinfo, priv->sinfo,
|
||||
sizeof(struct station_info),
|
||||
sizeof(struct station_info));
|
||||
|
||||
#if CFG80211_VERSION_CODE >= KERNEL_VERSION(6, 18, 0)
|
||||
for (int i = 0; i < IEEE80211_MLD_MAX_NUM_LINKS; i++) {
|
||||
sinfo->links[i] = saved_links[i];
|
||||
}
|
||||
#endif
|
||||
}
|
||||
LEAVE();
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue