netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Jason Wang <jasowang@redhat.com>
Cc: xuanzhuo@linux.alibaba.com, eperezma@redhat.com,
	davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
	pabeni@redhat.com, virtualization@lists.linux.dev,
	netdev@vger.kernel.org, inux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next V6 4/4] virtio-net: synchronize probe with ndo_set_features
Date: Tue, 6 Aug 2024 08:24:57 -0400	[thread overview]
Message-ID: <20240806082436-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20240806022224.71779-5-jasowang@redhat.com>

On Tue, Aug 06, 2024 at 10:22:24AM +0800, Jason Wang wrote:
> We calculate guest offloads during probe without the protection of
> rtnl_lock. This lead to race between probe and ndo_set_features. Fix
> this by moving the calculation under the rtnl_lock.
> 
> Signed-off-by: Jason Wang <jasowang@redhat.com>

Fixes tag pls?

> ---
>  drivers/net/virtio_net.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> index fc5196ca8d51..1d86aa07c871 100644
> --- a/drivers/net/virtio_net.c
> +++ b/drivers/net/virtio_net.c
> @@ -6596,6 +6596,11 @@ static int virtnet_probe(struct virtio_device *vdev)
>  		netif_carrier_on(dev);
>  	}
>  
> +	for (i = 0; i < ARRAY_SIZE(guest_offloads); i++)
> +		if (virtio_has_feature(vi->vdev, guest_offloads[i]))
> +			set_bit(guest_offloads[i], &vi->guest_offloads);
> +	vi->guest_offloads_capable = vi->guest_offloads;
> +
>  	rtnl_unlock();
>  
>  	err = virtnet_cpu_notif_add(vi);
> @@ -6604,11 +6609,6 @@ static int virtnet_probe(struct virtio_device *vdev)
>  		goto free_unregister_netdev;
>  	}
>  
> -	for (i = 0; i < ARRAY_SIZE(guest_offloads); i++)
> -		if (virtio_has_feature(vi->vdev, guest_offloads[i]))
> -			set_bit(guest_offloads[i], &vi->guest_offloads);
> -	vi->guest_offloads_capable = vi->guest_offloads;
> -
>  	pr_debug("virtnet: registered device %s with %d RX and TX vq's\n",
>  		 dev->name, max_queue_pairs);
>  
> -- 
> 2.31.1


  reply	other threads:[~2024-08-06 12:25 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-06  2:22 [PATCH net-next V6 0/4] virtio-net: synchronize op/admin state Jason Wang
2024-08-06  2:22 ` [PATCH net-next V6 1/4] virtio: rename virtio_config_enabled to virtio_config_core_enabled Jason Wang
2024-08-06  2:22 ` [PATCH net-next V6 2/4] virtio: allow driver to disable the configure change notification Jason Wang
2024-08-06  2:22 ` [PATCH net-next V6 3/4] virtio-net: synchronize operstate with admin state on up/down Jason Wang
2024-08-06  2:22 ` [PATCH net-next V6 4/4] virtio-net: synchronize probe with ndo_set_features Jason Wang
2024-08-06 12:24   ` Michael S. Tsirkin [this message]
2024-08-13  3:45     ` Jason Wang
2024-08-07 13:51 ` [PATCH net-next V6 0/4] virtio-net: synchronize op/admin state Michael S. Tsirkin
2024-08-13  3:43   ` Jason Wang
2024-08-13 14:40     ` Jakub Kicinski
2024-08-14  5:23       ` Jason Wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240806082436-mutt-send-email-mst@kernel.org \
    --to=mst@redhat.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=eperezma@redhat.com \
    --cc=inux-kernel@vger.kernel.org \
    --cc=jasowang@redhat.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=virtualization@lists.linux.dev \
    --cc=xuanzhuo@linux.alibaba.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).