Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mshv: fix SRCU protection in irqfd resampler ack handler

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.

Fixes: 621191d709b14 ("Drivers: hv: Introduce mshv_root module to expose /dev/mshv to VMMs")
Signed-off-by: Li RongQing <lirongqing@baidu.com>
Reviewed-by: Anirudh Rayabharam (Microsoft) <anirudh@anirudhrb.com>
Acked-by: Stanislav Kinsburskii <skinsburskii@linux.microsoft.com>
Signed-off-by: Wei Liu <wei.liu@kernel.org>

authored by

Li RongQing and committed by
Wei Liu
2e7577cd 51515bfc

+3 -2
+3 -2
drivers/hv/mshv_eventfd.c
··· 87 87 88 88 idx = srcu_read_lock(&partition->pt_irq_srcu); 89 89 90 - hlist_for_each_entry_rcu(irqfd, &resampler->rsmplr_irqfd_list, 91 - irqfd_resampler_hnode) { 90 + hlist_for_each_entry_srcu(irqfd, &resampler->rsmplr_irqfd_list, 91 + irqfd_resampler_hnode, 92 + srcu_read_lock_held(&partition->pt_irq_srcu)) { 92 93 if (hv_should_clear_interrupt(irqfd->irqfd_lapic_irq.lapic_control.interrupt_type)) 93 94 hv_call_clear_virtual_interrupt(partition->pt_id); 94 95