Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp2873983pxu; Sun, 29 Nov 2020 07:34:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJwfFTvbXIfyqrDo+W/oc6iRVsv5IZkw29IYHiqYhdvL5vYQYuj7YJMAQGOurNGHArN85o02 X-Received: by 2002:a17:906:4712:: with SMTP id y18mr13568030ejq.495.1606664077601; Sun, 29 Nov 2020 07:34:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606664077; cv=none; d=google.com; s=arc-20160816; b=xzmleQAfNlm8OBAr+1FZLQfQZHKeQJuxDPxcTShdFkFacjsiW0mAKI00xk3mNrgQn6 RNLJ+rYYa2GQ1SQd4lGu6A6IiiWI1XrCSxjQBBPH33/lSS7D8lycUzl7+1Ubg8KVBrX6 pWUPk9bjVQHCe81YINcwzM9J2IoE5T6qoBk/4YQQOxPqAuXfJrSFYIqP5aztAveRBPh5 RmhFCfD8J85vkcuQXQ/1GGnH5kA/d5rccjpSLu2tNz1NOrdYDYjsEaz0CPY5l/NFMJTC P03Z0bOme2xvTT/kLq2wujJfPeGdMikH6KeYIxmhpZX62dTUcSuZWcY8f/f7QvNglCmJ jUwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:cc:to:from; bh=bBMLenEaf6f4IFg19QP9i1KeW6U2e2PHf9e0jMsAeyM=; b=tlDt2STvDCnm1Kl/b8wuN31zwj5yU8sMLoKFUWdI7NQQBpb9h6wxYdVV9KMtBg2Lv+ cO5wtM8fYr2gqgu7FssGrZTjB/SgCEIMbOpsnPG19C7Onpm7EMbBcrJVOZP3tvQhO5aw DjQbxkAmREJnv83pL0jqGSn4aziE9kHXtfF2F9ITQkr7qh1uiBjPuMUbIzrMAk1TVT2/ 4q6Uhe/W9zVpwAP96TYB1J9tR/4G2x2F9SDlO3ZD7kOLZPGj0pa7IDF3qSA0Qju+iC12 DTY2Gh5b8RZ0QERXSRAuQrCLtYMQ7JahqXARapFYihjj7cRdMHo7wRbZs50QJCXKFSm+ JK+A== 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 p14si1558613edm.293.2020.11.29.07.34.14; Sun, 29 Nov 2020 07:34:37 -0800 (PST) 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 S1727930AbgK2Pbs (ORCPT + 99 others); Sun, 29 Nov 2020 10:31:48 -0500 Received: from paleale.coelho.fi ([176.9.41.70]:33522 "EHLO farmhouse.coelho.fi" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727739AbgK2Pbr (ORCPT ); Sun, 29 Nov 2020 10:31:47 -0500 Received: from 91-156-6-193.elisa-laajakaista.fi ([91.156.6.193] helo=redipa.ger.corp.intel.com) by farmhouse.coelho.fi with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1kjOfD-0035ld-UD; Sun, 29 Nov 2020 17:31:00 +0200 From: Luca Coelho To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org Date: Sun, 29 Nov 2020 17:30:45 +0200 Message-Id: X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201129153055.1971298-1-luca@coelho.fi> References: <20201129153055.1971298-1-luca@coelho.fi> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on farmhouse.coelho.fi X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, TVD_RCVD_IP autolearn=ham autolearn_force=no version=3.4.4 Subject: [PATCH 03/13] mac80211: support MIC error/replay detected counters driver update Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Johannes Berg Support the driver incrementing MIC error and replay detected counters when having detected a bad frame, if it drops it directly instead of relying on mac80211 to do the checks. These are then exposed to userspace, though currently only in some cases and in debugfs. Signed-off-by: Johannes Berg Signed-off-by: Luca Coelho --- include/net/mac80211.h | 20 +++++++++++++++++ net/mac80211/key.c | 49 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) diff --git a/include/net/mac80211.h b/include/net/mac80211.h index 1328b7166460..2d01280c0564 100644 --- a/include/net/mac80211.h +++ b/include/net/mac80211.h @@ -5321,6 +5321,26 @@ ieee80211_gtk_rekey_add(struct ieee80211_vif *vif, void ieee80211_gtk_rekey_notify(struct ieee80211_vif *vif, const u8 *bssid, const u8 *replay_ctr, gfp_t gfp); +/** + * ieee80211_key_mic_failure - increment MIC failure counter for the key + * + * Note: this is really only safe if no other RX function is called + * at the same time. + * + * @keyconf: the key in question + */ +void ieee80211_key_mic_failure(struct ieee80211_key_conf *keyconf); + +/** + * ieee80211_key_replay - increment replay counter for the key + * + * Note: this is really only safe if no other RX function is called + * at the same time. + * + * @keyconf: the key in question + */ +void ieee80211_key_replay(struct ieee80211_key_conf *keyconf); + /** * ieee80211_wake_queue - wake specific queue * @hw: pointer as obtained from ieee80211_alloc_hw(). diff --git a/net/mac80211/key.c b/net/mac80211/key.c index 8c5f829ff6d7..a4817aa4b171 100644 --- a/net/mac80211/key.c +++ b/net/mac80211/key.c @@ -1300,3 +1300,52 @@ ieee80211_gtk_rekey_add(struct ieee80211_vif *vif, return &key->conf; } EXPORT_SYMBOL_GPL(ieee80211_gtk_rekey_add); + +void ieee80211_key_mic_failure(struct ieee80211_key_conf *keyconf) +{ + struct ieee80211_key *key; + + key = container_of(keyconf, struct ieee80211_key, conf); + + switch (key->conf.cipher) { + case WLAN_CIPHER_SUITE_AES_CMAC: + case WLAN_CIPHER_SUITE_BIP_CMAC_256: + key->u.aes_cmac.icverrors++; + break; + case WLAN_CIPHER_SUITE_BIP_GMAC_128: + case WLAN_CIPHER_SUITE_BIP_GMAC_256: + key->u.aes_gmac.icverrors++; + break; + default: + /* ignore the others for now, we don't keep counters now */ + break; + } +} +EXPORT_SYMBOL_GPL(ieee80211_key_mic_failure); + +void ieee80211_key_replay(struct ieee80211_key_conf *keyconf) +{ + struct ieee80211_key *key; + + key = container_of(keyconf, struct ieee80211_key, conf); + + switch (key->conf.cipher) { + case WLAN_CIPHER_SUITE_CCMP: + case WLAN_CIPHER_SUITE_CCMP_256: + key->u.ccmp.replays++; + break; + case WLAN_CIPHER_SUITE_AES_CMAC: + case WLAN_CIPHER_SUITE_BIP_CMAC_256: + key->u.aes_cmac.replays++; + break; + case WLAN_CIPHER_SUITE_BIP_GMAC_128: + case WLAN_CIPHER_SUITE_BIP_GMAC_256: + key->u.aes_gmac.replays++; + break; + case WLAN_CIPHER_SUITE_GCMP: + case WLAN_CIPHER_SUITE_GCMP_256: + key->u.gcmp.replays++; + break; + } +} +EXPORT_SYMBOL_GPL(ieee80211_key_replay); -- 2.29.2