Skip to content

Commit 24db39f

Browse files
committed
[gve] Run startup process only while device is open
The startup process is scheduled to run when the device is opened and terminated (if still running) when the device is closed. It assumes that the resource allocation performed in gve_open() has taken place, and that the admin and transmit/receive data structure pointers are therefore valid. The process initialisation in gve_probe() erroneously calls process_init() rather than process_init_stopped() and will therefore schedule the startup process immediately, before the relevant resources have been allocated. This bug is masked in the typical use case of a Google Cloud instance with a single NIC built with the config/cloud/gce.ipxe embedded script, since the embedded script will immediately open the NIC (and therefore allocate the required resources) before the scheduled process is allowed to run for the first time. In a multi-NIC instance, undefined behaviour will arise as soon as the startup process for the second NIC is allowed to run. Fix by using process_init_stopped() to avoid implicitly scheduling the startup process during gve_probe(). Originally-fixed-by: Kal Cutter Conley <[email protected]> Signed-off-by: Michael Brown <[email protected]>
1 parent 5202f83 commit 24db39f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/drivers/net/gve.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -1543,7 +1543,8 @@ static int gve_probe ( struct pci_device *pci ) {
15431543
gve->netdev = netdev;
15441544
gve->tx.type = &gve_tx_type;
15451545
gve->rx.type = &gve_rx_type;
1546-
process_init ( &gve->startup, &gve_startup_desc, &netdev->refcnt );
1546+
process_init_stopped ( &gve->startup, &gve_startup_desc,
1547+
&netdev->refcnt );
15471548
timer_init ( &gve->watchdog, gve_watchdog, &netdev->refcnt );
15481549

15491550
/* Fix up PCI device */

0 commit comments

Comments
 (0)