Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2198377imm; Mon, 28 May 2018 03:46:19 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqqofvBrn3VCQSo28iAy/Qh4wCBcCSgj7bdKY0r0vewppUmzDOrqs9BrkEV2Ardibv8hpyG X-Received: by 2002:a63:4004:: with SMTP id n4-v6mr10347088pga.248.1527504379056; Mon, 28 May 2018 03:46:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527504379; cv=none; d=google.com; s=arc-20160816; b=Q09Q0Y3AS9G4s3lm+TwbwIroTCdt3mo6l1rPmi6UK5YB3w8fmdrLOt9OM5dsYz/rPQ 7g9GbPHKy0hkeCMmgR6kc7fVHKAEbxgLRZmG6kJPhlACMtMw+daerd6V0/mKQoSksFj4 efrSqSDOnMXJsVlpAYGpAFgZ5JNth38OQi3kqIwDpHpErBX1Q8J/oZc7BbQloX5rl7yD AXZZ+42qPABddETTg/4URlZs05Nhx5tbMrp8ebGM4696uE17W+qqk5W3mYLg74pB3Ms2 KT8h3Mn8syp97c1pPbEgh2C8TvvwJ6fyeALNmUt3HTTflHaBe74vc64MZBUxl1B/+QcR RKlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=+GVhGqs2g6wS8MCr2Ys2la1FQ79V//Zd4UQZ/anREw8=; b=LLGZu/zV+j2JMfF4s3M5eXLnrloApg/d3zEgzGv8i6FBQAiQ6nhK9uwYO0F+TB2/QH Zu86s3yNJLFi4Twb4+H0Wg0uZJppsO2/qytyA14hnqg9uCYi905vXu6Ft0V9VNroLcVW qTcED9g/3Y+qgjAgJgb6cXUnqwPJTUFVetOIPYS8oQC1eoJnMEhkdSZYUgWSGeIero3l 3wAdklmeiHcgQGlLBZiRFSE8NfFaCPOnzQ1ScDXB4/gv8L3XlkNu09fqs3YqvBYj+pN0 74nJRlnNbpv03V5JJhgmPkBvJCUMpBqSlpW96c0UxkHMkms01D+Z4YSNmkVKj7vC5uWE l2Fw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=C5bJOari; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x15-v6si24326579pgq.442.2018.05.28.03.46.04; Mon, 28 May 2018 03:46:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=C5bJOari; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1163064AbeE1Kot (ORCPT + 99 others); Mon, 28 May 2018 06:44:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:35412 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S937393AbeE1Kon (ORCPT ); Mon, 28 May 2018 06:44:43 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id AFDA32086D; Mon, 28 May 2018 10:44:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527504283; bh=0/EGLS0HgDBXaYOmg2nKqeWLbAlKmeotCxbNugUnt/c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=C5bJOariwvpt0a/vV4BzJwid61w9vDigDWpDtvE/hPsyasiAYZNTf88gA3cxBnA+o TQccqe9zeuEOg+aTjht/9Jh5LGvUP4yp/EmORNiujy9Jq74I8sHXIla5wsFYyz6aKQ R56fbBcoWzrspOtw1lGJzgzpNm22YGur0qKsmv/s= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sara Sharon , Luca Coelho , Sasha Levin Subject: [PATCH 4.14 082/496] iwlwifi: mvm: fix security bug in PN checking Date: Mon, 28 May 2018 11:57:47 +0200 Message-Id: <20180528100323.238939701@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180528100319.498712256@linuxfoundation.org> References: <20180528100319.498712256@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Sara Sharon [ Upstream commit 5ab2ba931255d8bf03009c06d58dce97de32797c ] A previous patch allowed the same PN for packets originating from the same AMSDU by copying PN only for the last packet in the series. This however is bogus since we cannot assume the last frame will be received on the same queue, and if it is received on a different ueue we will end up not incrementing the PN and possibly let the next packet to have the same PN and pass through. Change the logic instead to driver explicitly indicate for the second sub frame and on to be allowed to have the same PN as the first subframe. Indicate it to mac80211 as well for the fallback queue. Fixes: f1ae02b186d9 ("iwlwifi: mvm: allow same PN for de-aggregated AMSDU") Signed-off-by: Sara Sharon Signed-off-by: Luca Coelho Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c | 39 +++++++++++++------------- 1 file changed, 20 insertions(+), 19 deletions(-) --- a/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c @@ -71,6 +71,7 @@ static inline int iwl_mvm_check_pn(struc struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; struct ieee80211_rx_status *stats = IEEE80211_SKB_RXCB(skb); struct iwl_mvm_key_pn *ptk_pn; + int res; u8 tid, keyidx; u8 pn[IEEE80211_CCMP_PN_LEN]; u8 *extiv; @@ -127,12 +128,13 @@ static inline int iwl_mvm_check_pn(struc pn[4] = extiv[1]; pn[5] = extiv[0]; - if (memcmp(pn, ptk_pn->q[queue].pn[tid], - IEEE80211_CCMP_PN_LEN) <= 0) + res = memcmp(pn, ptk_pn->q[queue].pn[tid], IEEE80211_CCMP_PN_LEN); + if (res < 0) + return -1; + if (!res && !(stats->flag & RX_FLAG_ALLOW_SAME_PN)) return -1; - if (!(stats->flag & RX_FLAG_AMSDU_MORE)) - memcpy(ptk_pn->q[queue].pn[tid], pn, IEEE80211_CCMP_PN_LEN); + memcpy(ptk_pn->q[queue].pn[tid], pn, IEEE80211_CCMP_PN_LEN); stats->flag |= RX_FLAG_PN_VALIDATED; return 0; @@ -310,28 +312,21 @@ static void iwl_mvm_rx_csum(struct ieee8 } /* - * returns true if a packet outside BA session is a duplicate and - * should be dropped + * returns true if a packet is a duplicate and should be dropped. + * Updates AMSDU PN tracking info */ -static bool iwl_mvm_is_nonagg_dup(struct ieee80211_sta *sta, int queue, - struct ieee80211_rx_status *rx_status, - struct ieee80211_hdr *hdr, - struct iwl_rx_mpdu_desc *desc) +static bool iwl_mvm_is_dup(struct ieee80211_sta *sta, int queue, + struct ieee80211_rx_status *rx_status, + struct ieee80211_hdr *hdr, + struct iwl_rx_mpdu_desc *desc) { struct iwl_mvm_sta *mvm_sta; struct iwl_mvm_rxq_dup_data *dup_data; - u8 baid, tid, sub_frame_idx; + u8 tid, sub_frame_idx; if (WARN_ON(IS_ERR_OR_NULL(sta))) return false; - baid = (le32_to_cpu(desc->reorder_data) & - IWL_RX_MPDU_REORDER_BAID_MASK) >> - IWL_RX_MPDU_REORDER_BAID_SHIFT; - - if (baid != IWL_RX_REORDER_DATA_INVALID_BAID) - return false; - mvm_sta = iwl_mvm_sta_from_mac80211(sta); dup_data = &mvm_sta->dup_data[queue]; @@ -361,6 +356,12 @@ static bool iwl_mvm_is_nonagg_dup(struct dup_data->last_sub_frame[tid] >= sub_frame_idx)) return true; + /* Allow same PN as the first subframe for following sub frames */ + if (dup_data->last_seq[tid] == hdr->seq_ctrl && + sub_frame_idx > dup_data->last_sub_frame[tid] && + desc->mac_flags2 & IWL_RX_MPDU_MFLG2_AMSDU) + rx_status->flag |= RX_FLAG_ALLOW_SAME_PN; + dup_data->last_seq[tid] = hdr->seq_ctrl; dup_data->last_sub_frame[tid] = sub_frame_idx; @@ -929,7 +930,7 @@ void iwl_mvm_rx_mpdu_mq(struct iwl_mvm * if (ieee80211_is_data(hdr->frame_control)) iwl_mvm_rx_csum(sta, skb, desc); - if (iwl_mvm_is_nonagg_dup(sta, queue, rx_status, hdr, desc)) { + if (iwl_mvm_is_dup(sta, queue, rx_status, hdr, desc)) { kfree_skb(skb); goto out; }