Skip to content

Commit ec7d8e7

Browse files
jgross1kuba-moo
authored andcommitted
xen/netback: avoid race in xenvif_rx_ring_slots_available()
Since commit 2302539 ("xen/netback: use lateeoi irq binding") xenvif_rx_ring_slots_available() is no longer called only from the rx queue kernel thread, so it needs to access the rx queue with the associated queue held. Reported-by: Igor Druzhinin <igor.druzhinin@citrix.com> Fixes: 2302539 ("xen/netback: use lateeoi irq binding") Signed-off-by: Juergen Gross <jgross@suse.com> Acked-by: Wei Liu <wl@xen.org> Link: https://lore.kernel.org/r/20210202070938.7863-1-jgross@suse.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent d795cc0 commit ec7d8e7

File tree

1 file changed

+8
-1
lines changed
  • drivers/net/xen-netback

1 file changed

+8
-1
lines changed

drivers/net/xen-netback/rx.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,24 @@ static bool xenvif_rx_ring_slots_available(struct xenvif_queue *queue)
3838
RING_IDX prod, cons;
3939
struct sk_buff *skb;
4040
int needed;
41+
unsigned long flags;
42+
43+
spin_lock_irqsave(&queue->rx_queue.lock, flags);
4144

4245
skb = skb_peek(&queue->rx_queue);
43-
if (!skb)
46+
if (!skb) {
47+
spin_unlock_irqrestore(&queue->rx_queue.lock, flags);
4448
return false;
49+
}
4550

4651
needed = DIV_ROUND_UP(skb->len, XEN_PAGE_SIZE);
4752
if (skb_is_gso(skb))
4853
needed++;
4954
if (skb->sw_hash)
5055
needed++;
5156

57+
spin_unlock_irqrestore(&queue->rx_queue.lock, flags);
58+
5259
do {
5360
prod = queue->rx.sring->req_prod;
5461
cons = queue->rx.req_cons;

0 commit comments

Comments
 (0)