Skip to content

Commit a7efffe

Browse files
Jordan Rheegregkh
authored andcommitted
gve: prevent ethtool ops after shutdown
[ Upstream commit 75a9a46 ] A crash can occur if an ethtool operation is invoked after shutdown() is called. shutdown() is invoked during system shutdown to stop DMA operations without performing expensive deallocations. It is discouraged to unregister the netdev in this path, so the device may still be visible to userspace and kernel helpers. In gve, shutdown() tears down most internal data structures. If an ethtool operation is dispatched after shutdown(), it will dereference freed or NULL pointers, leading to a kernel panic. While graceful shutdown normally quiesces userspace before invoking the reboot syscall, forced shutdowns (as observed on GCP VMs) can still trigger this path. Fix by calling netif_device_detach() in shutdown(). This marks the device as detached so the ethtool ioctl handler will skip dispatching operations to the driver. Fixes: 974365e ("gve: Implement suspend/resume/shutdown") Signed-off-by: Jordan Rhee <[email protected]> Signed-off-by: Jeroen de Borst <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 22042ff commit a7efffe

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

drivers/net/ethernet/google/gve/gve_main.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2726,6 +2726,8 @@ static void gve_shutdown(struct pci_dev *pdev)
27262726
struct gve_priv *priv = netdev_priv(netdev);
27272727
bool was_up = netif_running(priv->dev);
27282728

2729+
netif_device_detach(netdev);
2730+
27292731
rtnl_lock();
27302732
if (was_up && gve_close(priv->dev)) {
27312733
/* If the dev was up, attempt to close, if close fails, reset */

0 commit comments

Comments
 (0)