Skip to content

spi: cadence-xspi: two memory-safety fixes in the slave-DMA paths

Weibin Liu linux-spi lkml stable 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 1 replyIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2spi: cadence-xspi: reject SDMA transfers larger than the requested lengthdrivers/spi/spi-cadence-xspi.c+31 -50 replies
2/2spi: cadence-xspi: fix stack buffer overflow in the Marvell b0 pathdrivers/spi/spi-cadence-xspi.c+11 -50 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/2] spi: cadence-xspi: two memory-safety fixes in the slave-DMA paths

While reviewing the slave-DMA handling of the Cadence XSPI driver I found two ways in which memory the SPI core handed to the driver can be overrun:

1/2 both SDMA handlers copy the byte count reported by SDMA_SIZE_REG
without checking it against the requested transfer length; a device reporting more bytes than were programmed makes the handlers walk past the end of the transfer buffers

2/2 the Marvell b0 transfer path points the SDMA buffers at a
10-byte stack scratch area for transfers without TX data; transfers longer than that overflow it in both directions and clock out uninitialized stack bytes to the attached device

The two patches are independent of each other and each carries its own
Fixes: tag, so they can be queued separately.

Tested on x86_64: with both patches applied the driver builds, loads and unloads cleanly; no xSPI controller is available in this environment to exercise the slave-DMA paths on hardware. Details are in the notes of the individual patches.

---
Weibin Liu (2):
spi: cadence-xspi: reject SDMA transfers larger than the requested
length
spi: cadence-xspi: fix stack buffer overflow in the Marvell b0 path

 drivers/spi/spi-cadence-xspi.c | 52 +++++++++++++++++++++++++++-------
 1 file changed, 42 insertions(+), 10 deletions(-)
Signature · 1 line
2.50.1