From patchwork Fri Mar 27 08:21:56 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Kazior X-Patchwork-Id: 6104161 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 8364F9F350 for ; Fri, 27 Mar 2015 08:24:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8F0CB203F7 for ; Fri, 27 Mar 2015 08:24:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9EC4C203B8 for ; Fri, 27 Mar 2015 08:24:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753121AbbC0IYr (ORCPT ); Fri, 27 Mar 2015 04:24:47 -0400 Received: from mail-la0-f52.google.com ([209.85.215.52]:32845 "EHLO mail-la0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752624AbbC0IYp (ORCPT ); Fri, 27 Mar 2015 04:24:45 -0400 Received: by labto5 with SMTP id to5so64915163lab.0 for ; Fri, 27 Mar 2015 01:24:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tieto.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=TUBe9C7iPTTYuGWZhCsao3gVkPSdspbtu5/8ISl/JEg=; b=Tlbw9GCqbzWahAFDfi3AeEGl8Miyt6AKQoPekkQ2+4iFS5Q5Ckm0PO7tQ+PHSmDj+1 mtNFFbX8e+Uridl2ePB5JMa7tQNY3zkGZa0TEuCjjLEJKk/NA49fIMcuckhhlGkouS3O SaruhS2v6zAC6hjv6k4zDmiXgLhIyltA2dILI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=TUBe9C7iPTTYuGWZhCsao3gVkPSdspbtu5/8ISl/JEg=; b=Gk4KgCTu0hvB+KR/vhpeCKV9IhCllRCXZb0LTtQlEsRfbbGn778ubG/efasMTwBAzn ouBhbnLKGyXo3BuUwCvYBYEu+3014h5V0CQBwSNdSsjktSE1G1099KHKR+LHmvezmXGT 5u/uFNR8ZmKsM+et+w/tfGEsxggqdWjLbiTUOT4qRavAJTMnI05bjzIJGysCYT6Cha+L gA//BE+QVH/9K8bDkyD1tDmUHaZbX7oRCq2sh9Kyk2Hn0t6x34rEGVdR7VbO/11vjOtD KSqkUqHdUKVvp/L3biLbLXVde2xBM/LedpRVxkG6bfL6R0PLpltU9N3pvsk8/+wgrlus 0vDA== X-Gm-Message-State: ALoCoQnAJYaX3TvkptAZxmnS/Q7331rT1tgkdiIhVeUlYS4X1GuCz3x5lsc+t5lM8QPiVIW65moO1f3fFwHzhFTzUy3o2itHoXg+8a8F1pHmXzPQiLnHDbZX2N07pLtINMrdYuNzsvWL X-Received: by 10.152.21.136 with SMTP id v8mr17037013lae.64.1427444683261; Fri, 27 Mar 2015 01:24:43 -0700 (PDT) Received: from localhost.localdomain ([91.198.246.8]) by mx.google.com with ESMTPSA id iy9sm218725lbc.8.2015.03.27.01.24.41 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 27 Mar 2015 01:24:42 -0700 (PDT) From: Michal Kazior To: ath10k@lists.infradead.org Cc: linux-wireless@vger.kernel.org, Michal Kazior Subject: [PATCH 2/2] ath10k: fix static wep with more than 1 key in client mode Date: Fri, 27 Mar 2015 08:21:56 +0000 Message-Id: <1427444516-974-2-git-send-email-michal.kazior@tieto.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1427444516-974-1-git-send-email-michal.kazior@tieto.com> References: <1427444516-974-1-git-send-email-michal.kazior@tieto.com> X-DomainID: tieto.com Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The default keyidx callback may be called after more than 1 key is installed. This led to only 1 WEP key being reinstalled only. This caused Rxed traffic encrypted with other WEP keys to be dropped in client mode. Signed-off-by: Michal Kazior Tested-by: Bartosz Markowski --- drivers/net/wireless/ath/ath10k/mac.c | 45 +++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/drivers/net/wireless/ath/ath10k/mac.c b/drivers/net/wireless/ath/ath10k/mac.c index 9d873900257d..3baea2b671dd 100644 --- a/drivers/net/wireless/ath/ath10k/mac.c +++ b/drivers/net/wireless/ath/ath10k/mac.c @@ -259,41 +259,44 @@ static int ath10k_clear_vdev_key(struct ath10k_vif *arvif, return first_errno; } -static int ath10k_mac_vif_sta_fix_wep_key(struct ath10k_vif *arvif) +static int ath10k_mac_vif_sta_fix_wep_key(struct ath10k_vif *arvif, int keyidx) { struct ath10k *ar = arvif->ar; enum nl80211_iftype iftype = arvif->vif->type; struct ieee80211_key_conf *key; - u32 flags = 0; - int num = 0; - int i; + u32 flags; int ret; + int i; lockdep_assert_held(&ar->conf_mutex); if (iftype != NL80211_IFTYPE_STATION) return 0; + if (keyidx < 0) + return 0; + for (i = 0; i < ARRAY_SIZE(arvif->wep_keys); i++) { - if (arvif->wep_keys[i]) { - key = arvif->wep_keys[i]; - ++num; + if (!arvif->wep_keys[i]) + continue; + + key = arvif->wep_keys[i]; + + flags = 0; + flags |= WMI_KEY_PAIRWISE; + + if (key->keyidx == keyidx) + flags |= WMI_KEY_TX_USAGE; + + ret = ath10k_install_key(arvif, key, SET_KEY, arvif->bssid, + flags); + if (ret) { + ath10k_warn(ar, "failed to install key %i on vdev %i: %d\n", + key->keyidx, arvif->vdev_id, ret); + return ret; } } - if (num != 1) - return 0; - - flags |= WMI_KEY_PAIRWISE; - flags |= WMI_KEY_TX_USAGE; - - ret = ath10k_install_key(arvif, key, SET_KEY, arvif->bssid, flags); - if (ret) { - ath10k_warn(ar, "failed to install key %i on vdev %i: %d\n", - key->keyidx, arvif->vdev_id, ret); - return ret; - } - return 0; } @@ -4227,7 +4230,7 @@ static void ath10k_set_default_unicast_key(struct ieee80211_hw *hw, arvif->def_wep_key_idx = keyidx; - ret = ath10k_mac_vif_sta_fix_wep_key(arvif); + ret = ath10k_mac_vif_sta_fix_wep_key(arvif, keyidx); if (ret) { ath10k_warn(ar, "failed to fix sta wep key on vdev %i: %d\n", arvif->vdev_id, ret);