[PATCH ath-next v2 3/4] wifi: ath12k: rely on pskb_trim() to trim the received skb
Lorenzo Bianconi
lorenzo.bianconi at oss.qualcomm.com
Fri Nov 13 06:51:44 PST 2026
Prepare the RX path for handling non-linear SKBs introduced by the
following RX batching change. skb_trim() cannot trim non-linear SKBs
(__skb_set_length() warns and leaves the length unchanged), so use
pskb_trim() instead.
pskb_trim() can fail if it needs to allocate while removing data, so
return its error from ath12k_dp_rx_h_undecap_raw(). The existing callers
then drop the frame instead of delivering it with an untrimmed FCS, MIC,
or ICV trailer.
Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.1.c7-00108-QCAHMTSWPL_V1.0_V2.0_SILICONZ_UPSTREAM-3
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi at oss.qualcomm.com>
---
drivers/net/wireless/ath/ath12k/dp_rx.c | 39 ++++++++++++++++++++++-----------
1 file changed, 26 insertions(+), 13 deletions(-)
diff --git a/drivers/net/wireless/ath/ath12k/dp_rx.c b/drivers/net/wireless/ath/ath12k/dp_rx.c
index 063bc3e58236..74c2d2affb0d 100644
--- a/drivers/net/wireless/ath/ath12k/dp_rx.c
+++ b/drivers/net/wireless/ath/ath12k/dp_rx.c
@@ -1007,9 +1007,9 @@ static int ath12k_dp_rx_h_undecap_raw(struct ath12k_pdev_dp *dp_pdev,
{
struct ath12k_dp *dp = dp_pdev->dp;
struct ath12k_skb_rxcb *rxcb = ATH12K_SKB_RXCB(msdu);
- struct ieee80211_hdr *hdr;
size_t hdr_len;
size_t crypto_len;
+ int err;
if (!rxcb->is_first_msdu ||
!(rxcb->is_first_msdu && rxcb->is_last_msdu)) {
@@ -1020,13 +1020,13 @@ static int ath12k_dp_rx_h_undecap_raw(struct ath12k_pdev_dp *dp_pdev,
if (msdu->len <= FCS_LEN)
return -EINVAL;
- skb_trim(msdu, msdu->len - FCS_LEN);
+ err = pskb_trim(msdu, msdu->len - FCS_LEN);
+ if (err)
+ return err;
if (!decrypted)
return 0;
- hdr = (void *)msdu->data;
-
/* Tail */
if (status->flag & RX_FLAG_IV_STRIPPED) {
int icv_len = ath12k_dp_rx_crypto_icv_len(dp_pdev, enctype);
@@ -1035,7 +1035,9 @@ static int ath12k_dp_rx_h_undecap_raw(struct ath12k_pdev_dp *dp_pdev,
if (msdu->len < mic_len + icv_len)
return -EINVAL;
- skb_trim(msdu, msdu->len - (mic_len + icv_len));
+ err = pskb_trim(msdu, msdu->len - (mic_len + icv_len));
+ if (err)
+ return err;
} else {
/* MIC */
if (status->flag & RX_FLAG_MIC_STRIPPED) {
@@ -1044,7 +1046,9 @@ static int ath12k_dp_rx_h_undecap_raw(struct ath12k_pdev_dp *dp_pdev,
if (msdu->len < mic_len)
return -EINVAL;
- skb_trim(msdu, msdu->len - mic_len);
+ err = pskb_trim(msdu, msdu->len - mic_len);
+ if (err)
+ return err;
}
/* ICV */
@@ -1056,22 +1060,31 @@ static int ath12k_dp_rx_h_undecap_raw(struct ath12k_pdev_dp *dp_pdev,
if (msdu->len < icv_len)
return -EINVAL;
- skb_trim(msdu, msdu->len - icv_len);
+ err = pskb_trim(msdu, msdu->len - icv_len);
+ if (err)
+ return err;
}
}
/* MMIC */
- if ((status->flag & RX_FLAG_MMIC_STRIPPED) &&
- !ieee80211_has_morefrags(hdr->frame_control) &&
- enctype == HAL_ENCRYPT_TYPE_TKIP_MIC) {
- if (msdu->len < MICHAEL_MIC_LEN)
- return -EINVAL;
+ if (status->flag & RX_FLAG_MMIC_STRIPPED) {
+ struct ieee80211_hdr *hdr = (void *)msdu->data;
- skb_trim(msdu, msdu->len - MICHAEL_MIC_LEN);
+ if (enctype == HAL_ENCRYPT_TYPE_TKIP_MIC &&
+ !ieee80211_has_morefrags(hdr->frame_control)) {
+ if (msdu->len < MICHAEL_MIC_LEN)
+ return -EINVAL;
+
+ err = pskb_trim(msdu, msdu->len - MICHAEL_MIC_LEN);
+ if (err)
+ return err;
+ }
}
/* Head */
if (status->flag & RX_FLAG_IV_STRIPPED) {
+ struct ieee80211_hdr *hdr = (void *)msdu->data;
+
hdr_len = ieee80211_hdrlen(hdr->frame_control);
crypto_len = ath12k_dp_rx_crypto_param_len(dp_pdev, enctype);
--
2.56.0
More information about the ath12k
mailing list