mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
i3c: mipi-i3c-hci: Bounce short reads irrespective of the IOMMU
The controller writes whole DWORDs, so a read whose length is not a
multiple of 4 overwrites up to 3 bytes past the end of the destination
buffer. That is a property of the controller, not of the IOMMU, but the
bounce buffer that works around it was used only when the device was
IOMMU mapped. Everywhere else the buffer is left unprotected.
Drop the device_iommu_mapped() condition.
The overrun is easily seen with CONFIG_SLUB_DEBUG=y and kernel command
line options intel_iommu=off slub_debug=FZPU, which reports it as a
kmalloc redzone overwrite, like:
[kmalloc Redzone overwritten] 0xffff8a354561570e-0xffff8a354561570f @offset=1806. First byte 0x15 instead of 0xcc
=============================================================================
BUG kmalloc-8 (Not tainted): Object corrupt
Allocated in i3c_master_retrieve_dev_info+0xc1/0x760 age=40 cpu=6 pid=1
...
Freed in i3c_master_enec_disec_locked+0xeb/0x140 age=40 cpu=6 pid=1
...
WARNING: mm/slub.c:1233 at object_err+0x1c1/0x1cf, CPU#6: swapper/0/1
...
Fixes: 9e23897bca ("i3c: mipi-i3c-hci: Use physical device pointer with DMA API")
Cc: stable@vger.kernel.org
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Link: https://patch.msgid.link/20260920151248.46936-3-adrian.hunter@intel.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
This commit is contained in:
parent
35b028b254
commit
b1a25e8e14
|
|
@ -428,7 +428,7 @@ static void hci_dma_unmap_xfer(struct i3c_hci *hci,
|
|||
static struct i3c_dma *hci_dma_map_xfer(struct device *dev, struct hci_xfer *xfer)
|
||||
{
|
||||
enum dma_data_direction dir = xfer->rnw ? DMA_FROM_DEVICE : DMA_TO_DEVICE;
|
||||
bool need_bounce = device_iommu_mapped(dev) && xfer->rnw && (xfer->data_len & 3);
|
||||
bool need_bounce = xfer->rnw && (xfer->data_len & 3);
|
||||
|
||||
return i3c_master_dma_map_single(dev, xfer->data, xfer->data_len, need_bounce, dir);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user