Skip to contentSkip to conversation

wifi: ath6kl: avoid A-MSDU subframe overread in aggr_slice_amsdu()

PATCH New Maoyi Xie 1 participant 1 message Nov 19

Subsystems (2)
lore
Share & tools
lore

Maoyi Xie

author
#0 lore raw

PATCH 1/1 wifi: ath6kl: avoid A-MSDU subframe overread in aggr_slice_amsdu()

For each subframe from the device, aggr_slice_amsdu() checks the payload length only against the range 46 to 1508, not against amsdu_len, the bytes left. A subframe longer than the bytes left makes memcpy() read past the received data. The u16 amsdu_len also wraps when the frame ends inside the padding of a subframe or is shorter than an Ethernet header. The loop then reads past the frame.

Check each subframe and its padding against the bytes left. Treat a frame shorter than an Ethernet header as empty.

Found with a CodeQL-based static analysis tool that we are developing. Reproduced in a userspace harness under AddressSanitizer, which reports nothing in aggr_slice_amsdu() with this patch. Not tested on hardware, only compile-tested with W=1 on next-20261116.

Fixes bdcd81707973 ("Add ath6kl cleaned up driver")

---
I used an LLM to help write the harness and this patch.

 drivers/net/wireless/ath/ath6kl/txrx.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/ath6kl/txrx.c +5 -2
index 609d458ca6c5730..7ae14d470627276 100644
@@ -997,14 +997,15 @@ static void aggr_slice_amsdu(struct aggr_info *p_aggr,
 
 	mac_hdr_len = sizeof(struct ethhdr);
 	framep = skb->data + mac_hdr_len;
-	amsdu_len = skb->len - mac_hdr_len;
+	amsdu_len = skb->len > mac_hdr_len ? skb->len - mac_hdr_len : 0;
 
 	while (amsdu_len > mac_hdr_len) {
 		hdr = (struct ethhdr *) framep;
 		payload_8023_len = be16_to_cpu(hdr->h_proto);
 
 		if (payload_8023_len < MIN_MSDU_SUBFRAME_PAYLOAD_LEN ||
-		    payload_8023_len > MAX_MSDU_SUBFRAME_PAYLOAD_LEN) {
+		    payload_8023_len > MAX_MSDU_SUBFRAME_PAYLOAD_LEN ||
+		    payload_8023_len + mac_hdr_len > amsdu_len) {
 			ath6kl_err("802.3 AMSDU frame bound check failed. len %d\n",
 				   payload_8023_len);
 			break;
@@ -1035,6 +1036,8 @@ static void aggr_slice_amsdu(struct aggr_info *p_aggr,
 		 * Round to nearest word.
 		 */
 		frame_8023_len = ALIGN(frame_8023_len, 4);
+		if (frame_8023_len > amsdu_len)
+			break;
 
 		framep += frame_8023_len;
 		amsdu_len -= frame_8023_len;

base-commit: 7e1392a42ea288d70a266f6553fe06f57f8647ea

Signature · 1 line
2.34.1