Skip to content

Commit 44b84d4

Browse files
pvts-matPlaidCat
authored andcommitted
wifi: cfg80211: check A-MSDU format more carefully
jira VULN-5183 cve CVE-2024-35937 commit-author Johannes Berg <johannes.berg@intel.com> commit 9ad7974 upstream-diff | 1. All changes to the `ieee80211_is_valid_amsdu' function were discarded because it's missing from `ciqlts9_2'. 2. Changes to `ieee80211_amsdu_to_8023s' were adapted to account for the missing 986e43b from `ciqlts9_2' history: the `copy_len > remaining' condition was changed to `sizeof(eth) > remaining', as `sizeof(eth)' is the only possible value `copy_len' could have assumed in `ciqlts9_2' if it was introduced without backporting 986e43b (pointless). If it looks like there's another subframe in the A-MSDU but the header isn't fully there, we can end up reading data out of bounds, only to discard later. Make this a bit more careful and check if the subframe header can even be present. Reported-by: syzbot+d050d437fe47d479d210@syzkaller.appspotmail.com Link: https://msgid.link/20240226203405.a731e2c95e38.I82ce7d8c0cc8970ce29d0a39fdc07f1ffc425be4@changeid Signed-off-by: Johannes Berg <johannes.berg@intel.com> (cherry picked from commit 9ad7974) Signed-off-by: Marcin Wcisło <marcin.wcislo@conclusive.pl>
1 parent c0d4ece commit 44b84d4

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

net/wireless/util.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -757,24 +757,27 @@ void ieee80211_amsdu_to_8023s(struct sk_buff *skb, struct sk_buff_head *list,
757757
struct sk_buff *frame = NULL;
758758
u16 ethertype;
759759
u8 *payload;
760-
int offset = 0, remaining;
760+
int offset = 0;
761761
struct ethhdr eth;
762762
bool reuse_frag = skb->head_frag && !skb_has_frag_list(skb);
763763
bool reuse_skb = false;
764764
bool last = false;
765765

766766
while (!last) {
767+
int remaining = skb->len - offset;
767768
unsigned int subframe_len;
768769
int len;
769770
u8 padding;
770771

772+
if (sizeof(eth) > remaining)
773+
goto purge;
774+
771775
skb_copy_bits(skb, offset, &eth, sizeof(eth));
772776
len = ntohs(eth.h_proto);
773777
subframe_len = sizeof(struct ethhdr) + len;
774778
padding = (4 - subframe_len) & 0x3;
775779

776780
/* the last MSDU has no padding */
777-
remaining = skb->len - offset;
778781
if (subframe_len > remaining)
779782
goto purge;
780783
/* mitigate A-MSDU aggregation injection attacks */

0 commit comments

Comments
 (0)