Skip to contentSkip to conversation

vmxnet3: remove adapter from device accessible structures

RFC PATCH syzbot 1 participant 1 message Sep 28

Subsystems (2)
lore
Share & tools
lore

syzbot

author syzbot
#0 lore raw

In vmxnet3_probe_device(), the driver allocates struct net_device and its private data (struct vmxnet3_adapter) via alloc_etherdev_mq(). Internally, alloc_netdev_mqs() uses kvzalloc_flex() to allocate the netdev along with its private data. The size of struct vmxnet3_adapter has grown to approximately 46 KB, requiring an order-4 page allocation. Under memory pressure or fragmentation, contiguous kmalloc allocation can fail and kvzalloc_flex() falls back to a vmalloc() allocation.

Later in vmxnet3_probe_device(), the driver attempts to map the adapter for DMA with dma_map_single(). Because dma_map_single() requires physically contiguous memory, passing a vmalloc address triggers dev_WARN_ONCE in dma_map_single_attrs() and returns DMA_MAPPING_ERROR, causing device probe to fail with -EFAULT:

vmxnet3 0000:00:00.0: rejecting DMA map of vmalloc memory

WARNING: include/linux/dma-mapping.h:532 at
vmxnet3_probe_device+0xab8/0x2e70 drivers/net/vmxnet3/vmxnet3_drv.c:4047
RIP: 0010:vmxnet3_probe_device+0xb32/0x2e70
drivers/net/vmxnet3/vmxnet3_drv.c:4047
Call Trace:
 <TASK>
 pci_device_probe+0x48e/0xd10 drivers/pci/pci-driver.c:512
 really_probe+0x254/0xae0 drivers/base/dd.c:706
 __driver_probe_device+0x1e8/0x360 drivers/base/dd.c:868
 device_driver_attach+0xe0/0x1d0 drivers/base/dd.c:1203
 bind_store+0x1d0/0x220 drivers/base/bus.c:267
 kernfs_fop_write_iter+0x3a4/0x540 fs/kernfs/file.c:345
 vfs_write+0x612/0xba0 fs/read_write.c:687
 ksys_write+0x150/0x270 fs/read_write.c:739
 do_syscall_64+0x166/0x520 arch/x86/entry/syscall_64.c:84
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
 </TASK>

The mapped address was only used to populate devRead->misc.ddPA and devRead->misc.ddLen in vmxnet3_setup_driver_shared() to expose driver-private data to the hypervisor, but the device does not rely on them for normal operation. A similar cleanup was done in commit de1da8bcf405 ("vmxnet3: Remove buf_info from device accessible structures") for TX and RX queue descriptors, where ddPA was set to ~0ULL and ddLen to 0. Additionally, exposing guest driver state to the hypervisor is undesirable in confidential computing environments.

Fix this by eliminating the DMA mapping and unmapping of struct vmxnet3_adapter during probe and removal, setting devRead->misc.ddPA to ~0ULL and ddLen to 0 in vmxnet3_setup_driver_shared(), and removing the unused adapter_pa field from struct vmxnet3_adapter.

Fixes b0eb57cb97e7 ("VMXNET3: Add support for virtual IOMMU")
Assisted-by Gemini:gemini-3.8-flash Gemini:gemini-3.1-pro-preview syzbot
Reported-by [email protected]

To: "Andrew Lunn" <[email protected]>
To: "David S. Miller" <[email protected]>
To: "Eric Dumazet" <[email protected]>
To: "Jakub Kicinski" <[email protected]>
To: <[email protected]>
To: "Paolo Abeni" <[email protected]>
To: "Ronak Doshi" <[email protected]>
To: "Andy King" <[email protected]>
Cc: "Broadcom internal kernel review list" <[email protected]>
Cc: <[email protected]>

---

drivers/net/vmxnet3/vmxnet3_drv.c +2 -14
index f8df83f99..81f74bc67 100644
@@ -2921,8 +2921,8 @@ vmxnet3_setup_driver_shared(struct vmxnet3_adapter *adapter)
 	devRead->misc.driverInfo.vmxnet3RevSpt = cpu_to_le32(1);
 	devRead->misc.driverInfo.uptVerSpt = cpu_to_le32(1);
 
-	devRead->misc.ddPA = cpu_to_le64(adapter->adapter_pa);
-	devRead->misc.ddLen = cpu_to_le32(sizeof(struct vmxnet3_adapter));
+	devRead->misc.ddPA = cpu_to_le64(~0ULL);
+	devRead->misc.ddLen = cpu_to_le32(0);
 
 	/* set up feature flags */
 	if (adapter->netdev->features & NETIF_F_RXCSUM)
@@ -4044,14 +4044,6 @@ vmxnet3_probe_device(struct pci_dev *pdev,
 	}
 
 	spin_lock_init(&adapter->cmd_lock);
-	adapter->adapter_pa = dma_map_single(&adapter->pdev->dev, adapter,
-					     sizeof(struct vmxnet3_adapter),
-					     DMA_TO_DEVICE);
-	if (dma_mapping_error(&adapter->pdev->dev, adapter->adapter_pa)) {
-		dev_err(&pdev->dev, "Failed to map dma\n");
-		err = -EFAULT;
-		goto err_set_mask;
-	}
 	adapter->shared = dma_alloc_coherent(
 				&adapter->pdev->dev,
 				sizeof(struct Vmxnet3_DriverShared),
@@ -4313,8 +4305,6 @@ vmxnet3_probe_device(struct pci_dev *pdev,
 			  sizeof(struct Vmxnet3_DriverShared),
 			  adapter->shared, adapter->shared_pa);
 err_alloc_shared:
-	dma_unmap_single(&adapter->pdev->dev, adapter->adapter_pa,
-			 sizeof(struct vmxnet3_adapter), DMA_TO_DEVICE);
 err_set_mask:
 	free_netdev(netdev);
 	return err;
@@ -4381,8 +4371,6 @@ vmxnet3_remove_device(struct pci_dev *pdev)
 	dma_free_coherent(&adapter->pdev->dev,
 			  sizeof(struct Vmxnet3_DriverShared),
 			  adapter->shared, adapter->shared_pa);
-	dma_unmap_single(&adapter->pdev->dev, adapter->adapter_pa,
-			 sizeof(struct vmxnet3_adapter), DMA_TO_DEVICE);
 	free_netdev(netdev);
 }
 
drivers/net/vmxnet3/vmxnet3_int.h +0 -1
index 9f24d66db..2c2a446a8 100644
@@ -438,7 +438,6 @@ struct vmxnet3_adapter {
 	struct Vmxnet3_CoalesceScheme *coal_conf;
 	bool   default_coal_mode;
 
-	dma_addr_t adapter_pa;
 	dma_addr_t pm_conf_pa;
 	dma_addr_t rss_conf_pa;
 	bool   queuesExtEnabled;

base-commit: 72d3fcf802c45d00b300f25b848a93c3a2bd7c7e

Signature · 9 lines
This is an AI-generated patch subject to moderation.
Reply with '#syz upstream' to Sign-off the patch as a human author
and send it to the upstream kernel mailing lists.
Reply with '#syz reject' to reject it ('#syz unreject' to undo).

See https://goo.gle/syzbot-ai-patches for information about AI-generated patches.
You can comment on the patch as usual, syzbot will try to address
the comments and send a new version of the patch if necessary.
syzbot engineers can be reached at [email protected].