diff options
| author | Weibin Liu <liuwb@xiaopeng.com> | 2026-10-14 20:39:13 +0800 |
|---|---|---|
| committer | Mark Brown <broonie@kernel.org> | 2026-10-15 23:24:51 +0100 |
| commit | e2f4edfc061e493fddde16c4bbe1c4f230f41e4a (patch) | |
| tree | 51b00ae8bdc3bc685a2d28fe05796a1d76cca938 /tools/perf/scripts/python/bin | |
| parent | f8334fdfd858c27f090ce597806794e4a08c9f4f (diff) | |
spi: amd: fix len==0 underflow and FIFO overflow
amd_spi_fifo_xfer() unconditionally decrements xfer->len when a tx_buf
is present. The SPI core does not reject zero-length transfers, so a
transfer submitted through the SPI_IOC_MESSAGE ioctl with len == 0 and
a tx_buf makes the u32 len wrap to 0xFFFFFFFF, and the following
per-byte loop writes far past the FIFO window.
The driver also never checks the cumulative FIFO offset against
AMD_SPI_FIFO_SIZE. The core splits each transfer down to the
controller's max transfer size but does not bound the total message
length, so a message of several transfers whose total exceeds the FIFO
overflows it with out-of-bounds MMIO writes (tx) and reads (rx).
Skip zero-length transfers and reject any transfer that would run past
the end of the FIFO window.
Tested with a user-space replica of the fifo_xfer length arithmetic
(ASAN build): a zero-length transfer with tx_buf makes len-- wrap to
0xffffffff, and skipping zero-length transfers avoids the wrap. No AMD
SPI hardware was available, so the FIFO bound check was verified by
inspection against AMD_SPI_FIFO_SIZE.
Fixes: bbb336f39efc ("spi: spi-amd: Add AMD SPI controller driver support")
Cc: stable@vger.kernel.org # 5.8+
Reviewed-by: Guanglei Zhu <zhugl3@xiaopeng.com>
Signed-off-by: Weibin Liu <liuwb@xiaopeng.com>
Link: https://patch.msgid.link/20261014-spi-amd-fifo-fix-v1-1-9fec9ab753e8@xiaopeng.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'tools/perf/scripts/python/bin')
0 files changed, 0 insertions, 0 deletions
