Commit ec7d8e7d authored by Juergen Gross's avatar Juergen Gross Committed by Jakub Kicinski

xen/netback: avoid race in xenvif_rx_ring_slots_available()

Since commit 23025393 ("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: default avatarIgor Druzhinin <igor.druzhinin@citrix.com>
Fixes: 23025393 ("xen/netback: use lateeoi irq binding")
Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
Acked-by: default avatarWei Liu <wl@xen.org>
Link: https://lore.kernel.org/r/20210202070938.7863-1-jgross@suse.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent d795cc02
...@@ -38,10 +38,15 @@ static bool xenvif_rx_ring_slots_available(struct xenvif_queue *queue) ...@@ -38,10 +38,15 @@ static bool xenvif_rx_ring_slots_available(struct xenvif_queue *queue)
RING_IDX prod, cons; RING_IDX prod, cons;
struct sk_buff *skb; struct sk_buff *skb;
int needed; int needed;
unsigned long flags;
spin_lock_irqsave(&queue->rx_queue.lock, flags);
skb = skb_peek(&queue->rx_queue); skb = skb_peek(&queue->rx_queue);
if (!skb) if (!skb) {
spin_unlock_irqrestore(&queue->rx_queue.lock, flags);
return false; return false;
}
needed = DIV_ROUND_UP(skb->len, XEN_PAGE_SIZE); needed = DIV_ROUND_UP(skb->len, XEN_PAGE_SIZE);
if (skb_is_gso(skb)) if (skb_is_gso(skb))
...@@ -49,6 +54,8 @@ static bool xenvif_rx_ring_slots_available(struct xenvif_queue *queue) ...@@ -49,6 +54,8 @@ static bool xenvif_rx_ring_slots_available(struct xenvif_queue *queue)
if (skb->sw_hash) if (skb->sw_hash)
needed++; needed++;
spin_unlock_irqrestore(&queue->rx_queue.lock, flags);
do { do {
prod = queue->rx.sring->req_prod; prod = queue->rx.sring->req_prod;
cons = queue->rx.req_cons; cons = queue->rx.req_cons;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment