[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] xen/netback: avoid race in xenvif_rx_ring_slots_available()



Since commit 23025393dbeb3b8b3 ("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@xxxxxxxxxx>
Fixes: 23025393dbeb3b8b3 ("xen/netback: use lateeoi irq binding")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Juergen Gross <jgross@xxxxxxxx>
---
 drivers/net/xen-netback/rx.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/net/xen-netback/rx.c b/drivers/net/xen-netback/rx.c
index b8febe1d1bfd..accc991d153f 100644
--- a/drivers/net/xen-netback/rx.c
+++ b/drivers/net/xen-netback/rx.c
@@ -38,10 +38,15 @@ static bool xenvif_rx_ring_slots_available(struct 
xenvif_queue *queue)
        RING_IDX prod, cons;
        struct sk_buff *skb;
        int needed;
+       unsigned long flags;
+
+       spin_lock_irqsave(&queue->rx_queue.lock, flags);
 
        skb = skb_peek(&queue->rx_queue);
-       if (!skb)
+       if (!skb) {
+               spin_unlock_irqrestore(&queue->rx_queue.lock, flags);
                return false;
+       }
 
        needed = DIV_ROUND_UP(skb->len, XEN_PAGE_SIZE);
        if (skb_is_gso(skb))
@@ -49,6 +54,8 @@ static bool xenvif_rx_ring_slots_available(struct 
xenvif_queue *queue)
        if (skb->sw_hash)
                needed++;
 
+       spin_unlock_irqrestore(&queue->rx_queue.lock, flags);
+
        do {
                prod = queue->rx.sring->req_prod;
                cons = queue->rx.req_cons;
-- 
2.26.2




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.