Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3609231pxb; Mon, 24 Jan 2022 13:26:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJxVuJP7mW64oPt/k9al5tqa6Hg7ViHewHOZK7pjDOkiTuKZL2QAHJk9K23/Peq3xb/tSyS8 X-Received: by 2002:a63:c6:: with SMTP id 189mr12844062pga.85.1643059529268; Mon, 24 Jan 2022 13:25:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643059529; cv=none; d=google.com; s=arc-20160816; b=cCqaT4/oXBNjdZyGbF3TE/5PrGYNGKAEWOdPjrp7OOVx0dSS/oFITEL5zVt1kNqI0U l5xN2r6obXQ69XiBzlC2H+s3XjH00k23mEddPuHZhyfmoqoJTIdXfWaomODLt7FXRcUa 9ZStKaq0QQtKY3VPKFcyAdqNC5zz4SBfS1eWuQ/W/FoPRfo9bIKiPBGpvWprVIukbHjr 7rGUtpaDcPu1N6BIiuyc9+mu09Kpqi/kkKtQ9agwRI3rKzwX7Vy17SXE1rEwdoZNQvlL NW/+BivVgJ8pXp6NjvN2zf9lyExW6Xk9pSuNAviyYvmYi++raGlJXEPraXnaVOCYNy1J bOYA== 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=vRV6GLKaji9wK4pcFa5W2eFjY8UpamUN/D6ipaLt6xY=; b=xfesiH8qqD3EYZHlos6bAiuMo5QLamxLrL7ZgQ875FJne4qnHWdnkXauQESvqAVPej hrMbuxZlQkp6AYvuvpKHguSMKssKGoV5JMRZ7Vrq61YSRlV7AHB99dBjyhowOnDRr1Fz tKaY1ipRuUbrToqtzcdtPP0JUwZ4imJmRo3CnEk+aE7UsM8ff+iWihyAXQaDUbzcdzaU dI1p8+tIxJbzvjS1Ei+ZmSE3BxgHg55GWosVhbiBLGqG2786PUQcEMW4+Ul4Sq0Qpj8b +njaL8T15UtzwZt0aVAz4akAdndKZgo9NX8wOj2DuGUFq5E/AtySrgsD+OV+NErLr/ot ZBGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=kEDrvfHo; 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 i13si13223220pla.617.2022.01.24.13.25.13; Mon, 24 Jan 2022 13:25:29 -0800 (PST) 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=kEDrvfHo; 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 S1444887AbiAXVBm (ORCPT + 99 others); Mon, 24 Jan 2022 16:01:42 -0500 Received: from ams.source.kernel.org ([145.40.68.75]:40788 "EHLO ams.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1388174AbiAXUiQ (ORCPT ); Mon, 24 Jan 2022 15:38:16 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id B45DFB80FA1; Mon, 24 Jan 2022 20:38:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DA563C340E5; Mon, 24 Jan 2022 20:38:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643056693; bh=RrUyY9uG7ZVfU+KF3Jfwg3xQPcg+XRDfLecSIqdmf5w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kEDrvfHoxUVkaxwJyknSQ/9yvGNFzxa0bQeUvvJ9SSPOb5WomTbj4BdQd1kTPegeA wSbtzJgiUM6+K8CmwOQxvOXEB5bf29G4su1GKeaQe7ZLUJNTv/WgpLuJgTOkv3+Ecr gmkxhjE7dlCx/3IhRqze6eCD6sUWecQnqVc8PNcA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xing Song , Felix Fietkau , Sasha Levin Subject: [PATCH 5.15 568/846] mt76: do not pass the received frame with decryption error Date: Mon, 24 Jan 2022 19:41:25 +0100 Message-Id: <20220124184120.626138799@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184100.867127425@linuxfoundation.org> References: <20220124184100.867127425@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: Xing Song [ Upstream commit dd28dea52ad9376d2b243a8981726646e1f60b1a ] MAC80211 doesn't care any decryption error in 802.3 path, so received frame will be dropped if HW tell us that the cipher configuration is not matched as well as the header has been translated to 802.3. This case only appears when IEEE80211_FCTL_PROTECTED is 0 and cipher suit is not none in the corresponding HW entry. The received frame is only reported to monitor interface if HW decryption block tell us there is ICV error or CCMP/BIP/WPI MIC error. Note in this case the reported frame is decrypted 802.11 frame and the payload may be malformed due to mismatched key. Signed-off-by: Xing Song Signed-off-by: Felix Fietkau Signed-off-by: Sasha Levin --- drivers/net/wireless/mediatek/mt76/mt7603/mac.c | 4 ++++ drivers/net/wireless/mediatek/mt76/mt7615/mac.c | 9 ++++++++- drivers/net/wireless/mediatek/mt76/mt7915/mac.c | 9 ++++++++- drivers/net/wireless/mediatek/mt76/mt7921/mac.c | 9 ++++++++- 4 files changed, 28 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7603/mac.c b/drivers/net/wireless/mediatek/mt76/mt7603/mac.c index 3972c56136a20..65f1f2bb80835 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7603/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7603/mac.c @@ -525,6 +525,10 @@ mt7603_mac_fill_rx(struct mt7603_dev *dev, struct sk_buff *skb) if (rxd2 & MT_RXD2_NORMAL_TKIP_MIC_ERR) status->flag |= RX_FLAG_MMIC_ERROR; + /* ICV error or CCMP/BIP/WPI MIC error */ + if (rxd2 & MT_RXD2_NORMAL_ICV_ERR) + status->flag |= RX_FLAG_ONLY_MONITOR; + if (FIELD_GET(MT_RXD2_NORMAL_SEC_MODE, rxd2) != 0 && !(rxd2 & (MT_RXD2_NORMAL_CLM | MT_RXD2_NORMAL_CM))) { status->flag |= RX_FLAG_DECRYPTED; diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mac.c b/drivers/net/wireless/mediatek/mt76/mt7615/mac.c index 5455231f51881..f2704149834a0 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7615/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7615/mac.c @@ -286,9 +286,16 @@ static int mt7615_mac_fill_rx(struct mt7615_dev *dev, struct sk_buff *skb) if (rxd2 & MT_RXD2_NORMAL_AMSDU_ERR) return -EINVAL; + hdr_trans = rxd1 & MT_RXD1_NORMAL_HDR_TRANS; + if (hdr_trans && (rxd2 & MT_RXD2_NORMAL_CM)) + return -EINVAL; + + /* ICV error or CCMP/BIP/WPI MIC error */ + if (rxd2 & MT_RXD2_NORMAL_ICV_ERR) + status->flag |= RX_FLAG_ONLY_MONITOR; + unicast = (rxd1 & MT_RXD1_NORMAL_ADDR_TYPE) == MT_RXD1_NORMAL_U2M; idx = FIELD_GET(MT_RXD2_NORMAL_WLAN_IDX, rxd2); - hdr_trans = rxd1 & MT_RXD1_NORMAL_HDR_TRANS; status->wcid = mt7615_rx_get_wcid(dev, idx, unicast); if (status->wcid) { diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c index bbc996f86b5c3..ff613d7056119 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c @@ -349,9 +349,16 @@ mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb) if (rxd2 & MT_RXD2_NORMAL_AMSDU_ERR) return -EINVAL; + hdr_trans = rxd2 & MT_RXD2_NORMAL_HDR_TRANS; + if (hdr_trans && (rxd1 & MT_RXD1_NORMAL_CM)) + return -EINVAL; + + /* ICV error or CCMP/BIP/WPI MIC error */ + if (rxd1 & MT_RXD1_NORMAL_ICV_ERR) + status->flag |= RX_FLAG_ONLY_MONITOR; + unicast = FIELD_GET(MT_RXD3_NORMAL_ADDR_TYPE, rxd3) == MT_RXD3_NORMAL_U2M; idx = FIELD_GET(MT_RXD1_NORMAL_WLAN_IDX, rxd1); - hdr_trans = rxd2 & MT_RXD2_NORMAL_HDR_TRANS; status->wcid = mt7915_rx_get_wcid(dev, idx, unicast); if (status->wcid) { diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mac.c b/drivers/net/wireless/mediatek/mt76/mt7921/mac.c index 8a16f3f4d5253..04a288029c98e 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mac.c @@ -383,10 +383,17 @@ int mt7921_mac_fill_rx(struct mt7921_dev *dev, struct sk_buff *skb) if (rxd2 & MT_RXD2_NORMAL_AMSDU_ERR) return -EINVAL; + hdr_trans = rxd2 & MT_RXD2_NORMAL_HDR_TRANS; + if (hdr_trans && (rxd1 & MT_RXD1_NORMAL_CM)) + return -EINVAL; + + /* ICV error or CCMP/BIP/WPI MIC error */ + if (rxd1 & MT_RXD1_NORMAL_ICV_ERR) + status->flag |= RX_FLAG_ONLY_MONITOR; + chfreq = FIELD_GET(MT_RXD3_NORMAL_CH_FREQ, rxd3); unicast = FIELD_GET(MT_RXD3_NORMAL_ADDR_TYPE, rxd3) == MT_RXD3_NORMAL_U2M; idx = FIELD_GET(MT_RXD1_NORMAL_WLAN_IDX, rxd1); - hdr_trans = rxd2 & MT_RXD2_NORMAL_HDR_TRANS; status->wcid = mt7921_rx_get_wcid(dev, idx, unicast); if (status->wcid) { -- 2.34.1