wifi: mac80211: recheck injected headers after removing FCS
Subsystems (2)
PATCH 1/1 wifi: mac80211: recheck injected headers after removing FCS
Injecting a short frame with IEEE80211_RADIOTAP_F_FCS on a monitor interface can pass a truncated 802.11 header to transmit handlers.
ieee80211_monitor_start_xmit() validates the linear 802.11 header before parsing radiotap. Radiotap parsing then removes the four-byte FCS without rechecking the remaining header length. Software encryption can subtract the larger header length and pass the resulting negative length as an unsigned size.
Recheck the required linear header length after pulling the radiotap header and before handing the frame to the transmit path. Require at least addr1, which the transmit path reads even for extension frames whose header is shorter.
LLM assistance was used to find the bug and review.
---
Validation: A W=1 module build with MODPOST passed. In a QEMU KASAN guest on the declared base, six truncated data and QoS-data injections with the FCS flag reached transmit before the change and were dropped after it. Injections that keep a full header, including 10-byte ACK and extension frames, were unchanged. KASAN reported nothing in either kernel, as expected for a length check. A reproducer is available on request.
Sparse C=2 passed. Targeted Smatch introduced no new diagnostics.
net/mac80211/tx.c | 6 ++++++ 1 file changed, 6 insertions(+)
net/mac80211/tx.c +6 -0
@@ -2511,6 +2511,12 @@ netdev_tx_t ieee80211_monitor_start_xmit(struct sk_buff *skb,/* remove the injection radiotap header */ skb_pull (skb, len_rthdr); +/* FCS removal may have shortened the 802.11 header. */ + hdrlen =max_t (int, hdrlen, + offsetofend(struct ieee80211_hdr, addr1)); +if (skb_headlen (skb) < hdrlen) + goto fail_rcu; +ieee80211_xmit (sdata,NULL , skb);rcu_read_unlock ();
base-commit: 25e73f1d6868c759c8eb56cad4e411692c5341b4
Signature · 1 line
2.56.0