Skip to content

Conversation

@zbowling
Copy link

@zbowling zbowling commented Jan 1, 2026

Several MCU functions dereference pointers returned by mt792x_sta_to_link()
and mt792x_vif_to_link() without checking for NULL. During MLO state
transitions, these functions can return NULL when link state is being
set up or torn down, causing kernel NULL pointer dereferences.

Add NULL checks in the following functions:

  • mt7925_mcu_sta_hdr_trans_tlv(): Check mlink before dereferencing wcid
  • mt7925_mcu_wtbl_update_hdr_trans(): Check mlink and mconf before use
  • mt7925_mcu_sta_amsdu_tlv(): Check mlink before setting amsdu flag
  • mt7925_mcu_sta_mld_tlv(): Check mconf and mlink in link iteration loop
  • mt7925_mcu_sta_update(): Initialize mlink to NULL and check both
    link_sta and mlink in the ternary condition

These race conditions can occur during:

  • MLO link setup/teardown
  • Station add/remove operations
  • Firmware command generation during state transitions

The fixes follow the pattern used in mt7996 and ath12k drivers for
similar MLO link state handling.

Related PRs:

Testing: Found via code audit comparing against mt7996 and ath12k patterns.

…tions

Several MCU functions dereference pointers returned by mt792x_sta_to_link()
and mt792x_vif_to_link() without checking for NULL. During MLO state
transitions, these functions can return NULL when link state is being
set up or torn down, causing kernel NULL pointer dereferences.

Add NULL checks in the following functions:

- mt7925_mcu_sta_hdr_trans_tlv(): Check mlink before dereferencing wcid
- mt7925_mcu_wtbl_update_hdr_trans(): Check mlink and mconf before use
- mt7925_mcu_sta_amsdu_tlv(): Check mlink before setting amsdu flag
- mt7925_mcu_sta_mld_tlv(): Check mconf and mlink in link iteration loop
- mt7925_mcu_sta_update(): Initialize mlink to NULL and check both
  link_sta and mlink in the ternary condition

These race conditions can occur during:
- MLO link setup/teardown
- Station add/remove operations
- Firmware command generation during state transitions

The fixes follow the pattern used in mt7996 and ath12k drivers for
similar MLO link state handling.

Signed-off-by: Zac Bowling <zac@zacbowling.com>
zbowling added a commit to zbowling/mt7925 that referenced this pull request Jan 1, 2026
Adds comprehensive NULL checks in 5 MCU functions that were dereferencing
mt792x_sta_to_link() and mt792x_vif_to_link() return values without checking:

- mt7925_mcu_sta_hdr_trans_tlv()
- mt7925_mcu_wtbl_update_hdr_trans()
- mt7925_mcu_sta_amsdu_tlv()
- mt7925_mcu_sta_mld_tlv()
- mt7925_mcu_sta_update()

Found via code audit comparing against mt7996 and ath12k patterns.

OpenWrt PR: openwrt/mt76#1039
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant