xen/netback: avoid race in xenvif_rx_ring_slots_available()
Subsystems (4)
PATCH 1/1 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.
--- drivers/net/xen-netback/rx.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/net/xen-netback/rx.c +8 -1
@@ -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;
Signature · 1 line
2.26.2
Quoted 9 lines · Juergen Gross
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 <[email protected]>Fixes 23025393dbeb3b8b3 ("xen/netback: use lateeoi irq binding")Signed-off-by Juergen Gross <[email protected]>
Appreciate a quick fix! Is this the only place that sort of race could happen now?
Igor
Quoted 6 lines · Igor Druzhinin
Quoted 5 lines · Juergen Gross
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.
Quoted 7 lines
Quoted 4 lines
Reported-by Igor Druzhinin <[email protected]>Fixes 23025393dbeb3b8b3 ("xen/netback: use lateeoi irq binding")Signed-off-by Juergen Gross <[email protected]>Appreciate a quick fix! Is this the only place that sort of race could happen now?
I checked and didn't find any other similar problem.
Juergen
Quoted 9 lines · Juergen Gross
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 <[email protected]>Fixes 23025393dbeb3b8b3 ("xen/netback: use lateeoi irq binding")Signed-off-by Juergen Gross <[email protected]>
Jakub Kicinski
maintainerQuoted 9 lines · On Tue, 2 Feb 2021 08:09:38 +0100 Juergen Gross wrote:
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 <[email protected]>Fixes 23025393dbeb3b8b3 ("xen/netback: use lateeoi irq binding")Signed-off-by Juergen Gross <[email protected]>
Should we route this change via networking trees? I see the bug did not go through networking :)
Quoted 6 lines · Jakub Kicinski
Quoted 5 lines · On Tue, 2 Feb 2021 08:09:38 +0100 Juergen Gross wrote:
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.
Quoted 8 lines
Quoted 4 lines
Reported-by Igor Druzhinin <[email protected]>Fixes 23025393dbeb3b8b3 ("xen/netback: use lateeoi irq binding")Signed-off-by Juergen Gross <[email protected]>Should we route this change via networking trees? I see the bug did not go through networking :)
I'm fine with either networking or the Xen tree. It should be included in 5.11, though. So if you are willing to take it, please do so.
Juergen
Jakub Kicinski
maintainerQuoted 12 lines · On Thu, 4 Feb 2021 06:32:32 +0100 Jürgen Groß wrote:
Quoted 11 lines · Jakub Kicinski
Quoted 9 lines · On Tue, 2 Feb 2021 08:09:38 +0100 Juergen Gross wrote:
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 <[email protected]>Fixes 23025393dbeb3b8b3 ("xen/netback: use lateeoi irq binding")Signed-off-by Juergen Gross <[email protected]>
Quoted 5 lines
Quoted 2 lines
Should we route this change via networking trees? I see the bug did not go through networking :)
I'm fine with either networking or the Xen tree. It should be included in 5.11, though. So if you are willing to take it, please do so.
All right, applied to net, it'll most likely hit Linus's tree on Tue.
Thanks!