From patchwork Mon Aug 7 16:47:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Skeffington X-Patchwork-Id: 9885839 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3324F60363 for ; Mon, 7 Aug 2017 16:49:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 252CA28696 for ; Mon, 7 Aug 2017 16:49:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 19E04286B6; Mon, 7 Aug 2017 16:49:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.4 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 694C128696 for ; Mon, 7 Aug 2017 16:49:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751940AbdHGQtH (ORCPT ); Mon, 7 Aug 2017 12:49:07 -0400 Received: from mail-qk0-f182.google.com ([209.85.220.182]:35299 "EHLO mail-qk0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751541AbdHGQtG (ORCPT ); Mon, 7 Aug 2017 12:49:06 -0400 Received: by mail-qk0-f182.google.com with SMTP id d145so5842961qkc.2 for ; Mon, 07 Aug 2017 09:49:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=astro-ai.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=ACgUNK4BVEqO50NodrW+rbhbjH+micVrRcGPzl1TBJM=; b=0uTh5Iqf0PTRTeU7td4UEovg0HhoASA5vItI+GpA3IJi5dnj/zZZoHwg6wqcVet8g0 pDfIoexKPhudjQbXRCBjhyPgfjS8j6sEn/xvxVLswGXUNBPkey/cVcuh+R8J6tLaHp1K 4eYeCdaj0kVd/OlUV9kKwR0opXDnsAiyCDN0FtC3zV60VaDU95c/ckwghOnWTsBpzCXx VqoK3XMAwCEc21JKDUQrrheZbJjNYTbggpRXFdC/X/24ja1vurQkBSkg0DN8n/VpIQUa PWRTUK5/tWdrkitchKGqsNiBiziljW3FKqLiHrXUyBH8N8o82iKskVymff+BtofNg6kv jLaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=ACgUNK4BVEqO50NodrW+rbhbjH+micVrRcGPzl1TBJM=; b=Rt1GGgwIgTHRDKm0ADfREA8A5gtkLsAwZsikJV56VYN2ntyIzv3hV2XQuIBiwP1ieE GdZsBHnfdPvJxSCItUL3n1hWQld81G/PUU/tkvKg4LckkRy9vpyz2fOcVetnVJue43n4 HIha6luoFI39Qvi+jBCwCkoL01WjKPRcdYDbKEzLvY6aFYlA+JPhCNiBJ2j2vFv3C62b HGgTK8RWre/s1K1Yp5KO6bxx9SbxTykmIoKDi2nN4/eZdztE+sCrxYvqF8oHBN32M+aV 0lYKMFFUTyREndoOIoEjLq8zb5+v4b/0TvSUyTk0dtHsHZkqMIMnwcEpLofcQfjYJFxK rKwQ== X-Gm-Message-State: AHYfb5hiP9rI0/z5gQYMuI5Pm7Qst8NI9kaxWzEqc0940aDi7ObMsg3E pt15Jki9hYy3+vph X-Received: by 10.55.164.12 with SMTP id n12mr1573007qke.327.1502124545624; Mon, 07 Aug 2017 09:49:05 -0700 (PDT) Received: from SneakyWeasel.rga.com ([170.200.72.11]) by smtp.gmail.com with ESMTPSA id 64sm5723181qky.78.2017.08.07.09.49.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Aug 2017 09:49:05 -0700 (PDT) From: Michael Skeffingfon To: Stanislaw Gruszka , Kalle Valo , Johannes Berg , linux-wireless@vger.kernel.org Cc: Michael Skeffingfon Subject: [PATCH v3] rt2x00: Fix MMIC Countermeasures Date: Mon, 7 Aug 2017 12:47:36 -0400 Message-Id: <20170807164736.20564-1-mike@astro.ai> X-Mailer: git-send-email 2.11.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Set RX_FLAG_DECRYPTED in case of MMIC failure so that ieee80211_rx_h_decrypt() doesnt drop the frame before getting to ieee80211_rx_h_michael_mic_verify(). Signed-off-by: Michael Skeffington Acked-by: Stanislaw Gruszka --- drivers/net/wireless/ralink/rt2x00/rt2800mmio.c | 13 +++++++++++-- drivers/net/wireless/ralink/rt2x00/rt2800usb.c | 15 ++++++++++++--- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800mmio.c b/drivers/net/wireless/ralink/rt2x00/rt2800mmio.c index ee5276e233fa..1123e2bed803 100644 --- a/drivers/net/wireless/ralink/rt2x00/rt2800mmio.c +++ b/drivers/net/wireless/ralink/rt2x00/rt2800mmio.c @@ -136,10 +136,19 @@ void rt2800mmio_fill_rxdone(struct queue_entry *entry, */ rxdesc->flags |= RX_FLAG_MMIC_STRIPPED; - if (rxdesc->cipher_status == RX_CRYPTO_SUCCESS) + if (rxdesc->cipher_status == RX_CRYPTO_SUCCESS) { rxdesc->flags |= RX_FLAG_DECRYPTED; - else if (rxdesc->cipher_status == RX_CRYPTO_FAIL_MIC) + } else if (rxdesc->cipher_status == RX_CRYPTO_FAIL_MIC) { + /* + * In order to check the Michael Mic, the packet must have + * been decrypted. Mac80211 doesnt check the MMIC failure + * flag to initiate MMIC countermeasures if the decoded flag + * has not been set. + */ + rxdesc->flags |= RX_FLAG_DECRYPTED; + rxdesc->flags |= RX_FLAG_MMIC_ERROR; + } } if (rt2x00_get_field32(word, RXD_W3_MY_BSS)) diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800usb.c b/drivers/net/wireless/ralink/rt2x00/rt2800usb.c index 685b8e0cd67d..3e5d3a40d986 100644 --- a/drivers/net/wireless/ralink/rt2x00/rt2800usb.c +++ b/drivers/net/wireless/ralink/rt2x00/rt2800usb.c @@ -697,11 +697,20 @@ static void rt2800usb_fill_rxdone(struct queue_entry *entry, * stripped it from the frame. Signal this to mac80211. */ rxdesc->flags |= RX_FLAG_MMIC_STRIPPED; - - if (rxdesc->cipher_status == RX_CRYPTO_SUCCESS) + + if (rxdesc->cipher_status == RX_CRYPTO_SUCCESS) { + rxdesc->flags |= RX_FLAG_DECRYPTED; + } else if (rxdesc->cipher_status == RX_CRYPTO_FAIL_MIC) { + /* + * In order to check the Michael Mic, the packet must have + * been decrypted. Mac80211 doesnt check the MMIC failure + * flag to initiate MMIC countermeasures if the decoded flag + * has not been set. + */ rxdesc->flags |= RX_FLAG_DECRYPTED; - else if (rxdesc->cipher_status == RX_CRYPTO_FAIL_MIC) + rxdesc->flags |= RX_FLAG_MMIC_ERROR; + } } if (rt2x00_get_field32(word, RXD_W0_MY_BSS))