From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.170 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796452908; b=bG2dbvdWq1ml4FDG2UIzyEKc15dwbBzdE6bCyhPvNlCW60IiEno8TX5n9RBWqGZQcdFE cjaHwsNk3LaAWft4Tqvk8Ioe/mu8iFushmtigUvk7t+KlS5Yi7ViL81K1Vf3UIAkkSkCp ue0vzR/bpc/t3IfsAs20zHBQNfFXWEI/+Aayk2Pz5DZDxFFOV3qDeN5FurZI+Ws1jzVIY 1Jz/2Q0TvmE9cL26EdSoxlK41R4ppHn595lhbTTGCfQEmOtq5l9m9pGZ/B9pHezarNJA0 mU8T8aiFvEk9ttUkTnQ9CZjQ1S6OLP1MR8OnaFZUtyOjP9iW5XY685Ae7jsnvGkgMAw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796452908; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-Id:X-Mailer:MIME-Version: Content-Transfer-Encoding; bh=Y2CYxdTEQlIYDJ/PO+onLHyNtK6R9J7wKImp/D719+M=; b=hdZ5MbiZQ+K+awosAYh3X2isoBNIbBCGWw57enSbu5b+gdQywEipxijXLNh/lLElfCyT aEKeMlivJvuULu7KkAQN6mLz8R2FJmGV/6xRK0HSgywLyc/vIDJxSWsSYRdda0PiWIsti T30avNhlnBPRoP+tjzDbd8AWwNYHjHdk2mvl3Mt1Par5cvRKZFFPj4Htezwxe/KiaQ9ox z80Iqw/ssD+/ovMpBIcTg7uXctMLpmS3xInHDSfH+sFBf+4Xlb7GJ31f0OD3M1jy6b2Nl Oqr+H2tnGQsiwyrHpALbPPEZ+hc9aFp/zy92jCaxVLm9omM/GsM2SmhpU3cdEdJbSxQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=rm+T20FY; arc=none smtp.remote-ip=74.125.82.170 Received: from mail-dy1-f170.google.com (mail-dy1-f170.google.com [74.125.82.170]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 12CD1606A330 for ; Sat, 5 Dec 2026 06:41:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 12CD1606A330 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=rm+T20FY Received: by mail-dy1-f170.google.com with SMTP id 5a478bee46e88-3869f03af6aso2092544eec.1 for ; Fri, 04 Dec 2026 22:41:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796452907; x=1797057707; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=Y2CYxdTEQlIYDJ/PO+onLHyNtK6R9J7wKImp/D719+M=; b=rm+T20FYhhd4cWOdBQYEmbmlp4hPz2YC6I74unls1pXh7vYfTkbJYZ4/L4Tm0QjLtl lJjLqnBYq5BFuPOuBJHHSQpl5eX4OSPvyYzSTM4n3lUiCgZgOrOwSoueBRirm+psPRG5 OSlcFv/pRc9mq1EAqX0Qxo0Rnccr+6/8dGJilL59thgcdcS0/inIVq7W+6BxIReDTHPM T/uZ8zVRir6hIoskej7akoY1rAFchWs9JLL2KESht+EMEsXSWWyCznrR9Mee4/Hl8IXj wWL59XW+lBxAOq4c4XskNwA2L/h1R8d2GZ+7qTwExiEeazq+IawRBr347kGG7N2PkI1k eC8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796452907; x=1797057707; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=Y2CYxdTEQlIYDJ/PO+onLHyNtK6R9J7wKImp/D719+M=; b=cuutjUbbMZIVKhhg/3RlcLhlaKE44KBuksdM8T+ozH6r/eGmv29XeylfhXSrz59naT fI2GyntfpTNrDQRH75kMHaRfavTfMQ8IZ4W1ApRc9Recuv2OBwincoNmBx/a+6s+Rfu5 F3NhsORn05r7o92cALLkgY4aQzp88S5RI5eGI5G66uJFT799d0RMwFdKH94OfYDRvXmE q42DbzbqcCcCgQSzHbP/lKbBM5FWrHbPYRt5gWa8SWyK/2TxtTZQwtvJrzOadzhDD8nf KpQR3ehZIqtOfqK/yGHLMnB+aSGbd4imZVBnXipNs+nemdcuYVItrlh/JrzoYXiwLSW2 hpAQ== X-Forwarded-Encrypted: i=1; AL+hErGG/QuxDIscr0WjzV+peU5NHDS6sHzVfmQKtXsoKuEABZbhrsqckR+FsYfBvf6PmHIPA9FZs44=@vger.kernel.org X-Gm-Message-State: AB4q+uH8nR1benm5LMUo/80P9B39Tijata2SttkPNYtYqtnAur5WBN08 VYfxhlMAwEQZPWlEnF70nad9Qi277m3BXv76NdYLq28u0i9rSMfSjJid X-Gm-Gg: AZFdTZekeNff6t3I3sx8z1SrqOpVqcwbghUMQU9TD5pyA1olj4rmgDZ6iClM6Ey6rS+ xW+Md3+RN1ixE7IdBd1FaSJeLIYelUdH8jui91ZfRhvz5jJya4m1+EyIglP/Ylh+sF5v3IVPnQM r25Zxx7t7tOcPE0SBZGEGaPf1TePspZxsGYJg5Ws0Dr+PHCOf6j2eA6Y0QWvnq56xzEbFJ0DryL zmIWPTZVHHRj4CZBtS0e9dT0lJPIgxP2McqyOLksLSMgw6Sbs43cC2I3b0m/E7/bJHG/Ff8jnFP EFfxOssPkFxR/fScxlkIV90MD1C4ROJsu/KKxik/Zh+7Gv0qbxZCGa6q+dKuRclY4DhxOLY48aP pq/34ojumAhAOhKDtt0CKPpd0/0ATRbMY3nxuiFU9ZxzAmgTI+f3qP9o2nWE6XO7wurFVSvVkcz bTG2pSy1US7zV75tyAeYkJhxYoDp/cPGq4cSEVVZUlSuQa73wSAszLbVK+NmB2fgvi7GsbLDo57 M2p/T7koWje0XL9ylcqk9fzAZuhpB40LvXVhFXgBrDwITJnLmadTyYs7Xy5UkPL/tjxVI9WP98N dTVeF+UE1XCsZEVluqo2fMFvPElXFMsOMEPuFJj3h1WJVVimMcV1ol9PDRtYByIrGV4= X-Received: by 2002:a05:693c:820d:b0:386:ac78:a2c4 with SMTP id 5a478bee46e88-38742d8caf6mr7402295eec.17.1796452907110; Fri, 04 Dec 2026 22:41:47 -0800 (PST) Received: from localhost.localdomain (wood.seclab.cs.ucsb.edu. [128.111.49.37]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-3875207a50fsm14736951eec.1.2026.12.04.22.41.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2026 22:41:46 -0800 (PST) From: Praneeth Balasubramanian To: Vinod Koul Cc: Praneeth Balasubramanian , stable@vger.kernel.org, Frank Li , dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] dmaengine: ioatdma: fix the source count check for XOR validate via PQ Date: Fri, 4 Dec 2026 22:41:37 -0800 Message-Id: <20261205064137.2527034-1-praneethb2002@gmail.com> X-Mailer: git-send-email 2.25.1 X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- 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