Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2883354pxj; Mon, 31 May 2021 13:35:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz6cdRMQyGy8QIquH5NdLuaD83tQPvlkSbpw1fCcdNSjXWm2hAsqCciIZCszy3rzmElTAal X-Received: by 2002:a17:907:6288:: with SMTP id nd8mr24728305ejc.223.1622493303561; Mon, 31 May 2021 13:35:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622493303; cv=none; d=google.com; s=arc-20160816; b=wi8IvdkKnIG9m1jbstF1Uz5O267tUNPCFILQp4JhReAOwUu5en2rfQ9zRGxYmJjN2U mXt1/2tME6Bq5puz6j/+tJwIYD9QkeExd0GFUlPbKZiF8WvBof6LgcMzGKcjOJAaBWRb dP0nXjwH3GUHVjskrVebBkv16/0DuluNWSLgX2IScK3cL1tbwVZgt+1YiQ3YyzxmhaID bs4EyZjDRv/2eJ6hM1ccqziD/NYBFahdkDF1agUdEl0NCljiFPSlAwM6DC1bNLchx0nK 2Bv/A3EBjJv/aZHProGmO0FO8rQXrOGFX4njc7wbiJlB81Y0Wbc9JtYquJ9rKE7s3dFf pBUw== 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=Be08IyfcULSnurh+TuT+l3cNczpwzhRzwUGi0lrhnVY=; b=JR5F/ee63oH/M+Ccm3vv19uKTwHXn4x5yywZ8Gjo1+3f1jbOR007W5K/PqmfLT0EA5 bO7OFVQkevhzvuEOuueBNdofmH46cZEiAiCYfSPvXtC/YAppIEv/ZBWTOn4XiQ27MGNp /MWQOlhFhqKS1QQBJ/RhcdpKaSns9nxw2RJYAXgPliD5YgkOrxdrXyb3kbIxv4wylBhU UtK5wy+66X6rJWt6nkrSajlxsZbDuuYrcLJtrgTVPqbDwUw23QnvDSiutWBJScyL/FWS /NAwsgGpwunqv1hwWXLz67qzogNln/jUifeuXdJmy5jNLtuYxDRGY3/jbKJrNS+v1BYm D+aw== 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 ju18si1746305ejc.455.2021.05.31.13.34.40; Mon, 31 May 2021 13:35:03 -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 S232507AbhEaUd6 (ORCPT + 99 others); Mon, 31 May 2021 16:33:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232481AbhEaUdZ (ORCPT ); Mon, 31 May 2021 16:33:25 -0400 Received: from sipsolutions.net (s3.sipsolutions.net [IPv6:2a01:4f8:191:4433::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8ECA1C06174A; Mon, 31 May 2021 13:31:43 -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 1lnoZZ-000FBv-Ox; Mon, 31 May 2021 22:31:41 +0200 From: Johannes Berg To: linux-wireless@vger.kernel.org Cc: stable@vger.kernel.org, Wen Gong Subject: [PATCH v4.14 10/10] mac80211: extend protection against mixed key and fragment cache attacks Date: Mon, 31 May 2021 22:31:35 +0200 Message-Id: <20210531203135.180427-11-johannes@sipsolutions.net> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210531203135.180427-1-johannes@sipsolutions.net> References: <20210531203135.180427-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: Wen Gong commit 3edc6b0d6c061a70d8ca3c3c72eb1f58ce29bfb1 upstream. For some chips/drivers, e.g., QCA6174 with ath10k, the decryption is done by the hardware, and the Protected bit in the Frame Control field is cleared in the lower level driver before the frame is passed to mac80211. In such cases, the condition for ieee80211_has_protected() is not met in ieee80211_rx_h_defragment() of mac80211 and the new security validation steps are not executed. Extend mac80211 to cover the case where the Protected bit has been cleared, but the frame is indicated as having been decrypted by the hardware. This extends protection against mixed key and fragment cache attack for additional drivers/chips. This fixes CVE-2020-24586 and CVE-2020-24587 for such cases. Tested-on: QCA6174 hw3.2 PCI WLAN.RM.4.4.1-00110-QCARMSWP-1 Cc: stable@vger.kernel.org Signed-off-by: Wen Gong Signed-off-by: Jouni Malinen Link: https://lore.kernel.org/r/20210511200110.037aa5ca0390.I7bb888e2965a0db02a67075fcb5deb50eb7408aa@changeid Signed-off-by: Johannes Berg --- net/mac80211/rx.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c index 2fe18dc6af86..6b4fd56800f7 100644 --- a/net/mac80211/rx.c +++ b/net/mac80211/rx.c @@ -2003,6 +2003,7 @@ ieee80211_rx_h_defragment(struct ieee80211_rx_data *rx) unsigned int frag, seq; struct ieee80211_fragment_entry *entry; struct sk_buff *skb; + struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(rx->skb); hdr = (struct ieee80211_hdr *)rx->skb->data; fc = hdr->frame_control; @@ -2061,7 +2062,9 @@ ieee80211_rx_h_defragment(struct ieee80211_rx_data *rx) sizeof(rx->key->u.gcmp.rx_pn[queue])); BUILD_BUG_ON(IEEE80211_CCMP_PN_LEN != IEEE80211_GCMP_PN_LEN); - } else if (rx->key && ieee80211_has_protected(fc)) { + } else if (rx->key && + (ieee80211_has_protected(fc) || + (status->flag & RX_FLAG_DECRYPTED))) { entry->is_protected = true; entry->key_color = rx->key->color; } @@ -2106,13 +2109,19 @@ ieee80211_rx_h_defragment(struct ieee80211_rx_data *rx) return RX_DROP_UNUSABLE; memcpy(entry->last_pn, pn, IEEE80211_CCMP_PN_LEN); } else if (entry->is_protected && - (!rx->key || !ieee80211_has_protected(fc) || + (!rx->key || + (!ieee80211_has_protected(fc) && + !(status->flag & RX_FLAG_DECRYPTED)) || rx->key->color != entry->key_color)) { /* Drop this as a mixed key or fragment cache attack, even * if for TKIP Michael MIC should protect us, and WEP is a * lost cause anyway. */ return RX_DROP_UNUSABLE; + } else if (entry->is_protected && rx->key && + entry->key_color != rx->key->color && + (status->flag & RX_FLAG_DECRYPTED)) { + return RX_DROP_UNUSABLE; } skb_pull(rx->skb, ieee80211_hdrlen(fc)); -- 2.31.1