* [PATCH] mshv: fix SRCU protection in irqfd resampler ack handler
@ 2026-02-05 9:40 lirongqing
2026-02-05 17:14 ` Stanislav Kinsburskii
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: lirongqing @ 2026-02-05 9:40 UTC (permalink / raw)
To: K . Y . Srinivasan, Haiyang Zhang, Wei Liu, Dexuan Cui, Long Li,
linux-hyperv, linux-kernel
Cc: Li RongQing
From: Li RongQing <lirongqing@baidu.com>
Replace hlist_for_each_entry_rcu() with hlist_for_each_entry_srcu()
in mshv_irqfd_resampler_ack() to correctly handle SRCU-protected
linked list traversal.
The function uses SRCU (sleepable RCU) synchronization via
partition->pt_irq_srcu, but was incorrectly using the RCU variant
for list iteration. This could lead to race conditions when the
list is modified concurrently.
Also add srcu_read_lock_held() assertion as required by
hlist_for_each_entry_srcu() to ensure we're in the proper
read-side critical section.
Signed-off-by: Li RongQing <lirongqing@baidu.com>
---
drivers/hv/mshv_eventfd.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/hv/mshv_eventfd.c b/drivers/hv/mshv_eventfd.c
index 0b75ff1..6d176ed 100644
--- a/drivers/hv/mshv_eventfd.c
+++ b/drivers/hv/mshv_eventfd.c
@@ -87,8 +87,9 @@ static void mshv_irqfd_resampler_ack(struct mshv_irq_ack_notifier *mian)
idx = srcu_read_lock(&partition->pt_irq_srcu);
- hlist_for_each_entry_rcu(irqfd, &resampler->rsmplr_irqfd_list,
- irqfd_resampler_hnode) {
+ hlist_for_each_entry_srcu(irqfd, &resampler->rsmplr_irqfd_list,
+ irqfd_resampler_hnode,
+ srcu_read_lock_held(&partition->pt_irq_srcu)) {
if (hv_should_clear_interrupt(irqfd->irqfd_lapic_irq.lapic_control.interrupt_type))
hv_call_clear_virtual_interrupt(partition->pt_id);
--
2.9.4
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] mshv: fix SRCU protection in irqfd resampler ack handler
2026-02-05 9:40 [PATCH] mshv: fix SRCU protection in irqfd resampler ack handler lirongqing
@ 2026-02-05 17:14 ` Stanislav Kinsburskii
2026-02-05 17:53 ` Anirudh Rayabharam
2026-02-06 7:06 ` Wei Liu
2 siblings, 0 replies; 4+ messages in thread
From: Stanislav Kinsburskii @ 2026-02-05 17:14 UTC (permalink / raw)
To: lirongqing
Cc: K . Y . Srinivasan, Haiyang Zhang, Wei Liu, Dexuan Cui, Long Li,
linux-hyperv, linux-kernel
On Thu, Feb 05, 2026 at 04:40:10AM -0500, lirongqing wrote:
> From: Li RongQing <lirongqing@baidu.com>
>
> Replace hlist_for_each_entry_rcu() with hlist_for_each_entry_srcu()
> in mshv_irqfd_resampler_ack() to correctly handle SRCU-protected
> linked list traversal.
>
> The function uses SRCU (sleepable RCU) synchronization via
> partition->pt_irq_srcu, but was incorrectly using the RCU variant
> for list iteration. This could lead to race conditions when the
> list is modified concurrently.
>
> Also add srcu_read_lock_held() assertion as required by
> hlist_for_each_entry_srcu() to ensure we're in the proper
> read-side critical section.
>
Thank you.
Acked-by: Stanislav Kinsburskii <skinsburskii@linux.microsoft.com>
> Signed-off-by: Li RongQing <lirongqing@baidu.com>
> ---
> drivers/hv/mshv_eventfd.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/hv/mshv_eventfd.c b/drivers/hv/mshv_eventfd.c
> index 0b75ff1..6d176ed 100644
> --- a/drivers/hv/mshv_eventfd.c
> +++ b/drivers/hv/mshv_eventfd.c
> @@ -87,8 +87,9 @@ static void mshv_irqfd_resampler_ack(struct mshv_irq_ack_notifier *mian)
>
> idx = srcu_read_lock(&partition->pt_irq_srcu);
>
> - hlist_for_each_entry_rcu(irqfd, &resampler->rsmplr_irqfd_list,
> - irqfd_resampler_hnode) {
> + hlist_for_each_entry_srcu(irqfd, &resampler->rsmplr_irqfd_list,
> + irqfd_resampler_hnode,
> + srcu_read_lock_held(&partition->pt_irq_srcu)) {
> if (hv_should_clear_interrupt(irqfd->irqfd_lapic_irq.lapic_control.interrupt_type))
> hv_call_clear_virtual_interrupt(partition->pt_id);
>
> --
> 2.9.4
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] mshv: fix SRCU protection in irqfd resampler ack handler
2026-02-05 9:40 [PATCH] mshv: fix SRCU protection in irqfd resampler ack handler lirongqing
2026-02-05 17:14 ` Stanislav Kinsburskii
@ 2026-02-05 17:53 ` Anirudh Rayabharam
2026-02-06 7:06 ` Wei Liu
2 siblings, 0 replies; 4+ messages in thread
From: Anirudh Rayabharam @ 2026-02-05 17:53 UTC (permalink / raw)
To: lirongqing
Cc: K . Y . Srinivasan, Haiyang Zhang, Wei Liu, Dexuan Cui, Long Li,
linux-hyperv, linux-kernel
On Thu, Feb 05, 2026 at 04:40:10AM -0500, lirongqing wrote:
> From: Li RongQing <lirongqing@baidu.com>
>
> Replace hlist_for_each_entry_rcu() with hlist_for_each_entry_srcu()
> in mshv_irqfd_resampler_ack() to correctly handle SRCU-protected
> linked list traversal.
>
> The function uses SRCU (sleepable RCU) synchronization via
> partition->pt_irq_srcu, but was incorrectly using the RCU variant
> for list iteration. This could lead to race conditions when the
> list is modified concurrently.
>
> Also add srcu_read_lock_held() assertion as required by
> hlist_for_each_entry_srcu() to ensure we're in the proper
> read-side critical section.
>
> Signed-off-by: Li RongQing <lirongqing@baidu.com>
Reviewed-by: Anirudh Rayabharam (Microsoft) <anirudh@anirudhrb.com>
> ---
> drivers/hv/mshv_eventfd.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/hv/mshv_eventfd.c b/drivers/hv/mshv_eventfd.c
> index 0b75ff1..6d176ed 100644
> --- a/drivers/hv/mshv_eventfd.c
> +++ b/drivers/hv/mshv_eventfd.c
> @@ -87,8 +87,9 @@ static void mshv_irqfd_resampler_ack(struct mshv_irq_ack_notifier *mian)
>
> idx = srcu_read_lock(&partition->pt_irq_srcu);
>
> - hlist_for_each_entry_rcu(irqfd, &resampler->rsmplr_irqfd_list,
> - irqfd_resampler_hnode) {
> + hlist_for_each_entry_srcu(irqfd, &resampler->rsmplr_irqfd_list,
> + irqfd_resampler_hnode,
> + srcu_read_lock_held(&partition->pt_irq_srcu)) {
> if (hv_should_clear_interrupt(irqfd->irqfd_lapic_irq.lapic_control.interrupt_type))
> hv_call_clear_virtual_interrupt(partition->pt_id);
>
> --
> 2.9.4
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] mshv: fix SRCU protection in irqfd resampler ack handler
2026-02-05 9:40 [PATCH] mshv: fix SRCU protection in irqfd resampler ack handler lirongqing
2026-02-05 17:14 ` Stanislav Kinsburskii
2026-02-05 17:53 ` Anirudh Rayabharam
@ 2026-02-06 7:06 ` Wei Liu
2 siblings, 0 replies; 4+ messages in thread
From: Wei Liu @ 2026-02-06 7:06 UTC (permalink / raw)
To: lirongqing
Cc: K . Y . Srinivasan, Haiyang Zhang, Wei Liu, Dexuan Cui, Long Li,
linux-hyperv, linux-kernel
On Thu, Feb 05, 2026 at 04:40:10AM -0500, lirongqing wrote:
> From: Li RongQing <lirongqing@baidu.com>
>
> Replace hlist_for_each_entry_rcu() with hlist_for_each_entry_srcu()
> in mshv_irqfd_resampler_ack() to correctly handle SRCU-protected
> linked list traversal.
>
> The function uses SRCU (sleepable RCU) synchronization via
> partition->pt_irq_srcu, but was incorrectly using the RCU variant
> for list iteration. This could lead to race conditions when the
> list is modified concurrently.
>
> Also add srcu_read_lock_held() assertion as required by
> hlist_for_each_entry_srcu() to ensure we're in the proper
> read-side critical section.
>
> Signed-off-by: Li RongQing <lirongqing@baidu.com>
Thank you for the patch. Applied.
I also added a Fixes tag to the commit message.
Fixes: 621191d709b14 ("Drivers: hv: Introduce mshv_root module to expose /dev/mshv to VMMs")
> ---
> drivers/hv/mshv_eventfd.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/hv/mshv_eventfd.c b/drivers/hv/mshv_eventfd.c
> index 0b75ff1..6d176ed 100644
> --- a/drivers/hv/mshv_eventfd.c
> +++ b/drivers/hv/mshv_eventfd.c
> @@ -87,8 +87,9 @@ static void mshv_irqfd_resampler_ack(struct mshv_irq_ack_notifier *mian)
>
> idx = srcu_read_lock(&partition->pt_irq_srcu);
>
> - hlist_for_each_entry_rcu(irqfd, &resampler->rsmplr_irqfd_list,
> - irqfd_resampler_hnode) {
> + hlist_for_each_entry_srcu(irqfd, &resampler->rsmplr_irqfd_list,
> + irqfd_resampler_hnode,
> + srcu_read_lock_held(&partition->pt_irq_srcu)) {
> if (hv_should_clear_interrupt(irqfd->irqfd_lapic_irq.lapic_control.interrupt_type))
> hv_call_clear_virtual_interrupt(partition->pt_id);
>
> --
> 2.9.4
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-02-06 7:06 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-02-05 9:40 [PATCH] mshv: fix SRCU protection in irqfd resampler ack handler lirongqing
2026-02-05 17:14 ` Stanislav Kinsburskii
2026-02-05 17:53 ` Anirudh Rayabharam
2026-02-06 7:06 ` Wei Liu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®