[PATCH 25/30] crypto: sa2ul - fix data corruption by skipping device sync on unmap
From: Manorit Chawdhry
Date: Tue Sep 15 2026 - 06:28:54 EST
The sa_free_sa_rx_data() function is called after explicitly syncing
DMA buffers to CPU via sa_sync_from_device(). Between the sync and
unmap, the DMA completion callbacks read and modify the buffer contents
to extract results.
Without DMA_ATTR_SKIP_CPU_SYNC, dma_unmap_sgtable() performs a
device-to-CPU cache sync, which invalidates the CPU cache and
overwrites the CPU's modifications with stale device data. This
causes data corruption where processed results are lost.
Add DMA_ATTR_SKIP_CPU_SYNC to keep the buffer in CPU domain after
the explicit sync, preventing the unmap operation from corrupting
the modified data.
Fixes: 00c9211f60db ("crypto: sa2ul - Fix DMA mapping API usage")
Assisted-by: Sisyphus:claude-sonnet-4-6
Signed-off-by: Manorit Chawdhry <m-chawdhry@xxxxxx>
---
drivers/crypto/sa2ul.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/crypto/sa2ul.c b/drivers/crypto/sa2ul.c
index cd5cd9182bdb..5e0ef12eb02b 100644
--- a/drivers/crypto/sa2ul.c
+++ b/drivers/crypto/sa2ul.c
@@ -1059,7 +1059,7 @@ static void sa_free_sa_rx_data(struct sa_rx_data *rxd)
if (mapped_sg->mapped) {
dma_unmap_sgtable(rxd->ddev, &mapped_sg->sgt,
- mapped_sg->dir, 0);
+ mapped_sg->dir, DMA_ATTR_SKIP_CPU_SYNC);
kfree(mapped_sg->split_sg);
}
}
--
2.43.0