From patchwork Fri Aug 23 09:59:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Larysa Zaremba X-Patchwork-Id: 13774886 X-Patchwork-Delegate: kuba@kernel.org Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) (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 D60111BF3A; Fri, 23 Aug 2024 10:08:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724407691; cv=none; b=S5FPfsTKhPkqREM+YtgpUjIaaH/aQ3CthtLUyL6RFr2MyXtCEcsTZLNsSiIhxntB9oM73shBigv6LEar3h7QlpY/+tt6UHajAs6il3/FfFw5IaiyNOXRN86w1dJGmkFKd53+WEuLn0nMskJyJL0BJIk9UN5CnZGjBmfzdkuccgE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724407691; c=relaxed/simple; bh=ZQepG22v/2yg4DruXjOlIUfQxcXCfOv/Ml8FpBV6ETs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JRQxpYINuUdFPRv5fALvcELM/sWVdrQsHaYjHL6Hk5utZzu0R1FNDWxVDQg3QogIhLLInvZ301kEiMeXZDsKKcRXdJLQFSOKu7JfEfipcaV1SRJmdKPsljB7DKcl/691NSk4i1X6OqqYDlwlaZzZe3PPdlCmefHAzQU8a4yR4UQ= 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=csgbBTh9; arc=none smtp.client-ip=192.198.163.10 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="csgbBTh9" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1724407690; x=1755943690; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ZQepG22v/2yg4DruXjOlIUfQxcXCfOv/Ml8FpBV6ETs=; b=csgbBTh9HeI/haTmPQuGQYSiIiOo/0RzstyBKecG5Qc/Tkdl/8di6xFn b9Q1hAXElPXdtRaGKbMzPqtpI6Mi7KqmLVL1gOLYqeVRR8VkamGMoFhEy 9H9xg8pnMNbZNYaLH63fQqfpAEp+nzk/SzIwj8kzoPBxuD+DLRi7m7H29 qcf+xAVdmTQtQLwQj0NZ3QB4QI9jsb1ZSUVPOWHPmv8hnw9v63iFeA7A8 ogAZsIXGsu0SY9JeCtbMntyQuRt2+J7irPLfWg9BQi8fzLrJLyGRjfuM6 VwxJcjjwwr5nj2M7OEBlp4cqpieBqrw8JUwJvp2YyOhT8vHoah8Y8PQul w==; X-CSE-ConnectionGUID: 28gq29LYRRWGJdaCI3Qw+Q== X-CSE-MsgGUID: YIhz2b/DTeOAkRuJPdsBNA== X-IronPort-AV: E=McAfee;i="6700,10204,11172"; a="34285044" X-IronPort-AV: E=Sophos;i="6.10,170,1719903600"; d="scan'208";a="34285044" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Aug 2024 03:08:09 -0700 X-CSE-ConnectionGUID: e+GTo2xFT4uObNT+SC3QBw== X-CSE-MsgGUID: B4xxOz1hRDiYosdN2hkX0w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,170,1719903600"; d="scan'208";a="62478984" Received: from irvmail002.ir.intel.com ([10.43.11.120]) by orviesa008.jf.intel.com with ESMTP; 23 Aug 2024 03:08:05 -0700 Received: from lincoln.igk.intel.com (lincoln.igk.intel.com [10.102.21.235]) by irvmail002.ir.intel.com (Postfix) with ESMTP id 718F333BD6; Fri, 23 Aug 2024 11:08:02 +0100 (IST) From: Larysa Zaremba To: intel-wired-lan@lists.osuosl.org, Tony Nguyen Cc: Larysa Zaremba , "David S. Miller" , Jacob Keller , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , Maciej Fijalkowski , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, magnus.karlsson@intel.com, Michal Kubiak , Wojciech Drewek , Amritha Nambiar , przemyslaw.kitszel@intel.com, anirudh.venkataramanan@intel.com, sridhar.samudrala@intel.com, Chandan Kumar Rout Subject: [PATCH iwl-net v4 4/6] ice: check ICE_VSI_DOWN under rtnl_lock when preparing for reset Date: Fri, 23 Aug 2024 11:59:29 +0200 Message-ID: <20240823095933.17922-5-larysa.zaremba@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240823095933.17922-1-larysa.zaremba@intel.com> References: <20240823095933.17922-1-larysa.zaremba@intel.com> Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Consider the following scenario: .ndo_bpf() | ice_prepare_for_reset() | ________________________|_______________________________________| rtnl_lock() | | ice_down() | | | test_bit(ICE_VSI_DOWN) - true | | ice_dis_vsi() returns | ice_up() | | | proceeds to rebuild a running VSI | .ndo_bpf() is not the only rtnl-locked callback that toggles the interface to apply new configuration. Another example is .set_channels(). To avoid the race condition above, act only after reading ICE_VSI_DOWN under rtnl_lock. Fixes: 0f9d5027a749 ("ice: Refactor VSI allocation, deletion and rebuild flow") Reviewed-by: Wojciech Drewek Reviewed-by: Jacob Keller Tested-by: Chandan Kumar Rout Signed-off-by: Larysa Zaremba Reviewed-by: Maciej Fijalkowski --- drivers/net/ethernet/intel/ice/ice_lib.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice_lib.c b/drivers/net/ethernet/intel/ice/ice_lib.c index 14257e036d4b..2405e5ed9128 100644 --- a/drivers/net/ethernet/intel/ice/ice_lib.c +++ b/drivers/net/ethernet/intel/ice/ice_lib.c @@ -2665,8 +2665,7 @@ int ice_ena_vsi(struct ice_vsi *vsi, bool locked) */ void ice_dis_vsi(struct ice_vsi *vsi, bool locked) { - if (test_bit(ICE_VSI_DOWN, vsi->state)) - return; + bool already_down = test_bit(ICE_VSI_DOWN, vsi->state); set_bit(ICE_VSI_NEEDS_RESTART, vsi->state); @@ -2674,15 +2673,16 @@ void ice_dis_vsi(struct ice_vsi *vsi, bool locked) if (netif_running(vsi->netdev)) { if (!locked) rtnl_lock(); - - ice_vsi_close(vsi); + already_down = test_bit(ICE_VSI_DOWN, vsi->state); + if (!already_down) + ice_vsi_close(vsi); if (!locked) rtnl_unlock(); - } else { + } else if (!already_down) { ice_vsi_close(vsi); } - } else if (vsi->type == ICE_VSI_CTRL) { + } else if (vsi->type == ICE_VSI_CTRL && !already_down) { ice_vsi_close(vsi); } }