* [PATCH net v2] virtio_net: fix virtnet_open and virtnet_probe competing for try_fill_recv
@ 2016-05-26 6:27 wangyunjian
2016-05-26 9:33 ` Jason Wang
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: wangyunjian @ 2016-05-26 6:27 UTC (permalink / raw)
To: davem, jasowang, mst, rusty, netdev; +Cc: liuyongan
In function virtnet_open() and virtnet_probe(), func try_fill_recv()
will be executed at the same time. VQ in virtqueue_add() is not protected
well and BUG_ON will be triggered when virito_net.ko being removed.
Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
---
drivers/net/virtio_net.c | 18 ++----------------
1 file changed, 2 insertions(+), 16 deletions(-)
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 49d84e5..e0638e5 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -1925,24 +1925,11 @@ static int virtnet_probe(struct virtio_device *vdev)
virtio_device_ready(vdev);
- /* Last of all, set up some receive buffers. */
- for (i = 0; i < vi->curr_queue_pairs; i++) {
- try_fill_recv(vi, &vi->rq[i], GFP_KERNEL);
-
- /* If we didn't even get one input buffer, we're useless. */
- if (vi->rq[i].vq->num_free ==
- virtqueue_get_vring_size(vi->rq[i].vq)) {
- free_unused_bufs(vi);
- err = -ENOMEM;
- goto free_recv_bufs;
- }
- }
-
vi->nb.notifier_call = &virtnet_cpu_callback;
err = register_hotcpu_notifier(&vi->nb);
if (err) {
pr_debug("virtio_net: registering cpu notifier failed\n");
- goto free_recv_bufs;
+ goto free_unregister_netdev;
}
/* Assume link up if device can't report link status,
@@ -1960,10 +1947,9 @@ static int virtnet_probe(struct virtio_device *vdev)
return 0;
-free_recv_bufs:
+free_unregister_netdev:
vi->vdev->config->reset(vdev);
- free_receive_bufs(vi);
unregister_netdev(dev);
free_vqs:
cancel_delayed_work_sync(&vi->refill);
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net v2] virtio_net: fix virtnet_open and virtnet_probe competing for try_fill_recv
2016-05-26 6:27 [PATCH net v2] virtio_net: fix virtnet_open and virtnet_probe competing for try_fill_recv wangyunjian
@ 2016-05-26 9:33 ` Jason Wang
2016-05-26 9:36 ` Michael S. Tsirkin
2016-05-30 5:31 ` David Miller
2 siblings, 0 replies; 4+ messages in thread
From: Jason Wang @ 2016-05-26 9:33 UTC (permalink / raw)
To: wangyunjian, davem, mst, rusty, netdev; +Cc: liuyongan
On 2016年05月26日 14:27, wangyunjian wrote:
> In function virtnet_open() and virtnet_probe(), func try_fill_recv()
> will be executed at the same time. VQ in virtqueue_add() is not protected
> well and BUG_ON will be triggered when virito_net.ko being removed.
>
> Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
> ---
> drivers/net/virtio_net.c | 18 ++----------------
> 1 file changed, 2 insertions(+), 16 deletions(-)
The patch is needed for stable.
Acked-by: Jason Wang <jasowang@redhat.com>
>
> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> index 49d84e5..e0638e5 100644
> --- a/drivers/net/virtio_net.c
> +++ b/drivers/net/virtio_net.c
> @@ -1925,24 +1925,11 @@ static int virtnet_probe(struct virtio_device *vdev)
>
> virtio_device_ready(vdev);
>
> - /* Last of all, set up some receive buffers. */
> - for (i = 0; i < vi->curr_queue_pairs; i++) {
> - try_fill_recv(vi, &vi->rq[i], GFP_KERNEL);
> -
> - /* If we didn't even get one input buffer, we're useless. */
> - if (vi->rq[i].vq->num_free ==
> - virtqueue_get_vring_size(vi->rq[i].vq)) {
> - free_unused_bufs(vi);
> - err = -ENOMEM;
> - goto free_recv_bufs;
> - }
> - }
> -
> vi->nb.notifier_call = &virtnet_cpu_callback;
> err = register_hotcpu_notifier(&vi->nb);
> if (err) {
> pr_debug("virtio_net: registering cpu notifier failed\n");
> - goto free_recv_bufs;
> + goto free_unregister_netdev;
> }
>
> /* Assume link up if device can't report link status,
> @@ -1960,10 +1947,9 @@ static int virtnet_probe(struct virtio_device *vdev)
>
> return 0;
>
> -free_recv_bufs:
> +free_unregister_netdev:
> vi->vdev->config->reset(vdev);
>
> - free_receive_bufs(vi);
> unregister_netdev(dev);
> free_vqs:
> cancel_delayed_work_sync(&vi->refill);
> --
> 1.7.12.4
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net v2] virtio_net: fix virtnet_open and virtnet_probe competing for try_fill_recv
2016-05-26 6:27 [PATCH net v2] virtio_net: fix virtnet_open and virtnet_probe competing for try_fill_recv wangyunjian
2016-05-26 9:33 ` Jason Wang
@ 2016-05-26 9:36 ` Michael S. Tsirkin
2016-05-30 5:31 ` David Miller
2 siblings, 0 replies; 4+ messages in thread
From: Michael S. Tsirkin @ 2016-05-26 9:36 UTC (permalink / raw)
To: wangyunjian; +Cc: davem, jasowang, rusty, netdev, liuyongan
On Thu, May 26, 2016 at 02:27:59PM +0800, wangyunjian wrote:
> In function virtnet_open() and virtnet_probe(), func try_fill_recv()
> will be executed at the same time. VQ in virtqueue_add() is not protected
> well and BUG_ON will be triggered when virito_net.ko being removed.
>
> Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
> ---
> drivers/net/virtio_net.c | 18 ++----------------
> 1 file changed, 2 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> index 49d84e5..e0638e5 100644
> --- a/drivers/net/virtio_net.c
> +++ b/drivers/net/virtio_net.c
> @@ -1925,24 +1925,11 @@ static int virtnet_probe(struct virtio_device *vdev)
>
> virtio_device_ready(vdev);
>
> - /* Last of all, set up some receive buffers. */
> - for (i = 0; i < vi->curr_queue_pairs; i++) {
> - try_fill_recv(vi, &vi->rq[i], GFP_KERNEL);
> -
> - /* If we didn't even get one input buffer, we're useless. */
> - if (vi->rq[i].vq->num_free ==
> - virtqueue_get_vring_size(vi->rq[i].vq)) {
> - free_unused_bufs(vi);
> - err = -ENOMEM;
> - goto free_recv_bufs;
> - }
> - }
> -
> vi->nb.notifier_call = &virtnet_cpu_callback;
> err = register_hotcpu_notifier(&vi->nb);
> if (err) {
> pr_debug("virtio_net: registering cpu notifier failed\n");
> - goto free_recv_bufs;
> + goto free_unregister_netdev;
> }
>
> /* Assume link up if device can't report link status,
> @@ -1960,10 +1947,9 @@ static int virtnet_probe(struct virtio_device *vdev)
>
> return 0;
>
> -free_recv_bufs:
> +free_unregister_netdev:
> vi->vdev->config->reset(vdev);
>
> - free_receive_bufs(vi);
> unregister_netdev(dev);
> free_vqs:
> cancel_delayed_work_sync(&vi->refill);
> --
> 1.7.12.4
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net v2] virtio_net: fix virtnet_open and virtnet_probe competing for try_fill_recv
2016-05-26 6:27 [PATCH net v2] virtio_net: fix virtnet_open and virtnet_probe competing for try_fill_recv wangyunjian
2016-05-26 9:33 ` Jason Wang
2016-05-26 9:36 ` Michael S. Tsirkin
@ 2016-05-30 5:31 ` David Miller
2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2016-05-30 5:31 UTC (permalink / raw)
To: wangyunjian; +Cc: jasowang, mst, rusty, netdev, liuyongan
From: wangyunjian <wangyunjian@huawei.com>
Date: Thu, 26 May 2016 14:27:59 +0800
> In function virtnet_open() and virtnet_probe(), func try_fill_recv()
> will be executed at the same time. VQ in virtqueue_add() is not protected
> well and BUG_ON will be triggered when virito_net.ko being removed.
>
> Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
Patch is whitespace damanged by your email client.
Fix this, email a test patch to yourself, and do not try to resubmit
this patch to the mailing list until you can successfully apply one of
those test patches.
Thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-05-30 5:31 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-26 6:27 [PATCH net v2] virtio_net: fix virtnet_open and virtnet_probe competing for try_fill_recv wangyunjian
2016-05-26 9:33 ` Jason Wang
2016-05-26 9:36 ` Michael S. Tsirkin
2016-05-30 5:31 ` 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).