2022-09-26 19:46:10

by Ben Greear

[permalink] [raw]
Subject: iwlmvm potential issue in txpath

Hello,

I'm trying to track down a use-after-free and similar bugs in ax210...

From looking at this code, I am thinking maybe this is part of the problem:

When this code returns non-zero, the skb is freed by calling code.

But in the section with #### HERE #### below, I think it could free
skb and still return != 0, which would cause double-free?

int iwl_mvm_tx_skb_sta(struct iwl_mvm *mvm, struct sk_buff *skb,
struct ieee80211_sta *sta)
{
struct iwl_mvm_sta *mvmsta = iwl_mvm_sta_from_mac80211(sta);
struct ieee80211_tx_info info;
struct sk_buff_head mpdus_skbs;
unsigned int payload_len;
int ret;

if (WARN_ON_ONCE(!mvmsta))
return -1;

if (WARN_ON_ONCE(mvmsta->sta_id == IWL_MVM_INVALID_STA))
return -1;

memcpy(&info, skb->cb, sizeof(info));

if (!skb_is_gso(skb))
return iwl_mvm_tx_mpdu(mvm, skb, &info, sta);

payload_len = skb_tail_pointer(skb) - skb_transport_header(skb) -
tcp_hdrlen(skb) + skb->data_len;

if (payload_len <= skb_shinfo(skb)->gso_size)
return iwl_mvm_tx_mpdu(mvm, skb, &info, sta);

__skb_queue_head_init(&mpdus_skbs);

ret = iwl_mvm_tx_tso(mvm, skb, &info, sta, &mpdus_skbs);
if (ret)
return ret;

if (WARN_ON(skb_queue_empty(&mpdus_skbs)))
return ret;

while (!skb_queue_empty(&mpdus_skbs)) {
skb = __skb_dequeue(&mpdus_skbs);

ret = iwl_mvm_tx_mpdu(mvm, skb, &info, sta);
if (ret) {

#### HERE ####
__skb_queue_purge(&mpdus_skbs);
return ret;
}
}

return 0;
}


Maybe return 0 in that error branch?

Thanks,
Ben

--
Ben Greear <[email protected]>
Candela Technologies Inc http://www.candelatech.com