Received: by 2002:ab2:6d45:0:b0:1fb:d597:ff75 with SMTP id d5csp210710lqr; Wed, 5 Jun 2024 03:58:29 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXjRLBkra2BUWwsXDts2nCwVTdrluwyNURBpLIoSbm93TrPTbU4IGs6t/uYKWwCJXlDSkKUT2o4XZ33RT5ucq9VbFfYE3nkrMobUqLwUQ== X-Google-Smtp-Source: AGHT+IGLJ7X3Smbv2q3N4tDnHkwaeeOPCsY6GhUqxhhqy0N8zRISQkUnbaPexhJvf7/EdFtC/Hbp X-Received: by 2002:a17:906:3f91:b0:a64:722f:4051 with SMTP id a640c23a62f3a-a699e784ce3mr129661566b.0.1717585109001; Wed, 05 Jun 2024 03:58:29 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717585108; cv=pass; d=google.com; s=arc-20160816; b=Rf2AWWvn2NXOqaaLCVB3SPEcVoFjMKvTqroOYRnZzRfm/LmHtL731nAKMCJe3awZSw BYA9ZGJozE3aRjJlFzGX6o8shONDAusNz6hw7Cy8c2ZnSXWIJMaKB6i75L4Kw5C2axv4 ue1HK+H2QqYzTQkkiUQNKhYGa9KW9FDa3066JTGzqMdzG+taY7HavzFOgXsnuDkbSHvO BENBFecqkN4MJQR3FnxtGi19bFmZegLTaEG28vkJzl3BRkFq1Ezob3jGAL7ytW/zYkEE SOEXUrb1HlNyVSis3vykc+PpiUWwb2T2GaxlywbiSdyZQ9y6opJxSqRtqvGvz3yEtm7Y ULrw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:organization:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=FRgcQCPrqk2/nJuil3KDkeWhLs+Qypr+rSYo+JH2ApY=; fh=TquNsOiV+zNY1csTpltVB6A9QFW5SbuNs6JlqcKCQkw=; b=XqRl9uEr5+NuQlm7ZH6FDKfU/lXpwOPLQkuMct2PVspB7YtqG4UWlUHfHKyjqxjD1g XXaHTfpxtL+fG2BmchU3zBA6vHPShg6EdrmQWftKkeoytpakdGixwfsuhy4sqcjbvVJH ULH6OdgrmjwhUM/3U5aKAMXTfmCnV9MP8weAPD8b+QYzY4UqrMO0KBrkR1FIzet3CSDB lWVlBEvN6ZT5TBBGwv3DmacXuoXwESMxectEjhX2P9gx+PW2WInr3TOI/eteM2siCZoz 8VUJYybxS0lw06JsTcFfREqUxy5aHH5t3YhUU5yQSLO4KXT0WcsyaIp7zfGWgVCX7X0u QmMQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=GdVkxeOt; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-wireless+bounces-8530-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-wireless+bounces-8530-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a640c23a62f3a-a68ed0bb7eesi378259866b.959.2024.06.05.03.58.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 03:58:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless+bounces-8530-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=GdVkxeOt; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-wireless+bounces-8530-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-wireless+bounces-8530-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id F35221F21672 for ; Wed, 5 Jun 2024 10:58:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 661F4192B63; Wed, 5 Jun 2024 10:57:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="GdVkxeOt" X-Original-To: linux-wireless@vger.kernel.org Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BD80B1922F2 for ; Wed, 5 Jun 2024 10:57:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.16 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717585055; cv=none; b=hjJJbnF6o0UI4xeLhC09jAVZAoOOxONkcIEl4w/y+y1jPICg5YqlR9A5B8nOrAVOkd+Gg9sVjqug62AZnrQnPYkwv0SA5UzTHpNGUy7FF39nRBg8gnikBNR9/8lV+YRRHynKf+wB2DXc9xmx5Xj8ncXFrMICZ1XNVWEOMYlzGQ4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717585055; c=relaxed/simple; bh=CaEISvJyN/0psLQBRsjv7+sN8zXe3+9OTQJNa0AMTFc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=AAAS+1w3PYQHyW0u/uV2FgvbZamWgWQDjCb3UOQY3MR5bs6X1m6IRXL8GruJBsVi8Tu+rdwurJ2x7Lkl906/VXoSYzci/vTf7z+uWwIhyAVfXYbulsTPqRptXI9xi+qB76GZRhJyTb/51AMSGxb78uoSrD99dllvZ7N38A9uFkE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=GdVkxeOt; arc=none smtp.client-ip=192.198.163.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717585054; x=1749121054; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=CaEISvJyN/0psLQBRsjv7+sN8zXe3+9OTQJNa0AMTFc=; b=GdVkxeOtbSwy7P5iymdYoawHRU+dfOiXRb/aqGkz6dZScJKPSW/PmWEl /ZpYZQNKST+6FD7TTsaWnqH3obGzuojVGLoNevZTVoo30ZSl7LibrvRL5 Jt3ur/lEJ65gfaLX2uuD9XT9Tyjb0zdhirzqbD+usogkU47VQEHGHmD+L 13Mid1m7r/j5W+hbx9PKBY+KAPp5TeQKMqbwDrIwDlmJfSGSzhD0bRLwr n6MhC5JD3FmxmywPCPANbQwG10uQHUdYJRphAD8ojqedCH3fY0/p27u2x DKNkVjG8p9SysocynmxoKeceGIdo0NA+UQYj5FFBsxRzhJ5/ISzzzPSx+ g==; X-CSE-ConnectionGUID: 99jTNo3rTgyFyC20WbvGHQ== X-CSE-MsgGUID: WJDLElhRQ4yHtMj87Cv1rA== X-IronPort-AV: E=McAfee;i="6600,9927,11093"; a="11919951" X-IronPort-AV: E=Sophos;i="6.08,216,1712646000"; d="scan'208";a="11919951" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jun 2024 03:57:34 -0700 X-CSE-ConnectionGUID: ZdsyfBOvRlGRQhv/S5S8/g== X-CSE-MsgGUID: 73koYEMnTZiUXFDCKSF41Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,216,1712646000"; d="scan'208";a="37563012" Received: from weis0040.iil.intel.com ([10.12.217.108]) by fmviesa008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jun 2024 03:57:33 -0700 From: Miri Korenblit To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, Johannes Berg Subject: [PATCH 3/7] wifi: mac80211: fix erroneous errors for STA changes Date: Wed, 5 Jun 2024 13:57:18 +0300 Message-Id: <20240605135233.48e2b8af07e3.Ib9793c383fcba118c05100e024f4a11a1c3d0e85@changeid> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240605105722.2034610-1-miriam.rachel.korenblit@intel.com> References: <20240605105722.2034610-1-miriam.rachel.korenblit@intel.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Organization: Intel Israel (74) Limited Content-Transfer-Encoding: 8bit From: Johannes Berg When e.g. wpa_supplicant sets only the MLD "sta" authorized state, the code actually applies that change, but then returns an error to userspace anyway because there were no changes to the link station, and no link ID was given. However, it's not incorrect to not have a link ID when wanting to change only the MLD peer ("sta") state, so the code shouldn't require it. To fix this, separate the "new_link" argument out into a new three-state enum, because if modify is called on a link STA only, it should return an error if no link is given or if it doesn't exist. For modify on the MLD "sta", not having a link ID is OK, but if there is one it should be validated. This seems to not have mattered much as wpa_supplicant just prints a message and continues, and the authorized state was already set before this error return. However, in the later code powersave recalculation etc. will be skipped, so that it may result in never allowing powersave on MLO connections. Signed-off-by: Johannes Berg Signed-off-by: Miri Korenblit --- net/mac80211/cfg.c | 55 ++++++++++++++++++++++++++++++---------------- 1 file changed, 36 insertions(+), 19 deletions(-) diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c index 62119e957cd8..54b03a86f71e 100644 --- a/net/mac80211/cfg.c +++ b/net/mac80211/cfg.c @@ -1814,8 +1814,15 @@ static void sta_apply_mesh_params(struct ieee80211_local *local, #endif } +enum sta_link_apply_mode { + STA_LINK_MODE_NEW, + STA_LINK_MODE_STA_MODIFY, + STA_LINK_MODE_LINK_MODIFY, +}; + static int sta_link_apply_parameters(struct ieee80211_local *local, - struct sta_info *sta, bool new_link, + struct sta_info *sta, + enum sta_link_apply_mode mode, struct link_station_parameters *params) { int ret = 0; @@ -1827,18 +1834,29 @@ static int sta_link_apply_parameters(struct ieee80211_local *local, struct link_sta_info *link_sta = rcu_dereference_protected(sta->link[link_id], lockdep_is_held(&local->hw.wiphy->mtx)); - - /* - * If there are no changes, then accept a link that exist, - * unless it's a new link. - */ - if (params->link_id >= 0 && !new_link && - !params->link_mac && !params->txpwr_set && - !params->supported_rates_len && - !params->ht_capa && !params->vht_capa && - !params->he_capa && !params->eht_capa && - !params->opmode_notif_used) - return 0; + bool changes = params->link_mac || + params->txpwr_set || + params->supported_rates_len || + params->ht_capa || + params->vht_capa || + params->he_capa || + params->eht_capa || + params->opmode_notif_used; + + switch (mode) { + case STA_LINK_MODE_NEW: + if (!params->link_mac) + return -EINVAL; + break; + case STA_LINK_MODE_LINK_MODIFY: + break; + case STA_LINK_MODE_STA_MODIFY: + if (params->link_id >= 0) + break; + if (!changes) + return 0; + break; + } if (!link || !link_sta) return -EINVAL; @@ -1848,15 +1866,13 @@ static int sta_link_apply_parameters(struct ieee80211_local *local, return -EINVAL; if (params->link_mac) { - if (new_link) { + if (mode == STA_LINK_MODE_NEW) { memcpy(link_sta->addr, params->link_mac, ETH_ALEN); memcpy(link_sta->pub->addr, params->link_mac, ETH_ALEN); } else if (!ether_addr_equal(link_sta->addr, params->link_mac)) { return -EINVAL; } - } else if (new_link) { - return -EINVAL; } if (params->txpwr_set) { @@ -2028,7 +2044,7 @@ static int sta_apply_parameters(struct ieee80211_local *local, if (params->listen_interval >= 0) sta->listen_interval = params->listen_interval; - ret = sta_link_apply_parameters(local, sta, false, + ret = sta_link_apply_parameters(local, sta, STA_LINK_MODE_STA_MODIFY, ¶ms->link_sta_params); if (ret) return ret; @@ -5004,7 +5020,7 @@ ieee80211_add_link_station(struct wiphy *wiphy, struct net_device *dev, if (ret) return ret; - ret = sta_link_apply_parameters(local, sta, true, params); + ret = sta_link_apply_parameters(local, sta, STA_LINK_MODE_NEW, params); if (ret) { ieee80211_sta_free_link(sta, params->link_id); return ret; @@ -5031,7 +5047,8 @@ ieee80211_mod_link_station(struct wiphy *wiphy, struct net_device *dev, if (!(sta->sta.valid_links & BIT(params->link_id))) return -EINVAL; - return sta_link_apply_parameters(local, sta, false, params); + return sta_link_apply_parameters(local, sta, STA_LINK_MODE_LINK_MODIFY, + params); } static int -- 2.34.1