Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp3998294imm; Mon, 14 May 2018 00:42:32 -0700 (PDT) X-Google-Smtp-Source: AB8JxZr1OXTDEA2nazWTh3Vu99HCSOmmS7pz17ntJ5vLUrhFTY9vBSK5sgPN2DFpvQpSMK0KFFdE X-Received: by 2002:a63:6e87:: with SMTP id j129-v6mr7407428pgc.86.1526283752758; Mon, 14 May 2018 00:42:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526283752; cv=none; d=google.com; s=arc-20160816; b=YnRzSFqYjClbVvurorrbqPljOf/Kd5JXNBxXT99Rv6Ab5VUqldrmD0LvVoZaMQRHcu Yg11lided/LkOzp3jPX3YgODnSLlumxjw7fkwQ6jz4WLfk8a2ttDb6mBwV2ILJh8Qo5i MjWxmaKu+8gUl8Ddg0br25XzaaIRC+zB8yv8HrYjE4h505YMoiAVepV7pwUs0/y2Pf70 wJGyuTtN1KTLKr4Ur7M54BwYeE7sjqy3gl4FuNahaa57NC69hQ+TstU2HqTIqzPAUEtT cBQaloz8ldE8zcnWh77q8ezsLo2uMlTncrNRJqoDNV27cHpxXm3R8epNdVTO1EAy66K3 WzUw== 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=66O0hKi6KsMCPI8oR0beKRWWALfX5ZAnduUdN9X2l90=; b=kXo52Wln7+v32abYNs6pxDVQAkVjw8YrU+gM4ztqjjNy4JlFE/9N6NNos1p0ddU4+R EGtKj40A2EjbDoNWxqVGegTCzyWP1xZ6TZmBo77yA8/j0ZoFiZ0hLxvfQFA0vgRJl4HY p3OcrmiCO5zOtayfiHb4UqFfXMLs0EOCXLgSQ5cDBW85r1wR5QiXFK9naFaLR0nuPpv7 v4Um109i5hs6KxeQRJiAAZZuyQlZ8cFdYikr2vu6AIe6f9UzMPk01aPAFCSZ90M2ofpF S0IdKMLJJTx6pxmbKzJQ/lujctFpLt5UkV9y/w9K18FTnhO07mjoaTiy4n2YmML5Xy4f 33yw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vgVA7iyc; 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 u2-v6si7076372pgp.692.2018.05.14.00.42.18; Mon, 14 May 2018 00:42:32 -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=vgVA7iyc; 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 S1752601AbeENGwC (ORCPT + 99 others); Mon, 14 May 2018 02:52:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:58524 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752041AbeENGwA (ORCPT ); Mon, 14 May 2018 02:52:00 -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 14B9520834; Mon, 14 May 2018 06:51:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1526280719; bh=7ax0JVRca/BfFQoJz88bD/3+GiCNRDqtYehltdOmpxc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vgVA7iycjsTmzf19d+/uYd1XTQMNcITwEV5fI6reBxKVcH9ICeRLxhh+o6PrIdNir ROKtn7sFb0sson30SncAWfQXL2mtav0Oo7pWa8PA9umLozlr8nRsCjy158UyOn8ngT sdOBNV89Cbe6SQFpTLbioqJ26Pw9ttWEUwuZMgsc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sara Sharon , Luca Coelho , Johannes Berg , Sriram R Subject: [PATCH 4.4 06/56] mac80211: allow same PN for AMSDU sub-frames Date: Mon, 14 May 2018 08:48:11 +0200 Message-Id: <20180514064755.556782755@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180514064754.853201981@linuxfoundation.org> References: <20180514064754.853201981@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.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Sara Sharon commit f631a77ba920f7153a1094d09cd8f2ebbffd0328 upstream. Some hardware (iwlwifi an example) de-aggregate AMSDUs and copy the IV as is to the generated MPDUs, so the same PN appears in multiple packets without being a replay attack. Allow driver to explicitly indicate that a frame is allowed to have the same PN as the previous frame. Signed-off-by: Sara Sharon Signed-off-by: Luca Coelho Signed-off-by: Johannes Berg Cc: Sriram R Signed-off-by: Greg Kroah-Hartman --- include/net/mac80211.h | 6 +++++- net/mac80211/wpa.c | 16 ++++++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) --- a/include/net/mac80211.h +++ b/include/net/mac80211.h @@ -1031,6 +1031,9 @@ ieee80211_tx_info_clear_status(struct ie * @RX_FLAG_RADIOTAP_VENDOR_DATA: This frame contains vendor-specific * radiotap data in the skb->data (before the frame) as described by * the &struct ieee80211_vendor_radiotap. + * @RX_FLAG_ALLOW_SAME_PN: Allow the same PN as same packet before. + * This is used for AMSDU subframes which can have the same PN as + * the first subframe. */ enum mac80211_rx_flags { RX_FLAG_MMIC_ERROR = BIT(0), @@ -1061,7 +1064,8 @@ enum mac80211_rx_flags { RX_FLAG_5MHZ = BIT(29), RX_FLAG_AMSDU_MORE = BIT(30), RX_FLAG_RADIOTAP_VENDOR_DATA = BIT(31), - RX_FLAG_MIC_STRIPPED = BIT_ULL(32), + RX_FLAG_MIC_STRIPPED = BIT_ULL(32), + RX_FLAG_ALLOW_SAME_PN = BIT_ULL(33), }; #define RX_FLAG_STBC_SHIFT 26 --- a/net/mac80211/wpa.c +++ b/net/mac80211/wpa.c @@ -523,12 +523,16 @@ ieee80211_crypto_ccmp_decrypt(struct iee return RX_DROP_UNUSABLE; if (!(status->flag & RX_FLAG_PN_VALIDATED)) { + int res; + ccmp_hdr2pn(pn, skb->data + hdrlen); queue = rx->security_idx; - if (memcmp(pn, key->u.ccmp.rx_pn[queue], - IEEE80211_CCMP_PN_LEN) <= 0) { + res = memcmp(pn, key->u.ccmp.rx_pn[queue], + IEEE80211_CCMP_PN_LEN); + if (res < 0 || + (!res && !(status->flag & RX_FLAG_ALLOW_SAME_PN))) { key->u.ccmp.replays++; return RX_DROP_UNUSABLE; } @@ -749,12 +753,16 @@ ieee80211_crypto_gcmp_decrypt(struct iee return RX_DROP_UNUSABLE; if (!(status->flag & RX_FLAG_PN_VALIDATED)) { + int res; + gcmp_hdr2pn(pn, skb->data + hdrlen); queue = rx->security_idx; - if (memcmp(pn, key->u.gcmp.rx_pn[queue], - IEEE80211_GCMP_PN_LEN) <= 0) { + res = memcmp(pn, key->u.gcmp.rx_pn[queue], + IEEE80211_GCMP_PN_LEN); + if (res < 0 || + (!res && !(status->flag & RX_FLAG_ALLOW_SAME_PN))) { key->u.gcmp.replays++; return RX_DROP_UNUSABLE; }