Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2883230pxj; Mon, 31 May 2021 13:34:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwG3yaCaJVxpu5XXBZcdG6k/3nvEUA2cyqbGe/b+cFr2YFgArRqRZxsHLn1JyzVQpy8pmIv X-Received: by 2002:aa7:d4c2:: with SMTP id t2mr10934452edr.144.1622493291779; Mon, 31 May 2021 13:34:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622493291; cv=none; d=google.com; s=arc-20160816; b=P1PisZvwRkvKZppHczHhFfRpZVsGPZKXdO0KInoxO0F8fzy66XqBof2G8m3pFPsLkp 3dHOZZxcmBKY1582n6y2Hz9aX+iQ4Yg9iiSmYCRHpD35nbVWxUA6QbH3ph8fLNCIPHg7 ouFddPrk8h5TSi3hy5sofPN8NmdVYdHZ9KTT7iTf3601ST4YHJOZhtlnbNwnES4PCUWL wmstCkJwiAGS8bVgrLacd/V/onTZEpqgL1+AxvceMe4kcCr02qtqQm3fUhc7AhvU0c1H HK+R9s1zhOcrvC+zNhv9ghu4FMtrQKbVsBSw6Whln2YDEpenloi+C4KBP0OaSBgJtnZN Xmew== 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=fdny86t0UxbIpUq8TxzYqsGT4T9695jeocbCTZTG25o=; b=MWH/UiPdjuZ2iQQiYxkpqAz7X7XSuTGiqL5nqqyTvRE5jQ6ZLOsuVQAA8i+Ccjim4n Sqgusu+qBpGquEsKTRuumIstqmpg8An0KapcAnB9YTaIUuZjTcb7oPZUAiiNv+IdUODf 5mi/76Pa4zcglin5rXRfqGQIfcOwfk6wj6fKsSuWhurn+WYlRzcBObeaFcKqd7DYinUc wZmjDMLXx2XM+ddzMH0j12M8hSHyiv7MYAXXuAfY2QK5Lz0duTm4oN/2cPZQig2U3Etz OPMknezpzbjxeq3IAZQ1Y2ZWnBf+EUjmUTyQPUrQaB1zjlBKi7CfUQkyNJdW3q4hjZw5 iYgw== 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 bt8si14231668ejb.153.2021.05.31.13.34.23; Mon, 31 May 2021 13:34:51 -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 S232198AbhEaUdy (ORCPT + 99 others); Mon, 31 May 2021 16:33:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232458AbhEaUdX (ORCPT ); Mon, 31 May 2021 16:33:23 -0400 Received: from sipsolutions.net (s3.sipsolutions.net [IPv6:2a01:4f8:191:4433::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF514C061756; Mon, 31 May 2021 13:31:42 -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 1lnoZY-000FBv-M7; Mon, 31 May 2021 22:31:40 +0200 From: Johannes Berg To: linux-wireless@vger.kernel.org Cc: stable@vger.kernel.org, Johannes Berg Subject: [PATCH v4.14 08/10] mac80211: prevent attacks on TKIP/WEP as well Date: Mon, 31 May 2021 22:31:33 +0200 Message-Id: <20210531203135.180427-9-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: Johannes Berg commit 7e44a0b597f04e67eee8cdcbe7ee706c6f5de38b upstream. Similar to the issues fixed in previous patches, TKIP and WEP should be protected even if for TKIP we have the Michael MIC protecting it, and WEP is broken anyway. However, this also somewhat protects potential other algorithms that drivers might implement. Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20210511200110.430e8c202313.Ia37e4e5b6b3eaab1a5ae050e015f6c92859dbe27@changeid Signed-off-by: Johannes Berg --- net/mac80211/rx.c | 12 ++++++++++++ net/mac80211/sta_info.h | 3 ++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c index a00ec2ccb363..61fe65696e6e 100644 --- a/net/mac80211/rx.c +++ b/net/mac80211/rx.c @@ -2048,6 +2048,7 @@ ieee80211_rx_h_defragment(struct ieee80211_rx_data *rx) * next fragment has a sequential PN value. */ entry->check_sequential_pn = true; + entry->is_protected = true; entry->key_color = rx->key->color; memcpy(entry->last_pn, rx->key->u.ccmp.rx_pn[queue], @@ -2060,6 +2061,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)) { + entry->is_protected = true; + entry->key_color = rx->key->color; } return RX_QUEUED; } @@ -2101,6 +2105,14 @@ ieee80211_rx_h_defragment(struct ieee80211_rx_data *rx) if (memcmp(pn, rpn, IEEE80211_CCMP_PN_LEN)) 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->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; } skb_pull(rx->skb, ieee80211_hdrlen(fc)); diff --git a/net/mac80211/sta_info.h b/net/mac80211/sta_info.h index 0447197c4a2b..f1d293f5678f 100644 --- a/net/mac80211/sta_info.h +++ b/net/mac80211/sta_info.h @@ -415,7 +415,8 @@ struct ieee80211_fragment_entry { u16 extra_len; u16 last_frag; u8 rx_queue; - bool check_sequential_pn; /* needed for CCMP/GCMP */ + u8 check_sequential_pn:1, /* needed for CCMP/GCMP */ + is_protected:1; u8 last_pn[6]; /* PN of the last fragment if CCMP was used */ unsigned int key_color; }; -- 2.31.1