Re: [PATCH V2 02/17] i3c: mipi-i3c-hci: Bounce short reads irrespective of the IOMMU
From: Frank Li
Date: Thu Sep 17 2026 - 20:09:03 EST
On Thu, Sep 17, 2026 at 10:13:41PM +0300, Adrian Hunter wrote:
> 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: 9e23897bca62 ("i3c: mipi-i3c-hci: Use physical device pointer with DMA API")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Adrian Hunter <adrian.hunter@xxxxxxxxx>
> ---
Reviewed-by: Frank Li <Frank.Li@xxxxxxx>
>
>
> Changes in V2:
>
> Added the slub_debug report to the commit message.
>
>
> drivers/i3c/master/mipi-i3c-hci/dma.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/i3c/master/mipi-i3c-hci/dma.c b/drivers/i3c/master/mipi-i3c-hci/dma.c
> index 7c2b20474130..5b195978f376 100644
> --- a/drivers/i3c/master/mipi-i3c-hci/dma.c
> +++ b/drivers/i3c/master/mipi-i3c-hci/dma.c
> @@ -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);
> }
> --
> 2.53.0
>