* [PATCH] dmaengine: ioatdma: fix the source count check for XOR validate via PQ
@ 2026-12-05 6:41 Praneeth Balasubramanian
0 siblings, 0 replies; only message in thread
From: Praneeth Balasubramanian @ 2026-12-05 6:41 UTC (permalink / raw)
To: Vinod Koul
Cc: Praneeth Balasubramanian, stable, Frank Li, dmaengine,
linux-kernel
When the channel has PQ but no XOR, XOR validation is done with a PQ
validate descriptor. ioat_prep_pqxor_val() passes src[0] as the P
result and the other src_cnt - 1 buffers as sources. But it picks
the 16-source helper by looking at src_cnt, not src_cnt - 1.
So a 9-source XOR validation reaches __ioat_prep_pq16_lock() with 8
sources. That function only handles 9 to 16 sources. It allocates the
smallest super extended descriptor for 8 sources, and
src16_cnt_to_hw(8) wraps to 7 in the 3-bit field, which means 16
sources to the hardware. The engine then reads source entries from
memory past the allocated descriptor.
Choose the helper by the number of sources that are passed on, as
ioat_prep_pqxor() and ioat_prep_pq() do. An 8-source validation then
uses __ioat_prep_pq_lock(), which handles up to 8.
Only hardware with RAID16SS and PQ but without XOR uses this path.
This was found by an LLM-based audit that checks code against the rules
stated in kernel comments.
Fixes: 7727eaa4490b ("ioatdma: Adding support for 16 src PQ ops and super extended descriptors")
Cc: stable@vger.kernel.org
Signed-off-by: Praneeth Balasubramanian <praneethb2002@gmail.com>
---
Notes:
This was found by an LLM-based audit, part of research at UCSB SecLab.
An LLM turned a kernel comment into a rule, and three LLM votes checked
the code against it. The fix and changelog were drafted with GLM-5.3,
then checked against the source and partly rewritten with Claude Opus
5.5. I reviewed the patch and take responsibility for it.
Testing: builds without new warnings with W=1 (x86_64 allmodconfig),
clang 23. checkpatch.pl is clean. Not runtime-tested, and there is no
reproducer. I do not have this hardware.
drivers/dma/ioat/prep.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/dma/ioat/prep.c b/drivers/dma/ioat/prep.c
index 033d9f2b3e2a..0a255f28d903 100644
--- a/drivers/dma/ioat/prep.c
+++ b/drivers/dma/ioat/prep.c
@@ -694,7 +694,8 @@ ioat_prep_pqxor_val(struct dma_chan *chan, dma_addr_t *src,
flags |= DMA_PREP_PQ_DISABLE_Q;
pq[1] = pq[0]; /* specify valid address for disabled result */
- return src_cnt_flags(src_cnt, flags) > 8 ?
+ /* src[0] is the destination, so src_cnt - 1 sources are passed on */
+ return src_cnt_flags(src_cnt - 1, flags) > 8 ?
__ioat_prep_pq16_lock(chan, result, pq, &src[1], src_cnt - 1,
scf, len, flags) :
__ioat_prep_pq_lock(chan, result, pq, &src[1], src_cnt - 1,
base-commit: 29beb21c21ada7207692b2d69fc58dcd15dab6e9
--
2.25.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-12-05 6:41 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-05 6:41 [PATCH] dmaengine: ioatdma: fix the source count check for XOR validate via PQ Praneeth Balasubramanian
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox