From: madhukar.mythri@gmail.com
To: longli@microsoft.com
Cc: dev@dpdk.org, stephen@networkplumber.org,
Madhuker Mythri <madhukar.mythri@gmail.com>,
stable@dpdk.org
Subject: [PATCH v2] net/netvsc: fix race condition in RNDIS command execution
Date: Tue, 13 Jan 2026 15:48:20 +0530 [thread overview]
Message-ID: <20260113101820.60611-1-madhukar.mythri@gmail.com> (raw)
From: Madhuker Mythri <madhukar.mythri@gmail.com>
When multiple threads issue RNDIS command requests (such as device
info queries and link status checks) simultaneously, command failures
can occur due to concurrent access to shared resources in the RNDIS
execution path.
Add a spinlock to serialize RNDIS command execution and prevent
data corruption.
Fixes: 4e9c73e96e83 ("net/netvsc: add Hyper-V network device")
Cc: stable@dpdk.org
Signed-off-by: Madhuker Mythri <madhukar.mythri@gmail.com>
---
drivers/net/netvsc/hn_ethdev.c | 1 +
drivers/net/netvsc/hn_rndis.c | 2 ++
drivers/net/netvsc/hn_var.h | 1 +
3 files changed, 4 insertions(+)
diff --git a/drivers/net/netvsc/hn_ethdev.c b/drivers/net/netvsc/hn_ethdev.c
index 6584819f4f..b525e287fa 100644
--- a/drivers/net/netvsc/hn_ethdev.c
+++ b/drivers/net/netvsc/hn_ethdev.c
@@ -1310,6 +1310,7 @@ eth_hn_dev_init(struct rte_eth_dev *eth_dev)
PMD_INIT_FUNC_TRACE();
rte_spinlock_init(&hv->hotadd_lock);
+ rte_spinlock_init(&hv->cmd_lock);
LIST_INIT(&hv->hotadd_list);
vmbus = container_of(device, struct rte_vmbus_device, device);
diff --git a/drivers/net/netvsc/hn_rndis.c b/drivers/net/netvsc/hn_rndis.c
index 7c54eebcef..8a0716df89 100644
--- a/drivers/net/netvsc/hn_rndis.c
+++ b/drivers/net/netvsc/hn_rndis.c
@@ -500,8 +500,10 @@ hn_rndis_query(struct hn_data *hv, uint32_t oid,
/* Input data immediately follows RNDIS query. */
memcpy(req + 1, idata, idlen);
+ rte_spinlock_lock(&hv->cmd_lock);
error = hn_rndis_execute(hv, rid, req, reqlen,
comp, comp_len, RNDIS_QUERY_CMPLT);
+ rte_spinlock_unlock(&hv->cmd_lock);
if (error)
goto done;
diff --git a/drivers/net/netvsc/hn_var.h b/drivers/net/netvsc/hn_var.h
index 17c1d5d07b..66ed186c0a 100644
--- a/drivers/net/netvsc/hn_var.h
+++ b/drivers/net/netvsc/hn_var.h
@@ -179,6 +179,7 @@ struct hn_data {
struct vmbus_channel *channels[HN_MAX_CHANNELS];
rte_spinlock_t hotadd_lock;
+ rte_spinlock_t cmd_lock;
LIST_HEAD(hotadd_list, hv_hotadd_context) hotadd_list;
};
--
2.50.1 (Apple Git-155)
next reply other threads:[~2026-01-13 10:18 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-13 10:18 madhukar.mythri [this message]
2026-01-13 16:58 ` [RFT 0/2] net/netvsc: fix race conditions Stephen Hemminger
2026-01-13 16:58 ` [RFT 1/2] net/netvsc: fix RNDIS command concurrency issue Stephen Hemminger
2026-01-13 16:58 ` [RFT 2/2] net/netvsc: fix link status " Stephen Hemminger
2026-01-16 23:10 ` [EXTERNAL] [PATCH v2] net/netvsc: fix race condition in RNDIS command execution Long Li
2026-03-28 23:53 ` Stephen Hemminger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260113101820.60611-1-madhukar.mythri@gmail.com \
--to=madhukar.mythri@gmail.com \
--cc=dev@dpdk.org \
--cc=longli@microsoft.com \
--cc=stable@dpdk.org \
--cc=stephen@networkplumber.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox