From patchwork Mon Aug 19 10:05:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Larysa Zaremba X-Patchwork-Id: 13768142 X-Patchwork-Delegate: kuba@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 650DD165EFD; Mon, 19 Aug 2024 10:14:44 +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=1724062486; cv=none; b=LOWGUoZuQGvg1VZHAFt+t0INafYxeZt0BjMdXcS2KUutOxjXN2tGYRzqYRqNjpecDeKDRG6aJZlCELdsRhwQ2IWeyqOdSEqb5cxgT/j1Cgzg2uRPo3YFX1ohLu1iy2lzSXESkd0Q1ppd4CR1w4j2+FyNpXdNyqrGp4i2xszn7Q8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724062486; c=relaxed/simple; bh=ggv0Vvud4p7WVAXKSxI0QumP+Iqv96sBq059E0KCF44=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mvnxre666xCLPZRn2WbK/TrtTEuS6iICA3IN7E/yrCFv5oGeUqY6CavyrehVOeNQIAh2ltt5b+6C0hn1+ybrMT6Kpij9iz/Y71G0ick03xOTcBJNuygHQ7YecoxhwUbqFw1OktBFFyAYQAUOfwtvBAfh8ICjuv2z12O0WQZC01U= 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=en8JuDzQ; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="en8JuDzQ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1724062484; x=1755598484; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ggv0Vvud4p7WVAXKSxI0QumP+Iqv96sBq059E0KCF44=; b=en8JuDzQzHjKWJn6LJ1/37siWkV+Txc9hTrPgMjT6F7Qxj64lM8YFsnb fAZvrd6gbvJ/CITUzTVtjL8iujuUJiylkVhDarrDVYVLGlmBWPTzmdtNp UkFwlRVHVqenjCiOmo2r9vu54ubFIudMsoAu2+yB0VAGY/kwcQqpKQ7qH jnTiS6gBSaCiafCA0gOiKUhK1HcBilAT+/ooIvG+OwRKA8Ni0nTf2wMTx tHeVbtddvEhHAPR3TDD757YA47+dOga1Zmn6FK/b6Y39RVIFQZj4KIEno G1YM88MhlPdAr5j4aBoqd4b0w33+Abm3rmHCXc3pY4PsOb8nB3rh/IUXX g==; X-CSE-ConnectionGUID: 9Qxi3dgyRYGFj8/aPfVfvQ== X-CSE-MsgGUID: Vaf1sEahS8KZoXcq05IDtg== X-IronPort-AV: E=McAfee;i="6700,10204,11168"; a="13090167" X-IronPort-AV: E=Sophos;i="6.10,158,1719903600"; d="scan'208";a="13090167" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Aug 2024 03:14:41 -0700 X-CSE-ConnectionGUID: IiwUjazURwi9aNFKqE/3NA== X-CSE-MsgGUID: HaRkVdDNR+ahstqUeXg/oQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,158,1719903600"; d="scan'208";a="91097101" Received: from irvmail002.ir.intel.com ([10.43.11.120]) by fmviesa001.fm.intel.com with ESMTP; 19 Aug 2024 03:14:37 -0700 Received: from lincoln.igk.intel.com (lincoln.igk.intel.com [10.102.21.235]) by irvmail002.ir.intel.com (Postfix) with ESMTP id BD74028195; Mon, 19 Aug 2024 11:14:35 +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 , Chandan Kumar Rout Subject: [PATCH iwl-net v3 4/6] ice: check ICE_VSI_DOWN under rtnl_lock when preparing for reset Date: Mon, 19 Aug 2024 12:05:41 +0200 Message-ID: <20240819100606.15383-5-larysa.zaremba@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240819100606.15383-1-larysa.zaremba@intel.com> References: <20240819100606.15383-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 Signed-off-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 b72338974a60..94029e446b99 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); } }