Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2687702pxj; Mon, 31 May 2021 08:16:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy2PiWdNMiVs+T6qmtDvL8aKf68dSksq+uWQhzwwFOOHgOOAKNsnorYVVvvjFay1KnaJgDr X-Received: by 2002:a17:906:6dd0:: with SMTP id j16mr23588078ejt.208.1622474188721; Mon, 31 May 2021 08:16:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622474188; cv=none; d=google.com; s=arc-20160816; b=aSZBgcGyxC1VgMJ8fqWBDwGSdgT0pXsi8pxZDUv0D3u4p9zLMAa1gqGojloMzFGKHq l3gkcRgAe3Qfvpqvjr6sNfWZWC7EMD2zWKEiwHXp3B9RB46uBDDPvs+7h8+An2k0QwC4 evTc+DQWO2JSZ45CqaUprMm6npLUXspxgvG4QnPCEDJZP3CF+hto5ZFr7zfTgQUFLZ2X bitlVdmTMpWiVY4ysph4Iu09Rr4OpXUocuNyvCZL4W+XjFw4xcAA0V51ffraiBElWA+S wFtDD2g8dBHowwvx7p5ApTsS8w61WoMdO3yQxfhVU0Sf1ko5OjwNXimlhNlwR0xStpW3 SRhg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=1qAOTDwiOldv1H5y5yZLzSprOuy2h0HZMktcakIwIDo=; b=xiGoj3gIH7fIG/f715+Mw418pRi3A9mj7iTdAkxeDBCwTXncxQtYl1q9iq3GzitBfu zWN5MM5Ce5ecVz9DNCjPChCwS+5J8c0qWu6y5GjsFNNepG4rdSgAfaYGne7GMFzEwNFF wlrSPRqXXWCrdT/Mv+/llaCKngzm3EVYhullnxvja0u9aHUuO+OAla8tGbHCL0aeKO77 noIrozsSamMLUuP9Y1mPxL+HJ+uCZCvUQl2Y36ZOzplbpUIuUR/2e9BoSd+hqw2LIzPX XD2/HGRIX+n2bPMD8tGoxKwAVWnSCC99mUWRWHWoSbRMzRL5MmBx58WgS8ACVvOrElig tejw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=LlCqKTdG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a1si192102eje.497.2021.05.31.08.16.06; Mon, 31 May 2021 08:16:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=LlCqKTdG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232947AbhEaPQr (ORCPT + 99 others); Mon, 31 May 2021 11:16:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:43306 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232571AbhEaONi (ORCPT ); Mon, 31 May 2021 10:13:38 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2BDD061991; Mon, 31 May 2021 13:42:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1622468525; bh=ltcpFpzwagyBwKWZ8PwHzZWhWjauqAAww2zfiy7o9cQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LlCqKTdGOMVjzmleWCUPY6OkfR8kNcob+IYLOlSNAabJtouUwJ/tfVO3PrLvzPck/ y/t1BqvLcngbQQgIinBn3guv1VxZCOGoGaYA3CloU9gmPPhNyI1qu5KMah5IYHOXB2 O03QuCiVLXM1KYS2QFrzt7F9eRMD/xUXGuxIaqnQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Wen Gong , Jouni Malinen , Johannes Berg Subject: [PATCH 5.4 023/177] mac80211: extend protection against mixed key and fragment cache attacks Date: Mon, 31 May 2021 15:13:00 +0200 Message-Id: <20210531130648.721141814@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210531130647.887605866@linuxfoundation.org> References: <20210531130647.887605866@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 Signed-off-by: Greg Kroah-Hartman --- net/mac80211/rx.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) --- a/net/mac80211/rx.c +++ b/net/mac80211/rx.c @@ -2189,6 +2189,7 @@ ieee80211_rx_h_defragment(struct ieee802 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; @@ -2247,7 +2248,9 @@ ieee80211_rx_h_defragment(struct ieee802 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; } @@ -2292,13 +2295,19 @@ ieee80211_rx_h_defragment(struct ieee802 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));