Skip to content

Commit 2e7577c

Browse files
lrq-maxliuw
authored andcommitted
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: 621191d ("Drivers: hv: Introduce mshv_root module to expose /dev/mshv to VMMs") Signed-off-by: Li RongQing <[email protected]> Reviewed-by: Anirudh Rayabharam (Microsoft) <[email protected]> Acked-by: Stanislav Kinsburskii <[email protected]> Signed-off-by: Wei Liu <[email protected]>
1 parent 51515bf commit 2e7577c

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

drivers/hv/mshv_eventfd.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,9 @@ static void mshv_irqfd_resampler_ack(struct mshv_irq_ack_notifier *mian)
8787

8888
idx = srcu_read_lock(&partition->pt_irq_srcu);
8989

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)) {
9293
if (hv_should_clear_interrupt(irqfd->irqfd_lapic_irq.lapic_control.interrupt_type))
9394
hv_call_clear_virtual_interrupt(partition->pt_id);
9495

0 commit comments

Comments
 (0)