Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp739295rwd; Thu, 8 Jun 2023 07:10:18 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5d1che5QY5IbWqP8Lt/lTnhBFSsqS+RsEpHIPv0eb8LWmMxvs9Q1/onHCwFuXRbcP2aab1 X-Received: by 2002:a17:903:2305:b0:1b0:3cda:635b with SMTP id d5-20020a170903230500b001b03cda635bmr10306935plh.0.1686233418009; Thu, 08 Jun 2023 07:10:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686233417; cv=none; d=google.com; s=arc-20160816; b=LhEJY2/s/XEm+BHcgC+l+KGjzuUSYE1vn4+YV2+tbK0i/zatFTTTQJyKh2EXrWLdJz 0M4hD8i83RExjGnc+cb614q8apKOKjZXs2N50Fiu4qB5a0akhLntYz/72CtX8Ci0neKS dsnak2vVaMAGqc8O8n1FmU/r/fUrGv52jtccVr6sISbARSc19Meh6K/RAgsZk5XOs2MW /Ey65gKpyQGSkIgRCkjNWgBzXgR2GM8anKTpJ9lEfr+5dgHPfwX2mD0eRDNaRruxwpRc 8tnwc4g3TTpuRPFtOMRYT5QKCg4CG2BLa7wkBgjzG4dGaUlvlrAyLigRBF4tu8T2VdLl LAtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Zm4v8B0SSNSxOs+lydyUR3CmgTNf/JCK7KiOOMfC8H4=; b=FEWRP5/6/i1YAxcOaSkUVaP9hmsyR6bGZfOJSIkdA/4hfIl5sRPAsAnCvDYjBlMGeH cknQmk2SZkwslHIONAtm+9erwVtIDy/YmiiGQepXjjGY8JauursZ39V3j+VDjpzFdlhP luNCfGSCM7iGZ5B8fTTm+8OP1EKujI3VksvqTgo4keea2cDMIar7t8oaHnpvOMAn9f4x 9GPV3CD/UPMJJsFY9IjCCrwf/kz9nlLns1NfD8KG3AUXG2Cim+icZpj5qCKaVtcjxpNk aNjLCgf15mQdVNc5jb01t9mlK1E1+pOeJxP/kRVDic64Uziakgg0IT2prX7o6T56njek kKYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=fgy+5PLZ; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h6-20020a170902f54600b001ac9ab8539csi1193750plf.77.2023.06.08.07.10.09; Thu, 08 Jun 2023 07:10:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=fgy+5PLZ; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236728AbjFHOHV (ORCPT + 61 others); Thu, 8 Jun 2023 10:07:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236830AbjFHOHO (ORCPT ); Thu, 8 Jun 2023 10:07:14 -0400 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2C6222D7F for ; Thu, 8 Jun 2023 07:07:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1686233234; x=1717769234; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=gsuQcX44owvjiTFHVsZVIMRX0g/zSGCDAnxryWX2ntI=; b=fgy+5PLZnHVlKsRxQyTvG/LHcldfEAY6ZhOT66E1K1objRu6FAg2hdtg aM2gSnv/OzXnSpasw8o4jazDwC1e41GpsCMynR0JmsfKHIpyLXeSpS441 M64XoC50oZZvDR0iAEGcae2+wkjdr8BKmsYIwwAFP4JuHeaGy2P63T2jK v1ji5Rdo14Ro2+V5zXnxiZZsW7cYcp3dWRDebp/TEt8oBaN+8XNKgT+Mw 8BKgl6BHLughP7t1cUK1M1386c+OePNZy7uVOEuPgaXA73ww+ejhYiQGi 6QexBE6x0u8MmSFwaRdfRUJAnapmtkiwMaAN59SHwaVtUMX1bjpPcAnqR g==; X-IronPort-AV: E=McAfee;i="6600,9927,10734"; a="423176222" X-IronPort-AV: E=Sophos;i="6.00,226,1681196400"; d="scan'208";a="423176222" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Jun 2023 06:36:37 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10734"; a="956706205" X-IronPort-AV: E=Sophos;i="6.00,226,1681196400"; d="scan'208";a="956706205" Received: from unknown (HELO ggreenma-mobl2.intel.com) ([10.249.94.100]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Jun 2023 06:36:35 -0700 From: gregory.greenman@intel.com To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, Benjamin Berg , Gregory Greenman Subject: [PATCH 06/15] wifi: mac80211: take lock before setting vif links Date: Thu, 8 Jun 2023 16:36:02 +0300 Message-Id: <20230608163202.fa0c6597fdad.I83dd70359f6cda30f86df8418d929c2064cf4995@changeid> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230608133611.1303724-1-gregory.greenman@intel.com> References: <20230608133611.1303724-1-gregory.greenman@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Benjamin Berg ieee80211_vif_set_links requires the sdata->local->mtx lock to be held. Add the appropriate locking around the calls in both the link add and remove handlers. This causes a warning when e.g. ieee80211_link_release_channel is called via ieee80211_link_stop from ieee80211_vif_update_links. Fixes: 0d8c4a3c8688 ("wifi: mac80211: implement add/del interface link callbacks") Signed-off-by: Benjamin Berg Signed-off-by: Gregory Greenman --- net/mac80211/cfg.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c index 1b78a2ae7a83..4aaead4895b7 100644 --- a/net/mac80211/cfg.c +++ b/net/mac80211/cfg.c @@ -4862,11 +4862,16 @@ static int ieee80211_add_intf_link(struct wiphy *wiphy, unsigned int link_id) { struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev); + int res; if (wdev->use_4addr) return -EOPNOTSUPP; - return ieee80211_vif_set_links(sdata, wdev->valid_links); + mutex_lock(&sdata->local->mtx); + res = ieee80211_vif_set_links(sdata, wdev->valid_links); + mutex_unlock(&sdata->local->mtx); + + return res; } static void ieee80211_del_intf_link(struct wiphy *wiphy, @@ -4875,7 +4880,9 @@ static void ieee80211_del_intf_link(struct wiphy *wiphy, { struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev); + mutex_lock(&sdata->local->mtx); ieee80211_vif_set_links(sdata, wdev->valid_links); + mutex_unlock(&sdata->local->mtx); } static int sta_add_link_station(struct ieee80211_local *local, -- 2.38.1