Commit 557602e
committed
virtio-net: fix race between ndo_open() and virtio_device_ready()
Bugzilla: http://bugzilla.redhat.com/2153210
commit 50c0ada
Author: Jason Wang <jasowang@redhat.com>
Date: Fri Jun 17 15:29:49 2022 +0800
virtio-net: fix race between ndo_open() and virtio_device_ready()
We currently call virtio_device_ready() after netdev
registration. Since ndo_open() can be called immediately
after register_netdev, this means there exists a race between
ndo_open() and virtio_device_ready(): the driver may start to use the
device before DRIVER_OK which violates the spec.
Fix this by switching to use register_netdevice() and protect the
virtio_device_ready() with rtnl_lock() to make sure ndo_open() can
only be called after virtio_device_ready().
Fixes: 4baf1e3 ("virtio_net: enable VQs early")
Signed-off-by: Jason Wang <jasowang@redhat.com>
Message-Id: <20220617072949.30734-1-jasowang@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Conflict in the context because of missing commit:
c7114b1 ("drivers/net/virtio_net: Added basic RSS support.")
Signed-off-by: Laurent Vivier <lvivier@redhat.com>1 parent 032ef07 commit 557602e
1 file changed
+7
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3269 | 3269 | | |
3270 | 3270 | | |
3271 | 3271 | | |
3272 | | - | |
| 3272 | + | |
| 3273 | + | |
| 3274 | + | |
| 3275 | + | |
3273 | 3276 | | |
3274 | 3277 | | |
| 3278 | + | |
3275 | 3279 | | |
3276 | 3280 | | |
3277 | 3281 | | |
3278 | 3282 | | |
3279 | 3283 | | |
| 3284 | + | |
| 3285 | + | |
3280 | 3286 | | |
3281 | 3287 | | |
3282 | 3288 | | |
| |||
0 commit comments