linux/Documentation/core-api
Halil Pasic aa6f8dcbab swiotlb: rework "fix info leak with DMA_FROM_DEVICE"
Unfortunately, we ended up merging an old version of the patch "fix info
leak with DMA_FROM_DEVICE" instead of merging the latest one. Christoph
(the swiotlb maintainer), he asked me to create an incremental fix
(after I have pointed this out the mix up, and asked him for guidance).
So here we go.

The main differences between what we got and what was agreed are:
* swiotlb_sync_single_for_device is also required to do an extra bounce
* We decided not to introduce DMA_ATTR_OVERWRITE until we have exploiters
* The implantation of DMA_ATTR_OVERWRITE is flawed: DMA_ATTR_OVERWRITE
  must take precedence over DMA_ATTR_SKIP_CPU_SYNC

Thus this patch removes DMA_ATTR_OVERWRITE, and makes
swiotlb_sync_single_for_device() bounce unconditionally (that is, also
when dir == DMA_TO_DEVICE) in order do avoid synchronising back stale
data from the swiotlb buffer.

Let me note, that if the size used with dma_sync_* API is less than the
size used with dma_[un]map_*, under certain circumstances we may still
end up with swiotlb not being transparent. In that sense, this is no
perfect fix either.

To get this bullet proof, we would have to bounce the entire
mapping/bounce buffer. For that we would have to figure out the starting
address, and the size of the mapping in
swiotlb_sync_single_for_device(). While this does seem possible, there
seems to be no firm consensus on how things are supposed to work.

Signed-off-by: Halil Pasic <pasic@linux.ibm.com>
Fixes: ddbd89deb7 ("swiotlb: fix info leak with DMA_FROM_DEVICE")
Cc: stable@vger.kernel.org
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2022-03-07 11:26:02 -08:00
..
irq irq: remove handle_domain_{irq,nmi}() 2021-10-26 10:13:31 +01:00
assoc_array.rst Documentation: Use "while" instead of "whilst" 2018-11-20 09:30:43 -07:00
boot-time-mm.rst docs/boot-time-mm: remove bootmem documentation 2018-10-31 08:54:16 -07:00
bus-virt-phys-mapping.rst docs: core-api: avoid using ReST :doc:foo markup 2021-06-17 13:24:37 -06:00
cachetlb.rst mm: Add flush_dcache_folio() 2021-10-18 07:49:36 -04:00
circular-buffers.rst doc: Remove ".vnet" from paulmck email addresses 2019-05-28 09:02:57 -07:00
cpu_hotplug.rst Documentation: core-api/cpuhotplug: Rewrite the API section 2021-09-11 00:41:21 +02:00
debug-objects.rst doc: debugobjects: actually pull in the kerneldoc comments 2016-11-29 14:44:14 -07:00
debugging-via-ohci1394.rst docs: debugging-via-ohci1394.txt: add it to the core-api book 2020-05-15 11:59:17 -06:00
dma-api-howto.rst docs: move DMA kAPI to Documentation/core-api 2020-05-15 11:51:54 -06:00
dma-api.rst docs: core-api: avoid using ReST :doc:foo markup 2021-06-17 13:24:37 -06:00
dma-attributes.rst swiotlb: rework "fix info leak with DMA_FROM_DEVICE" 2022-03-07 11:26:02 -08:00
dma-isa-lpc.rst docs: core-api: avoid using ReST :doc:foo markup 2021-06-17 13:24:37 -06:00
errseq.rst errseq: Add to documentation tree 2018-01-01 12:40:27 -07:00
genalloc.rst lib/genalloc.c: rename addr_in_gen_pool to gen_pool_has_addr 2019-12-04 19:44:13 -08:00
generic-radix-tree.rst generic radix trees 2019-03-12 10:04:02 -07:00
genericirq.rst docs: genericirq.rst: don't document chip.c functions twice 2020-10-15 07:49:41 +02:00
gfp_mask-from-fs-io.rst docs: core-api/gfp_mask-from-fs-io: add a label for cross-referencing 2018-09-20 11:02:32 -06:00
idr.rst Core-api: Documentation: Replace deprecated :c:func: Usage 2020-08-11 10:26:08 -06:00
index.rst docs: core-api: avoid using ReST :doc:foo markup 2021-06-17 13:24:37 -06:00
kernel-api.rst Convert xfs/iomap to use folios 2022-01-12 12:51:41 -08:00
kobject.rst kobject documentation: remove default_attrs information 2022-01-07 11:23:37 +01:00
kref.rst docs: move the kref doc into the core-api book 2020-05-15 12:02:19 -06:00
librs.rst docs-rst: convert librs book to ReST 2017-05-16 08:44:16 -03:00
local_ops.rst timer: Remove init_timer() interface 2017-11-21 15:57:09 -08:00
memory-allocation.rst mm: slab: provide krealloc_array() 2020-12-15 12:13:37 -08:00
memory-hotplug.rst mm/memory_hotplug: remove HIGHMEM leftovers 2021-11-06 13:30:42 -07:00
mm-api.rst mm/util: Add folio_mapping() and folio_file_mapping() 2021-09-27 09:27:30 -04:00
packing.rst docs: packing: move it to core-api book and adjust markups 2019-07-31 13:30:01 -06:00
padata.rst padata: fold padata_alloc_possible() into padata_alloc() 2020-07-23 17:34:18 +10:00
pin_user_pages.rst selftests/vm: only some gup_test items are really benchmarks 2020-12-15 12:13:38 -08:00
printk-basics.rst printk: Move the printk() kerneldoc comment to its new home 2021-07-26 12:36:44 +02:00
printk-formats.rst vsprintf: Update %pGp documentation about that it prints hex value 2021-11-01 15:55:06 +01:00
protection-keys.rst x86/Kconfig: Update config and kernel doc for MPK feature on AMD 2020-05-28 18:27:40 +02:00
rbtree.rst docs: rbtree.rst: Fix a typo 2021-03-25 11:38:51 -06:00
refcount-vs-atomic.rst docs: remove :c:func: from refcount-vs-atomic.rst 2019-10-07 09:08:56 -06:00
symbol-namespaces.rst docs/core-api: Consistent code style 2021-05-03 16:52:50 -06:00
this_cpu_ops.rst docs: move other kAPI documents to core-api 2020-06-26 11:33:42 -06:00
timekeeping.rst docs: timekeeping: Use correct prototype for deprecated functions 2020-04-15 14:48:26 -06:00
tracepoint.rst doc: Sphinxify the tracepoint docbook 2016-11-29 14:44:23 -07:00
unaligned-memory-access.rst docs: move other kAPI documents to core-api 2020-06-26 11:33:42 -06:00
workqueue.rst workqueue: doc: Call out the non-reentrance conditions 2021-10-25 07:18:40 -10:00
xarray.rst XArray: add xas_split 2020-10-16 11:11:15 -07:00