Skip to content

dmaengine: idma64: descriptor allocation and length limit fixes

Rosen Penev dmaengine linux-hardening lkml sashiko-reviews 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest2 patches 3 repliesIn review
  2. v11 patch 0 repliesSuperseded

Changes in v2 from the cover letter

- (fill in changes here)

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2dmaengine: idma64: use kzalloc_flexdrivers/dma/idma64.c drivers/dma/idma64.h+6 -282 replies
2/2dmaengine: idma64: use sg_nents_for_dma to respect hardware descriptor length limitdrivers/dma/idma64.c drivers/dma/idma64.h+32 -151 reply

Reviews trailers per patch

1 of 2 patches has a Reviewed-by or Acked-by.

PatchFrank Li
1/2R-b
2/2

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCHv2 0/2] dmaengine: idma64: descriptor allocation and length limit fixes

This small series cleans up the idma64 descriptor allocation and fixes a long-standing truncation bug in idma64_prep_slave_sg().

Patch 1 replaces the open-coded two-stage allocation in idma64_alloc_desc() with kzalloc_flex() using a flexible array member for the hardware descriptor list, annotated with __counted_by for extra runtime bounds checking. The now-redundant helper is removed.

Patch 2 addresses the hardware limit. The iDMA 64-bit CTL_HI BLOCK_TS field is only 17 bits (IDMA64C_CTLH_BLOCK_TS_MASK = 0x1ffff), so when a scatterlist entry exceeds that size the driver would silently truncate the transfer length. Use sg_nents_for_dma() to size the descriptor ring after splitting oversized entries, and iterate the new per-chunk loop so each hardware descriptor stays within the field.

Rosen Penev (2):

Rosen Penev (2):
dmaengine: idma64: use kzalloc_flex
dmaengine: idma64: use sg_nents_for_dma to respect hardware descriptor
length limit

v2: add second patch

 drivers/dma/idma64.c | 70 ++++++++++++++++++++------------------------
 drivers/dma/idma64.h |  7 +++--
 2 files changed, 36 insertions(+), 41 deletions(-)

Changes since v1:
- (fill in changes here)

Signature · 1 line
2.55.0