Article View: linux.kernel.netdev
Article #25789[PATCH net 2/3] ice: lock VF config while changing its MSI-X vector count
From: Przemek Kitszel
Date: Wed, 02 Dec 2026 12:48
Date: Wed, 02 Dec 2026 12:48
93 lines
12573 bytes
12573 bytes
ice_sriov_set_msix_vec_count() rebuilds the VF VSI and rewrites the VF
queue and interrupt mappings without vf->cfg_lock. The PCI core only
makes sure that no driver is bound to the VF, the PF can still reset the
VF at the same time, e.g. from ndo_set_vf_mac() or ndo_set_vf_vlan().
Such a reset rebuilds the same VSI under vf->cfg_lock, and one rebuild
frees the VSI arrays that the other one still uses. Reproducer, with one
VF that has no driver bound:
while :; do
ip link set $PF vf 0 mac 02:00:00:00:02:01
ip link set $PF vf 0 mac 02:00:00:00:02:02
done &
while :; do
echo 33 > /sys/bus/pci/devices/$VF/sriov_vf_msix_count
echo 17 > /sys/bus/pci/devices/$VF/sriov_vf_msix_count
done
The first MAC change already oopses, with RTNL held:
BUG: kernel NULL pointer dereference, address: 0000000000000000
RIP: 0010:ice_free_q_vector+0x16/0x140 [ice]
Call Trace:
ice_vsi_free_q_vectors+0x20/0x40 [ice]
ice_vsi_decfg+0x59/0xc0 [ice]
ice_reset_vf+0x38f/0x5a0 [ice]
__ice_set_vf_mac+0x10a/0x160 [ice]
do_setvfinfo+0x5d/0x450
do_setlink.constprop.0+0x57f/0xd20
rtnl_newlink+0x4a4/0x9b0
Take vf->cfg_lock for the whole change, like the other paths that
reconfigure a VF do. It nests in the device locks of the PF and the VF,
which the PCI core holds here; the reset paths take vf->cfg_lock without
any device lock.
Fixes: 05c16687e0cc ("ice: set MSI-X vector count on VF")
Reported-by: Petr Oros <poros@redhat.com>
Closes: https://lore.kernel.org/netdev/20261126094321.40071-1-poros@redhat.com
Signed-off-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
---
drivers/net/ethernet/intel/ice/ice_sriov.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/net/ethernet/intel/ice/ice_sriov.c b/drivers/net/ethernet/intel/ice/ice_sriov.c
index c49f48b5ae38..5916cf7bf914 100644
--- a/drivers/net/ethernet/intel/ice/ice_sriov.c
+++ b/drivers/net/ethernet/intel/ice/ice_sriov.c
@@ -957,14 +957,18 @@ int ice_sriov_set_msix_vec_count(struct pci_dev *vf_dev, int msix_vec_count)
if (!vf)
return -ENOENT;
+ mutex_lock(&vf->cfg_lock);
+
vsi = ice_get_vf_vsi(vf);
if (!vsi) {
+ mutex_unlock(&vf->cfg_lock);
ice_put_vf(vf);
return -ENOENT;
}
/* No need to rebuild if we're setting to the same value */
if (msix_vec_count == vf->num_msix) {
+ mutex_unlock(&vf->cfg_lock);
ice_put_vf(vf);
return 0;
}
@@ -998,6 +1002,7 @@ int ice_sriov_set_msix_vec_count(struct pci_dev *vf_dev, int msix_vec_count)
vf->vf_id, vf->num_msix, vf->num_vf_qs);
ice_ena_vf_mappings(vf);
+ mutex_unlock(&vf->cfg_lock);
ice_put_vf(vf);
return 0;
@@ -1012,6 +1017,7 @@ int ice_sriov_set_msix_vec_count(struct pci_dev *vf_dev, int msix_vec_count)
vf->first_vector_idx = ice_virt_get_irqs(pf, vf->num_msix);
if (vf->first_vector_idx < 0) {
+ mutex_unlock(&vf->cfg_lock);
ice_put_vf(vf);
return -EINVAL;
}
@@ -1024,6 +1030,7 @@ int ice_sriov_set_msix_vec_count(struct pci_dev *vf_dev, int msix_vec_count)
}
ice_ena_vf_mappings(vf);
+ mutex_unlock(&vf->cfg_lock);
ice_put_vf(vf);
return -EINVAL;
--
2.51.1
Technical Details
Message-ID:
<20261202124956.18277-3-przemyslaw.kitszel@intel.com>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu.MISMATCH!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-375788-linux-kernel-netdev=dewy.ruReferences:
<20261202124956.18277-1-przemyslaw.kitszel@intel.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu.MISMATCH!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-375788-linux-kernel-netdev=dewy.ru From: przemyslaw.kitszel@intel.com (Przemek Kitszel) Newsgroups: linux.kernel.netdev Subject: [PATCH net 2/3] ice: lock VF config while changing its MSI-X vector count Date: Wed, 2 Dec 2026 13:48:02 +0100 Organization: Usenet Network Message-ID: <20261202124956.18277-3-przemyslaw.kitszel@intel.com> References: <20261202124956.18277-1-przemyslaw.kitszel@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="1972882"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:INVHOVYWeAF8nUuwUTLzF37OuYU= sha256:aLDlJL/B9s9aPPxbT8i3fBHtXKKMgZv4Dz/NPA8XQFQ= sha1:ydydfQ9vJPZRs+moI3wvxvSxQNc= sha256:fPbWftyAHcjsq+oKSf1e428ump2CrJ24IEUXDAMp7Dc= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 45124117639; Wed, 2 Dec 2026 15:50:43 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.051 X-Spam-Status: No, score=-3.051 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=intel.com X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 8Nc9l1fToS1Y; Wed, 2 Dec 2026 15:50:36 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-375788-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=intel.com X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 2303911762A; Wed, 2 Dec 2026 15:50:24 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id 481A72E384; Wed, 2 Dec 2026 12:50:14 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796215812; b=lCcM/cpnGExxeyvErtqsoA2CfRf0jvQJQrEBC4j/ICfCbS/WoJRy8WbvbLQvd/q/pQ6g BBM155xtRkxTHMB++kZuyLPbcJx2YQOIYRlFvvJlcw7VVSbIT+ZmqiQc2plHQq4DEZC+I CUREIFMLugKBHkwQBdr1XVCxrS/DRJaZ0InGV9TTHsJlGB2vUHz9ZzykPSFT+3bLjo7EN HMdO/WT6tw8pqtAFkUfRZ03l91IiwWczvMNY2OXLBvt5cGlwb7/ysBeSgQTgozruTvkdF 2IDkCrZJJWwjD8qga+RuNfapBdiQzJO7oXWw+kFDSKLIF7LCGrsM1wLUriQFZPg/Ozw== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796215812; h=X-Original-To:Received:DMARC-Filter:DKIM-Signature: X-CSE-ConnectionGUID:X-CSE-MsgGUID:X-IronPort-AV:X-IronPort-AV: Received:X-CSE-ConnectionGUID:X-CSE-MsgGUID:X-ExtLoop1:X-IronPort-AV: Received:Received:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:X-Mailing-List:List-Id:List-Post:List-Help: List-Subscribe:List-Unsubscribe:List-Owner:Precedence:MIME-Version: Content-Transfer-Encoding; bh=QTpl+0MaWJBBRjkXzOQctFxtZ/ZZm3GTC/N7ZALJIsY=; b=ffnMdhEG6vVRU5zPYEep/sAlU1pEVVUa2/6qTg1T5m+cXQY+Zp/UacfQuM5CXvzHueIH xot/y2fSx5LO5FH3CaPUzHaTl0kJs0a9V4SWVHLZeJZ4RYLnAe1ZvpV4NUH2Wfjo3Wzu8 UG4G2zoLhq6sJJyxqEhiMtOQBkZdjWkz5fAb9XI+qMjCCrx57BTSfljiKvKw8298YZTRj zvAzujdjFKDgiWbNUatXuoz11dBoHWWTJZF93wcPH8iohiQK7oUYtRVbCK+386tfr8LFG +Pe2y2U3zsdcopcRLxnj4zoB2X2+O/6xRnMkpYIrVJ5Vd9q/7+FuISOQxs5RzyqWQgw== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b="LfTC9/LA"; dmarc=pass header.from=intel.com; spf=pass smtp.mailfrom=intel.com; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A9432606A337; Wed, 2 Dec 2026 12:50:12 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=LfTC9/LA X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=198.175.65.12 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796215811; b=CrMZZcS2aq6DmbezDR36P+TAPXNLQw0jOprafQ45C4ky29gV7QB5xd1lWjWtH0CjSnc7 BSU02DPR4tVzAiediIuBynVH1GFME6gjWZnVHNvIW0JEEWja4AymIsOJXIuijO2vWZj27 wcdN5u4ZFlck5m6lnYJ6wH+58N3myGIbdz9CmKSqTAbhsX0KEeHMdrhC7KrhlIEV9i+Sa c4sYH/ippoSorGVVcLDfb8s7Bg/oj2VnzMWGo1VqCChyNaAoMBrJh8mMYwyAGX5YgODo2 Wd2WyVGfBsnMIX0t27CBB+9ZO1Y5qh/lK3ny2FvOymGcPYy3ifq6QgR4sm2WS3s7xYA== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796215811; h=DMARC-Filter:DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID: X-IronPort-AV:X-IronPort-AV:Received:X-CSE-ConnectionGUID: X-CSE-MsgGUID:X-ExtLoop1:X-IronPort-AV:Received:Received:From:To:Cc: Subject:Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=QTpl+0MaWJBBRjkXzOQctFxtZ/ZZm3GTC/N7ZALJIsY=; b=bdPReLEFcj4uRQxkHffe5FRac2Zu7jJQcg8MzgxAJASpNE/mQXuadkpvmY9lb7cSZYnD EFHAg/NjfTzy6WOvn86cEWmmu1gh2U0YNtbahe2659UYOkvMXbDCp6U8o4ffMEjMXKTjR ZSTnGtw2ggD1izcQSbwy6DgSkOMnzwceTA9z9NG7+/sZLN0OoPwgu/NmWhzDc7k2N5rXw vLCpPDwaXBrFEc4Rfkz+BbotJk5CMpWM1EZ8EmDAQBcXNAp3qgNOfiUnJGLTjyy6Kt8as hLsBbv8qH4KI+tjklKIjcqwh4qRfWG2Rxw4P8p0Yxcchx4oNDYSYHpla4ijDU+AzGbg== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b="LfTC9/LA"; arc=none smtp.remote-ip=198.175.65.12 X-Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 71BE3606A323 for <netdev@vger.kernel.org>; Wed, 2 Dec 2026 12:50:11 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 71BE3606A323 X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796215812; x=1827751812; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=QTpl+0MaWJBBRjkXzOQctFxtZ/ZZm3GTC/N7ZALJIsY=; b=LfTC9/LAUwBKPY2P0jGJgO+f5r1ALAWEmmhKZjjXRBcuzYZoFki+/7uk 2CIPx8SYRJS+QWBaVdU7oDdS3ifuU0F9bteyVrW+Jdhvt5Qz2cp7lQz0o naEog3oarvk24RXYatiDMgF83ejQcqesSrY0i8p9R3+D1Pa9qvGWW9vxZ D3Tt6KvgqFQgrFXcqN8B43vy4DngIDD+CgHt14IDaxHv0VlXrcG4eG+/Z rps51OK9lZvuTw3WJBoinnI0MEVl2XsIfAbDJaOtRjPuioJxa8fz5526z DXSqil4kLnAEXqMe3sfRFDbNX7i94xosASMQtubvwIssf9RhA9C+nykTp g==; X-CSE-ConnectionGUID: tX37sbnEThyHf3ZjXifmqA== X-CSE-MsgGUID: xEdHF5AtTdm6h6yVujdC8w== X-IronPort-AV: E=McAfee;i="6800,10657,11984"; a="5052221" X-IronPort-AV: E=Sophos;i="6.27,246,1787036400"; d="scan'208";a="5052221" X-Received: from fmviesa012.fm.intel.com ([10.60.135.152]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2026 04:50:11 -0800 X-CSE-ConnectionGUID: ZRJ2r7N4SN+0h1MFNeKZ0Q== X-CSE-MsgGUID: IE4IqbXtSnuZnfxh7OxZpQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,246,1787036400"; d="scan'208";a="15168160" X-Received: from irvmail002.ir.intel.com ([10.43.11.120]) by fmviesa012.fm.intel.com with ESMTP; 02 Dec 2026 04:50:06 -0800 X-Received: from pkitszel-desk.tendawifi.com (unknown [10.245.245.159]) by irvmail002.ir.intel.com (Postfix) with ESMTP id 506B62FC53; Wed, 2 Dec 2026 12:50:04 +0000 (GMT) X-Cc: intel-wired-lan@lists.osuosl.org, anthony.l.nguyen@intel.com, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, horms@kernel.org, andrew+netdev@lunn.ch, Petr Oros <poros@redhat.com>, Przemek Kitszel <przemyslaw.kitszel@intel.com> X-Mailer: git-send-email 2.51.1 X-In-Reply-To: <20261202124956.18277-1-przemyslaw.kitszel@intel.com> X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list