Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3751365pxj; Tue, 11 May 2021 11:03:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyzYtxrcDQo9qOQlGcTjmpFRoFA0ycvb0HD7JzkIHmpCM2u9fWMbSZvLM92w++D8b+SiML1 X-Received: by 2002:a19:c748:: with SMTP id x69mr22183989lff.37.1620756237119; Tue, 11 May 2021 11:03:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620756237; cv=none; d=google.com; s=arc-20160816; b=A9OD+23voasZnLD6JAib/VselGdbFwadz5v6fbsTUhKGufpVXGyiFUlufhldZFe6Ty lYA+EJirLZdyx7CmXL0n4EwmpfiZUhfhX3i3OAntQwhhtQLUUYsf9xsQVRArOqpTHJfd /soKR8vEWtQNikW6/yA0umWJ9D8WSpE/roozl1inO9MHETp57+g+BFwwwCfB5LoUZFz0 B2SpYRN8y4fRBZ3PJWFL4W1OIL9PdojErgrIBaPIGAMz6gxGMCDgwkoEQbka7YRhJaZO bx5z6z9wIJK7NME9/PIc8QWbi/Nokru+Vgt/JcA8zGyToAw8QlFZZOHmQ/S3YEakkHvF ZGNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=/YQVhCLpt4EF6U1APbzAAzW93qVtRVJG9TltvU6ZSm8=; b=nX0X2RVpIjgz55V0dHrau7tmU2XLfHhDfDK+lVWae+euJeLREZiMyrJB84gx6oT+1c xXo7hHWJOngQHdvPeBtwedKPzzvWExMnIrNpxKwAMmeLdp2RJGbYetMXuFRrZoFyypup nzXrpeH/6XB87hdZky+uPdBs7veDPblAgJf//AC+SlgaeStFYmTcBKt2j7Xbdn2PJa3i nmoFrYKXXj7g3loSVJiiqfyseZU5nVryvJ9gfKWGRI8hFCQS208nbRsCsKLHvBQqvywr bx2I3vELMrCmKgz1ix0gSpsP6YVFWigwD8EFHa1FEqoPkx1I7byTsKu6ybY0h/4I8Gjc vpiA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j19si22279795lfg.269.2021.05.11.11.03.27; Tue, 11 May 2021 11:03:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231693AbhEKSEZ (ORCPT + 99 others); Tue, 11 May 2021 14:04:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231561AbhEKSEV (ORCPT ); Tue, 11 May 2021 14:04:21 -0400 Received: from sipsolutions.net (s3.sipsolutions.net [IPv6:2a01:4f8:191:4433::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D055CC06175F; Tue, 11 May 2021 11:03:10 -0700 (PDT) Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.94.2) (envelope-from ) id 1lgWir-007aAS-9o; Tue, 11 May 2021 20:03:09 +0200 From: Johannes Berg To: linux-wireless@vger.kernel.org Cc: Mathy Vanhoef , stable@vger.kernel.org Subject: [PATCH 03/18] mac80211: properly handle A-MSDUs that start with an RFC 1042 header Date: Tue, 11 May 2021 20:02:44 +0200 Message-Id: <20210511200110.0b2b886492f0.I23dd5d685fe16d3b0ec8106e8f01b59f499dffed@changeid> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210511180259.159598-1-johannes@sipsolutions.net> References: <20210511180259.159598-1-johannes@sipsolutions.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Mathy Vanhoef Properly parse A-MSDUs whose first 6 bytes happen to equal a rfc1042 header. This can occur in practice when the destination MAC address equals AA:AA:03:00:00:00. More importantly, this simplifies the next patch to mitigate A-MSDU injection attacks. Cc: stable@vger.kernel.org Signed-off-by: Mathy Vanhoef Signed-off-by: Johannes Berg --- include/net/cfg80211.h | 4 ++-- net/mac80211/rx.c | 2 +- net/wireless/util.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index 5224f885a99a..58c2cd417e89 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -5760,7 +5760,7 @@ unsigned int ieee80211_get_mesh_hdrlen(struct ieee80211s_hdr *meshhdr); */ int ieee80211_data_to_8023_exthdr(struct sk_buff *skb, struct ethhdr *ehdr, const u8 *addr, enum nl80211_iftype iftype, - u8 data_offset); + u8 data_offset, bool is_amsdu); /** * ieee80211_data_to_8023 - convert an 802.11 data frame to 802.3 @@ -5772,7 +5772,7 @@ int ieee80211_data_to_8023_exthdr(struct sk_buff *skb, struct ethhdr *ehdr, static inline int ieee80211_data_to_8023(struct sk_buff *skb, const u8 *addr, enum nl80211_iftype iftype) { - return ieee80211_data_to_8023_exthdr(skb, NULL, addr, iftype, 0); + return ieee80211_data_to_8023_exthdr(skb, NULL, addr, iftype, 0, false); } /** diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c index 531232b91bc4..f14d32a5001d 100644 --- a/net/mac80211/rx.c +++ b/net/mac80211/rx.c @@ -2682,7 +2682,7 @@ __ieee80211_rx_h_amsdu(struct ieee80211_rx_data *rx, u8 data_offset) if (ieee80211_data_to_8023_exthdr(skb, ðhdr, rx->sdata->vif.addr, rx->sdata->vif.type, - data_offset)) + data_offset, true)) return RX_DROP_UNUSABLE; ieee80211_amsdu_to_8023s(skb, &frame_list, dev->dev_addr, diff --git a/net/wireless/util.c b/net/wireless/util.c index 382c5262d997..39966a873e40 100644 --- a/net/wireless/util.c +++ b/net/wireless/util.c @@ -542,7 +542,7 @@ EXPORT_SYMBOL(ieee80211_get_mesh_hdrlen); int ieee80211_data_to_8023_exthdr(struct sk_buff *skb, struct ethhdr *ehdr, const u8 *addr, enum nl80211_iftype iftype, - u8 data_offset) + u8 data_offset, bool is_amsdu) { struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; struct { @@ -629,7 +629,7 @@ int ieee80211_data_to_8023_exthdr(struct sk_buff *skb, struct ethhdr *ehdr, skb_copy_bits(skb, hdrlen, &payload, sizeof(payload)); tmp.h_proto = payload.proto; - if (likely((ether_addr_equal(payload.hdr, rfc1042_header) && + if (likely((!is_amsdu && ether_addr_equal(payload.hdr, rfc1042_header) && tmp.h_proto != htons(ETH_P_AARP) && tmp.h_proto != htons(ETH_P_IPX)) || ether_addr_equal(payload.hdr, bridge_tunnel_header))) -- 2.30.2