The RX reorder code uses the tid passed by its callers to index the MAX_NUM_TID-sized rx_reorder_tbl_ptr[] and rx_reorder_tbl_lock[] arrays. Several callers take the tid from a received frame or from a firmware event and never validate it, so a tid >= MAX_NUM_TID accesses the arrays out of bounds. Validate tid in nxpwifi_11n_get_rx_reorder_tbl() itself, so that every caller is covered. Also validate it at the entry of nxpwifi_11n_create_rx_reorder_tbl(): when the lookup returns NULL, the create path adds a new entry to the tid-indexed rx_reorder_tbl_ptr[] list, which the lookup check cannot cover. In nxpwifi_11n_rx_reorder_pkt(), the out-of-window drop check bounds seq_num by TWOPOW11 rather than by win_size. The window advance that follows keeps the computed pkt_index within win_size, but it does not trigger when win_size == 1, so pkt_index can still run past the win_size-sized tbl->rx_reorder_ptr[] flex array. Bound pkt_index by win_size before the array access. Fixes: 73b01e57ed3e ("wifi: nxp: add nxpwifi driver for IW61x") Cc: stable@vger.kernel.org Signed-off-by: guohongyu --- Hi Jeff, Thank you for the review. I have analyzed your comments and updated the patch accordingly. Changes in v2: - Move the tid check into nxpwifi_11n_get_rx_reorder_tbl() so that all callers, including the uap RX path, the RXBA sync event and the DELBA and ADDBA-RSP event handling, are covered, as you suggested. drivers/net/wireless/nxp/nxpwifi/11n_rxreorder.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/net/wireless/nxp/nxpwifi/11n_rxreorder.c b/drivers/net/wireless/nxp/nxpwifi/11n_rxreorder.c index 87cf2ec85991..115380a2219a 100644 --- a/drivers/net/wireless/nxp/nxpwifi/11n_rxreorder.c +++ b/drivers/net/wireless/nxp/nxpwifi/11n_rxreorder.c @@ -182,6 +182,9 @@ nxpwifi_11n_get_rx_reorder_tbl(struct nxpwifi_private *priv, int tid, u8 *ta) { struct nxpwifi_rx_reorder_tbl *tbl, *found = NULL; + if (tid >= MAX_NUM_TID) + return NULL; + guard(rcu)(); list_for_each_entry_rcu(tbl, &priv->rx_reorder_tbl_ptr[tid], list) { @@ -266,6 +269,9 @@ nxpwifi_11n_create_rx_reorder_tbl(struct nxpwifi_private *priv, u8 *ta, u16 last_seq = 0; struct nxpwifi_sta_node *node; + if (tid >= MAX_NUM_TID) + return; + /* Existing TID/TA: flush and move window to SSN. */ tbl = nxpwifi_11n_get_rx_reorder_tbl(priv, tid, ta); if (tbl) { @@ -492,6 +498,11 @@ int nxpwifi_11n_rx_reorder_pkt(struct nxpwifi_private *priv, else pkt_index = (seq_num + MAX_TID_VALUE) - start_win; + if (pkt_index >= tbl->win_size) { + ret = -EINVAL; + goto done; + } + if (tbl->rx_reorder_ptr[pkt_index]) { ret = -EINVAL; goto done; -- 2.43.0