* [PATCH] xen/netback: avoid race in xenvif_rx_ring_slots_available()
@ 2021-02-02 7:09 Juergen Gross
2021-02-02 15:26 ` Igor Druzhinin
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Juergen Gross @ 2021-02-02 7:09 UTC (permalink / raw)
To: xen-devel, netdev, linux-kernel
Cc: Juergen Gross, Wei Liu, Paul Durrant, David S. Miller,
Jakub Kicinski, Igor Druzhinin, stable
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@citrix.com>
Fixes: 23025393dbeb3b8b3 ("xen/netback: use lateeoi irq binding")
Cc: stable@vger.kernel.org
Signed-off-by: Juergen Gross <jgross@suse.com>
---
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
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] xen/netback: avoid race in xenvif_rx_ring_slots_available()
2021-02-02 7:09 [PATCH] xen/netback: avoid race in xenvif_rx_ring_slots_available() Juergen Gross
@ 2021-02-02 15:26 ` Igor Druzhinin
2021-02-02 16:12 ` Jürgen Groß
2021-02-02 16:22 ` Wei Liu
2021-02-03 23:48 ` Jakub Kicinski
2 siblings, 1 reply; 7+ messages in thread
From: Igor Druzhinin @ 2021-02-02 15:26 UTC (permalink / raw)
To: Juergen Gross, xen-devel, netdev, linux-kernel
Cc: Wei Liu, Paul Durrant, David S. Miller, Jakub Kicinski, stable
On 02/02/2021 07:09, 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 <igor.druzhinin@citrix.com>
> Fixes: 23025393dbeb3b8b3 ("xen/netback: use lateeoi irq binding")
> Cc: stable@vger.kernel.org
> Signed-off-by: Juergen Gross <jgross@suse.com>
Appreciate a quick fix! Is this the only place that sort of race could
happen now?
Igor
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] xen/netback: avoid race in xenvif_rx_ring_slots_available()
2021-02-02 15:26 ` Igor Druzhinin
@ 2021-02-02 16:12 ` Jürgen Groß
0 siblings, 0 replies; 7+ messages in thread
From: Jürgen Groß @ 2021-02-02 16:12 UTC (permalink / raw)
To: Igor Druzhinin, xen-devel, netdev, linux-kernel
Cc: Wei Liu, Paul Durrant, David S. Miller, Jakub Kicinski, stable
[-- Attachment #1.1.1: Type: text/plain, Size: 713 bytes --]
On 02.02.21 16:26, Igor Druzhinin wrote:
> On 02/02/2021 07:09, 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 <igor.druzhinin@citrix.com>
>> Fixes: 23025393dbeb3b8b3 ("xen/netback: use lateeoi irq binding")
>> Cc: stable@vger.kernel.org
>> Signed-off-by: Juergen Gross <jgross@suse.com>
>
> 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
[-- Attachment #1.1.2: OpenPGP_0xB0DE9DD628BF132F.asc --]
[-- Type: application/pgp-keys, Size: 3135 bytes --]
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 495 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] xen/netback: avoid race in xenvif_rx_ring_slots_available()
2021-02-02 7:09 [PATCH] xen/netback: avoid race in xenvif_rx_ring_slots_available() Juergen Gross
2021-02-02 15:26 ` Igor Druzhinin
@ 2021-02-02 16:22 ` Wei Liu
2021-02-03 23:48 ` Jakub Kicinski
2 siblings, 0 replies; 7+ messages in thread
From: Wei Liu @ 2021-02-02 16:22 UTC (permalink / raw)
To: Juergen Gross
Cc: xen-devel, netdev, linux-kernel, Wei Liu, Paul Durrant,
David S. Miller, Jakub Kicinski, Igor Druzhinin, stable
On Tue, Feb 02, 2021 at 08:09:38AM +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 <igor.druzhinin@citrix.com>
> Fixes: 23025393dbeb3b8b3 ("xen/netback: use lateeoi irq binding")
> Cc: stable@vger.kernel.org
> Signed-off-by: Juergen Gross <jgross@suse.com>
Acked-by: Wei Liu <wl@xen.org>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] xen/netback: avoid race in xenvif_rx_ring_slots_available()
2021-02-02 7:09 [PATCH] xen/netback: avoid race in xenvif_rx_ring_slots_available() Juergen Gross
2021-02-02 15:26 ` Igor Druzhinin
2021-02-02 16:22 ` Wei Liu
@ 2021-02-03 23:48 ` Jakub Kicinski
2021-02-04 5:32 ` Jürgen Groß
2 siblings, 1 reply; 7+ messages in thread
From: Jakub Kicinski @ 2021-02-03 23:48 UTC (permalink / raw)
To: Juergen Gross
Cc: xen-devel, netdev, linux-kernel, Wei Liu, Paul Durrant,
David S. Miller, Igor Druzhinin, stable
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 <igor.druzhinin@citrix.com>
> Fixes: 23025393dbeb3b8b3 ("xen/netback: use lateeoi irq binding")
> Cc: stable@vger.kernel.org
> Signed-off-by: Juergen Gross <jgross@suse.com>
Should we route this change via networking trees? I see the bug did not
go through networking :)
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] xen/netback: avoid race in xenvif_rx_ring_slots_available()
2021-02-03 23:48 ` Jakub Kicinski
@ 2021-02-04 5:32 ` Jürgen Groß
2021-02-05 1:56 ` Jakub Kicinski
0 siblings, 1 reply; 7+ messages in thread
From: Jürgen Groß @ 2021-02-04 5:32 UTC (permalink / raw)
To: Jakub Kicinski
Cc: xen-devel, netdev, linux-kernel, Wei Liu, Paul Durrant,
David S. Miller, Igor Druzhinin, stable
[-- Attachment #1.1.1: Type: text/plain, Size: 827 bytes --]
On 04.02.21 00:48, Jakub Kicinski wrote:
> 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 <igor.druzhinin@citrix.com>
>> Fixes: 23025393dbeb3b8b3 ("xen/netback: use lateeoi irq binding")
>> Cc: stable@vger.kernel.org
>> Signed-off-by: Juergen Gross <jgross@suse.com>
>
> 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
[-- Attachment #1.1.2: OpenPGP_0xB0DE9DD628BF132F.asc --]
[-- Type: application/pgp-keys, Size: 3135 bytes --]
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 495 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] xen/netback: avoid race in xenvif_rx_ring_slots_available()
2021-02-04 5:32 ` Jürgen Groß
@ 2021-02-05 1:56 ` Jakub Kicinski
0 siblings, 0 replies; 7+ messages in thread
From: Jakub Kicinski @ 2021-02-05 1:56 UTC (permalink / raw)
To: Jürgen Groß
Cc: xen-devel, netdev, linux-kernel, Wei Liu, Paul Durrant,
David S. Miller, Igor Druzhinin, stable
On Thu, 4 Feb 2021 06:32:32 +0100 Jürgen Groß wrote:
> On 04.02.21 00:48, Jakub Kicinski wrote:
> > 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 <igor.druzhinin@citrix.com>
> >> Fixes: 23025393dbeb3b8b3 ("xen/netback: use lateeoi irq binding")
> >> Cc: stable@vger.kernel.org
> >> Signed-off-by: Juergen Gross <jgross@suse.com>
> >
> > 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!
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2021-02-05 1:56 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-02 7:09 [PATCH] xen/netback: avoid race in xenvif_rx_ring_slots_available() Juergen Gross
2021-02-02 15:26 ` Igor Druzhinin
2021-02-02 16:12 ` Jürgen Groß
2021-02-02 16:22 ` Wei Liu
2021-02-03 23:48 ` Jakub Kicinski
2021-02-04 5:32 ` Jürgen Groß
2021-02-05 1:56 ` Jakub Kicinski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).