Skip to content

Commit 1de9278

Browse files
avasummergregkh
authored andcommitted
wifi: iwlwifi: mld: validate sta_mask before ffs() in BA session handlers
commit f056fc2 upstream. Three BA session handlers use ffs(ba_data->sta_mask) - 1 to derive a station ID without checking that sta_mask is non-zero. When sta_mask is zero, ffs() returns 0 and the subtraction wraps to 0xFFFFFFFF, causing an out-of-bounds access on fw_id_to_link_sta[]. Add WARN_ON_ONCE(!ba_data->sta_mask) guards before each ffs() call, consistent with the existing check in iwl_mld_ampdu_rx_start(). Reported-by: Yuhao Jiang <danisjiang@gmail.com> Cc: stable@vger.kernel.org Signed-off-by: Junrui Luo <moonafterrain@outlook.com> Link: https://patch.msgid.link/SYBPR01MB788115C6CE873271A9A15A25AF51A@SYBPR01MB7881.ausprd01.prod.outlook.com Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent b0b07e0 commit 1de9278

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

  • drivers/net/wireless/intel/iwlwifi/mld

drivers/net/wireless/intel/iwlwifi/mld/agg.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ static void iwl_mld_release_frames_from_notif(struct iwl_mld *mld,
6464
}
6565

6666
/* pick any STA ID to find the pointer */
67+
if (WARN_ON_ONCE(!ba_data->sta_mask))
68+
goto out_unlock;
69+
6770
sta_id = ffs(ba_data->sta_mask) - 1;
6871
link_sta = rcu_dereference(mld->fw_id_to_link_sta[sta_id]);
6972
if (WARN_ON_ONCE(IS_ERR_OR_NULL(link_sta) || !link_sta->sta))
@@ -166,6 +169,9 @@ void iwl_mld_del_ba(struct iwl_mld *mld, int queue,
166169
goto out_unlock;
167170

168171
/* pick any STA ID to find the pointer */
172+
if (WARN_ON_ONCE(!ba_data->sta_mask))
173+
goto out_unlock;
174+
169175
sta_id = ffs(ba_data->sta_mask) - 1;
170176
link_sta = rcu_dereference(mld->fw_id_to_link_sta[sta_id]);
171177
if (WARN_ON_ONCE(IS_ERR_OR_NULL(link_sta) || !link_sta->sta))
@@ -347,6 +353,9 @@ static void iwl_mld_rx_agg_session_expired(struct timer_list *t)
347353
}
348354

349355
/* timer expired, pick any STA ID to find the pointer */
356+
if (WARN_ON_ONCE(!ba_data->sta_mask))
357+
goto unlock;
358+
350359
sta_id = ffs(ba_data->sta_mask) - 1;
351360
link_sta = rcu_dereference(ba_data->mld->fw_id_to_link_sta[sta_id]);
352361

0 commit comments

Comments
 (0)