netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] vmxnet3: Fix inconsistent DMA accesses
@ 2024-11-13 19:59 Brian Johannesmeyer
  2024-11-13 20:00 ` [PATCH 1/2] vmxnet3: Fix inconsistent DMA accesses in vmxnet3_probe_device() Brian Johannesmeyer
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Brian Johannesmeyer @ 2024-11-13 19:59 UTC (permalink / raw)
  To: Ronak Doshi, Broadcom internal kernel review list, Andrew Lunn,
	David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Andy King, netdev, linux-kernel
  Cc: Brian Johannesmeyer, Raphael Isemann

Hello,

We found hundreds of inconsistent DMA accesses in the VMXNET3 driver. This
patch series aims to fix them. (For a nice summary of the rules around
accessing streaming DMA --- which, if violated, result in inconsistent
accesses --- see Figure 4a of this paper [0]).

The inconsistent accesses occur because the `adapter` object is mapped into
streaming DMA. However, when it is mapped into streaming DMA, it is then
"owned" by the device. Hence, any access to `adapter` thereafter, if not
preceded by a CPU-synchronization operation (e.g.,
`dma_sync_single_for_cpu()`), may cause unexpected hardware behaviors.

This patch series consists of two patches:
- Patch 1 adds synchronization operations into `vmxnet3_probe_device()`, to
  mitigate the inconsistent accesses when `adapter` is initialized.
However, this unfortunately does not mitigate all inconsistent accesses to
it, because `adapter` is accessed elsewhere in the driver without proper
synchronization.
- Patch 2 removes `adapter` from streaming DMA, which entirely mitigates
  the inconsistent accesses to it. It is not clear to me why `adapter` was
mapped into DMA in the first place (in [1]), because it seems that before
[1], it was not mapped into DMA. (However, I am not very familiar with the
VMXNET3 internals, so someone is welcome to correct me here). Alternatively
--- if `adapter` should indeed remain mapped in DMA --- then
synchronization operations should be added throughout the driver code (as
Patch 1 begins to do).

[0] Link: https://www.usenix.org/system/files/sec21-bai.pdf
[1] commit b0eb57cb97e7837ebb746404c2c58c6f536f23fa ("VMXNET3: Add support
for virtual IOMMU")

Brian Johannesmeyer (2):
  vmxnet3: Fix inconsistent DMA accesses in vmxnet3_probe_device()
  vmxnet3: Remove adapter from DMA region

 drivers/net/vmxnet3/vmxnet3_drv.c | 17 ++---------------
 drivers/net/vmxnet3/vmxnet3_int.h |  1 -
 2 files changed, 2 insertions(+), 16 deletions(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-11-19 17:11 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-13 19:59 [PATCH 0/2] vmxnet3: Fix inconsistent DMA accesses Brian Johannesmeyer
2024-11-13 20:00 ` [PATCH 1/2] vmxnet3: Fix inconsistent DMA accesses in vmxnet3_probe_device() Brian Johannesmeyer
2024-11-13 20:00 ` [PATCH 2/2] vmxnet3: Remove adapter from DMA region Brian Johannesmeyer
2024-11-15  3:38 ` [PATCH 0/2] vmxnet3: Fix inconsistent DMA accesses Jakub Kicinski
2024-11-18 15:31   ` Brian Johannesmeyer
2024-11-19  0:16     ` Jakub Kicinski
2024-11-19 17:10       ` Brian Johannesmeyer

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).