[PATCH v2] net/netvsc: fix race condition in RNDIS command execution

Stephen Hemminger stephen at networkplumber.org
Sun Mar 29 00:53:31 CET 2026


On Tue, 13 Jan 2026 15:48:20 +0530
madhukar.mythri at gmail.com wrote:

> From: Madhuker Mythri <madhukar.mythri at 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 at dpdk.org
> 
> Signed-off-by: Madhuker Mythri <madhukar.mythri at gmail.com>
> ---

As Long (and AI review) observed this patch needs more work.
There are two issues:

1. The introduced spin lock only protects query, it does not protect
around cases where a query races with some thing else calling rndis_set.
Lock should go inside hn_rndis_execute().

2. The lock is held while spinning, and it could take several
seconds to complete, holding spinlock that long burns CPU and any
other thread trying to do operation would queue up and block.

Maybe a pthread_mutex (which sleeps) or use trylock in the
query path and return EBUSY?


More information about the dev mailing list