* [PATCH net] virtio-net: add a missing synchronize_net()
@ 2016-11-16 6:24 Eric Dumazet
2016-11-16 13:55 ` Michael S. Tsirkin
2016-11-16 20:12 ` David Miller
0 siblings, 2 replies; 3+ messages in thread
From: Eric Dumazet @ 2016-11-16 6:24 UTC (permalink / raw)
To: David Miller; +Cc: netdev, Jason Wang, Michael S. Tsirkin
From: Eric Dumazet <edumazet@google.com>
It seems many drivers do not respect napi_hash_del() contract.
When napi_hash_del() is used before netif_napi_del(), an RCU grace
period is needed before freeing NAPI object.
Fixes: 91815639d880 ("virtio-net: rx busy polling support")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Jason Wang <jasowang@redhat.com>
Cc: Michael S. Tsirkin <mst@redhat.com>
---
drivers/net/virtio_net.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index fd8b1e62301f..7276d5a95bd0 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -1497,6 +1497,11 @@ static void virtnet_free_queues(struct virtnet_info *vi)
netif_napi_del(&vi->rq[i].napi);
}
+ /* We called napi_hash_del() before netif_napi_del(),
+ * we need to respect an RCU grace period before freeing vi->rq
+ */
+ synchronize_net();
+
kfree(vi->rq);
kfree(vi->sq);
}
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net] virtio-net: add a missing synchronize_net()
2016-11-16 6:24 [PATCH net] virtio-net: add a missing synchronize_net() Eric Dumazet
@ 2016-11-16 13:55 ` Michael S. Tsirkin
2016-11-16 20:12 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: Michael S. Tsirkin @ 2016-11-16 13:55 UTC (permalink / raw)
To: Eric Dumazet; +Cc: David Miller, netdev, Jason Wang
On Tue, Nov 15, 2016 at 10:24:12PM -0800, Eric Dumazet wrote:
> From: Eric Dumazet <edumazet@google.com>
>
> It seems many drivers do not respect napi_hash_del() contract.
>
> When napi_hash_del() is used before netif_napi_del(), an RCU grace
> period is needed before freeing NAPI object.
>
> Fixes: 91815639d880 ("virtio-net: rx busy polling support")
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Cc: Jason Wang <jasowang@redhat.com>
> Cc: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
> ---
> drivers/net/virtio_net.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> index fd8b1e62301f..7276d5a95bd0 100644
> --- a/drivers/net/virtio_net.c
> +++ b/drivers/net/virtio_net.c
> @@ -1497,6 +1497,11 @@ static void virtnet_free_queues(struct virtnet_info *vi)
> netif_napi_del(&vi->rq[i].napi);
> }
>
> + /* We called napi_hash_del() before netif_napi_del(),
> + * we need to respect an RCU grace period before freeing vi->rq
> + */
> + synchronize_net();
> +
> kfree(vi->rq);
> kfree(vi->sq);
> }
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net] virtio-net: add a missing synchronize_net()
2016-11-16 6:24 [PATCH net] virtio-net: add a missing synchronize_net() Eric Dumazet
2016-11-16 13:55 ` Michael S. Tsirkin
@ 2016-11-16 20:12 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2016-11-16 20:12 UTC (permalink / raw)
To: eric.dumazet; +Cc: netdev, jasowang, mst
From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Tue, 15 Nov 2016 22:24:12 -0800
> From: Eric Dumazet <edumazet@google.com>
>
> It seems many drivers do not respect napi_hash_del() contract.
>
> When napi_hash_del() is used before netif_napi_del(), an RCU grace
> period is needed before freeing NAPI object.
>
> Fixes: 91815639d880 ("virtio-net: rx busy polling support")
> Signed-off-by: Eric Dumazet <edumazet@google.com>
Applied and queued up for -stable, thanks Eric.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-11-16 20:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-16 6:24 [PATCH net] virtio-net: add a missing synchronize_net() Eric Dumazet
2016-11-16 13:55 ` Michael S. Tsirkin
2016-11-16 20:12 ` David Miller
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).