Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2700754pxj; Mon, 31 May 2021 08:34:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxGOK3RTumFIC0gQw8JalpYSeZnnH+I/uDJAmztuc3vMH85XxvruF2UYLmhVzm7rYNjknhu X-Received: by 2002:a6b:f618:: with SMTP id n24mr7164221ioh.174.1622475277155; Mon, 31 May 2021 08:34:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622475277; cv=none; d=google.com; s=arc-20160816; b=UHS2CyYv291KZ6eGJB1pjOt1H/eoZs0uupv114TFYHZprEX1Flyk/wZLPtEU2vt8Gs EQ5NXNJoySqTCWCVFZK9EDh8qrkgHDeJn75SW8sHepKvOVCrryRqH7waBVXrPqmnqEdL b6GFl7/t4DEyo7xs3+fdcet41o8wWRGVnshIjnQ2bDUJ5Ju9nYhpPfbMJPH9NwNco/os +cQWa5Z53HWCrRuBwtoOg/8viTIcrm+bi5K5J0LT9J5cEHT2meuED4TOtdMeidiLP4DX hKiaw/TC8Qq4ASgIaBaZ2zeY4TL9CVQsExIv4aEys3xoyHFn/2I445uNSzurYCm8FLYw uPog== 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=PUT8zOyRj4hzyabun2Kadj5ZEZi0SWmFW0Zw1PafyLU=; b=OcT+8zsZQ0fwfh6ld5t6UvXvuF8nTAyD6Kp2eWpAy7HGc+RkCCza7eDzAybDxxdq76 ZmqJq1s+9IjHK4QdXV/s/ZXDRjDZaybypZhV7jxixaKedgq8n/pcuyHt7nLOAsv4apmO f2JS3UxYIqZZVP4IFG552eIkp/YiqdUl1XlhxNM+xujU4kVVd+7sgmzQjoctaZxvnmkx UfOz3M/uRTi3rgWTyC02m0Mke8JKOMgIDsQpmmNPN3scA02bpUYkS0HJJhigAaVAIQ1w zYlGbePsFumNTf88OrhM7w69ftaIbC/qzhCQNuy/J26JAsdn1r6NVu6Tbf7nImgR6f4x C8eA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=0fwN9pJp; 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 e15si13051807iom.19.2021.05.31.08.34.23; Mon, 31 May 2021 08:34:37 -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=0fwN9pJp; 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 S234000AbhEaPf0 (ORCPT + 99 others); Mon, 31 May 2021 11:35:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:43712 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232153AbhEaOQB (ORCPT ); Mon, 31 May 2021 10:16:01 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5BDE3619A4; Mon, 31 May 2021 13:43:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1622468590; bh=81HEX3wfGTS5qyC4+VS4SZfAh54TQnf3Kpe1DR6KXDs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0fwN9pJpvIXgLuefprmgCay18Uh8vaqNBr31F7bHS4MHotE8fxK4ptjfRDmPqt4A2 TKYOv0cuHq4ujasF2d937bILIjp8B5EoQlTO3eHCec/dz8AxeLg3qz3RAUOSjVLAXl xBjuLHjUH6d/bcBx/dwgDzHMfjz7/dBGS5j5YJ8k= 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.4 014/177] mac80211: assure all fragments are encrypted Date: Mon, 31 May 2021 15:12:51 +0200 Message-Id: <20210531130648.400682153@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: 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 @@ -2154,6 +2154,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) { @@ -2198,12 +2208,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 @@ -2245,11 +2250,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--) {