Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2720356pxj; Mon, 31 May 2021 09:04:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyTCSSc+4OZ2glIfWl34GvsgdR+oRyuAyLCeYOEkZ/hZOS/bHNM0812awIHur25ZT+LY7rH X-Received: by 2002:a50:9990:: with SMTP id m16mr25863122edb.292.1622477044260; Mon, 31 May 2021 09:04:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622477044; cv=none; d=google.com; s=arc-20160816; b=e/j7EyJK0lrEf7sFi/pOLJHRb9QtN8pJHkQZvNZ0PBoZCjhl3kex9a7Kog3waJVCND 29m47BoL4aQrEkBzWEypV5oYitw3lm+fPS9eYR2dlPSPkRKgu6uXB/F8ptbE/GmlfGqR Axrlx/WPT32zemncqPxWr9hiClitVbCq1tHTVrtVH9P0XgMNBeHWq5h7LALjsyF4WkKJ ld/lEvdtfix96z6MdaXVfvBLHSA0XCm+iaZZAmbhW2d/k1q907svkZyTtwTxeYyXFrvw XF9wY8/j5sWiI2Zhqo8IpYJ5j1cpHHO97uPEYxkcCtKEaBFh7Ww7llmTRRS5JNmipT9U QImA== 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=LKvDQAwCgsYF6I1Zw9/op2gn4Y5118X0oIQqthz9en8=; b=Ird3Wm3Qay0dqrGRG2gXOhdxw7K5oMKOdMPL1RJlwxHlv7EGax8FL5Ef6huuARikIv 5HSM0Boxqv20cjocUCChPPc7YBm7222bmd4c6YM8BUpbiNIX/AgvFe/29RVhotQB1tRJ Oup2QjqFxSDCfKWEMOEsNjsdEX1qtj1ro5rlDssZzeOAvh8C1YmeblSGV+VDUsBLu939 B4Drwsm3RnQGaYSPcxjwXkPhy4uXk7Xkso6xnWlsRt6L2UKD4RMUZm/hmaZokp7dvA0J NTLPSVa1r6M1U93lsg1duC4cF45be/HhrFHdlDCHfSgSNXiG/ZN961Wk1laFunj0l2GP qasg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=l1jCylg6; 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 z25si6957895edq.402.2021.05.31.09.03.42; Mon, 31 May 2021 09:04:04 -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=l1jCylg6; 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 S231580AbhEaQCU (ORCPT + 99 others); Mon, 31 May 2021 12:02:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:33150 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233669AbhEaOdb (ORCPT ); Mon, 31 May 2021 10:33:31 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D8BEC613B4; Mon, 31 May 2021 13:50:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1622469008; bh=2/O+k+1G/PXQ2nFOWXizGHcE7185hUsTaFemAusCs5c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=l1jCylg6vl6N5IR2lRrGxRBZ8NJz25S8VOQwvSKJdItGI2WsQa4kapteAQD6QM0tx 1M4fzStCZMA78YVxLlMmMR0Qf0F8o9gkBq7EvDAg7jGSfX09rCjenfD34zTMzIyWvy J/HG3o5vzO40PQULVUdEVlQZ9uBspLfr004AxM0E= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mathy Vanhoef , Johannes Berg Subject: [PATCH 5.12 035/296] mac80211: assure all fragments are encrypted Date: Mon, 31 May 2021 15:11:30 +0200 Message-Id: <20210531130704.995510531@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210531130703.762129381@linuxfoundation.org> References: <20210531130703.762129381@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: Mathy Vanhoef commit 965a7d72e798eb7af0aa67210e37cf7ecd1c9cad upstream. Do not mix plaintext and encrypted fragments in protected Wi-Fi networks. This fixes CVE-2020-26147. Previously, an attacker was able to first forward a legitimate encrypted fragment towards a victim, followed by a plaintext fragment. The encrypted and plaintext fragment would then be reassembled. For further details see Section 6.3 and Appendix D in the paper "Fragment and Forge: Breaking Wi-Fi Through Frame Aggregation and Fragmentation". Because of this change there are now two equivalent conditions in the code to determine if a received fragment requires sequential PNs, so we also move this test to a separate function to make the code easier to maintain. Cc: stable@vger.kernel.org Signed-off-by: Mathy Vanhoef Link: https://lore.kernel.org/r/20210511200110.30c4394bb835.I5acfdb552cc1d20c339c262315950b3eac491397@changeid Signed-off-by: Johannes Berg Signed-off-by: Greg Kroah-Hartman --- net/mac80211/rx.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) --- a/net/mac80211/rx.c +++ b/net/mac80211/rx.c @@ -2193,6 +2193,16 @@ ieee80211_reassemble_find(struct ieee802 return NULL; } +static bool requires_sequential_pn(struct ieee80211_rx_data *rx, __le16 fc) +{ + return rx->key && + (rx->key->conf.cipher == WLAN_CIPHER_SUITE_CCMP || + rx->key->conf.cipher == WLAN_CIPHER_SUITE_CCMP_256 || + rx->key->conf.cipher == WLAN_CIPHER_SUITE_GCMP || + rx->key->conf.cipher == WLAN_CIPHER_SUITE_GCMP_256) && + ieee80211_has_protected(fc); +} + static ieee80211_rx_result debug_noinline ieee80211_rx_h_defragment(struct ieee80211_rx_data *rx) { @@ -2237,12 +2247,7 @@ ieee80211_rx_h_defragment(struct ieee802 /* This is the first fragment of a new frame. */ entry = ieee80211_reassemble_add(rx->sdata, frag, seq, rx->seqno_idx, &(rx->skb)); - if (rx->key && - (rx->key->conf.cipher == WLAN_CIPHER_SUITE_CCMP || - rx->key->conf.cipher == WLAN_CIPHER_SUITE_CCMP_256 || - rx->key->conf.cipher == WLAN_CIPHER_SUITE_GCMP || - rx->key->conf.cipher == WLAN_CIPHER_SUITE_GCMP_256) && - ieee80211_has_protected(fc)) { + if (requires_sequential_pn(rx, fc)) { int queue = rx->security_idx; /* Store CCMP/GCMP PN so that we can verify that the @@ -2284,11 +2289,7 @@ ieee80211_rx_h_defragment(struct ieee802 u8 pn[IEEE80211_CCMP_PN_LEN], *rpn; int queue; - if (!rx->key || - (rx->key->conf.cipher != WLAN_CIPHER_SUITE_CCMP && - rx->key->conf.cipher != WLAN_CIPHER_SUITE_CCMP_256 && - rx->key->conf.cipher != WLAN_CIPHER_SUITE_GCMP && - rx->key->conf.cipher != WLAN_CIPHER_SUITE_GCMP_256)) + if (!requires_sequential_pn(rx, fc)) return RX_DROP_UNUSABLE; memcpy(pn, entry->last_pn, IEEE80211_CCMP_PN_LEN); for (i = IEEE80211_CCMP_PN_LEN - 1; i >= 0; i--) {