From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.171 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796452908; b=164+ZkaNJ1LzPQuCL+zveU9C1wpc+s9TIHWLr/7lRk4RGwP74E7X07hXOzUD32E02bSO yVGn8Pn1ftMISzcVtpZM/tkwYVrp0EUVcGwxMWViWoyVR16IhVhz/XkAX3wAQ6EdGBget g7wBfyqThNMtuvQx61Q3eAsovJe6aVtd492TL7k9LWGvVx0DKpAxDZCp2G4Ioju5MVJHz c2cAHfCoHqvL759NGM7bdU3UwynIMAQR31fA1gk996OHlT/t/R/1wOg7eM2Y3xrAedF6H NKmtnzdJEhGB4/l3aETKhkw4mkDTLeACzyEBZ/avq4hC2GzuBCEaEBPlhxjuYXsUjVQ== 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=iUq87W/Pg56E1p1+mMX+/jy2dnxnxGxgcG3+C1yMD6MFbaXzvgF0JqpCm4JPrXwsZtmt Tt5SczusMftf5nffxy+CN1zuBhZ8kPNOSaCTSP/orlCjSVfS+R1vH4lLansuBNFRTqVHn E0gcaoXFM0mC9gKNX0aFNPonab8cXt2+kLXKWZW2AVRz1gbErN3sMDXJGnp1Yc5DeF9bF e8BW0uCIzzFaMHiIoaVz4lmkXtvsKxuSEbkPg8Od1PxHjhy8Mk1Kf+BmydD/+G4I6SCNt R/SPSjis7gGNlLxWMSZc2faRitL6RYzT6KEbLHwz/TbcLlyG4/gNK+e+PGMWpQM2d1Q== 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.171 Received: from mail-dy1-f171.google.com (mail-dy1-f171.google.com [74.125.82.171]) (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 EE365606A32F for ; Sat, 5 Dec 2026 06:41:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org EE365606A32F 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-f171.google.com with SMTP id 5a478bee46e88-3869f03af6aso2092543eec.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=AoRL+LTePGjaHECSa2Ihm2e07ozaYpoInWmlKt7yWscwiP17Qe1+D1IeAt++veNppm ty49mk3kWAuNM8EhNy1EKge50hrrTDo213Gd06lJbY2ewu0vEcyZ8wsDLUmJlHx8Eyu/ wej9EuWtlpP8dZl42mIch59h0np17PuLCiMvMbBgoxvW2QegdslRyYKEDIWnDEcOp1cw Q94eBSsu5jc2EoxFCYpGiDKrPM94qVHV4ggs/PBZPT9iWkhpMLHxDCS9YAFMnUW/hm33 NenSKBzPxlVuqdQp7lIfoQ5T5pAfvSZujhAKUYUied0HJfvTVIlwFM2UmwfVgdhuXEtI C2iQ== X-Forwarded-Encrypted: i=1; AL+hErFph1iPOb/5qWGm8D5jSzUaIrK63cFyF/5h1OsIz2eNdcr6SHqXWuid9RgIzj5sKynMwR7OjFVY4s8U6mU=@vger.kernel.org X-Gm-Message-State: AB4q+uHeE8BHAcZ2Zi6kruxCwsurCiOIoL35fX+cIuVImu5WdBeYN2m5 kLmWyLbGjYStNFcaMl6xSbkDVVysKBk/7Tf7SmDBRVQfwM12YJkkaFpP X-Gm-Gg: AZFdTZcUkT2w8L8xDmUHYwDtHNVPn1/Y+i4KfRPayJaFm7f6BNv+JI4ZQWeiOz0ylsX tzk0Wz+DODwhS4RwgaUnJrqRVKBS7NZpr042pGbWoF1fM/Q90ydKkpc7UzEujs7UvguVzTIwavq HFIUzWwgfqEoFd4PAKRxg9mV4LvNXDRShHf0nrnXgTzu3n6dHQMalxywsuIdWIAFyMBvcdnGUfi +f3VseaExID7lCBHtTLS538qo8vEG9KrnDmd0+8sqKXGKsYPOXQNXossNBbuBZPvHkmBgi5Ol2S jRLsJY0ONcVUYV/Q06UmKSpoKoToxb2G0khr4ksQJ186Fdvy4n6nIHDVcMlWT3u0YYy7cZeGeho 5cCSmIuN84RUcCMR95TEFkBz/ixUgd5j8iHPzadR8Tl8YEH6m0VoSUMFbxpUMNLXKd5NYVV6E/h lUYtSQJbGMSIf8GQE8ybsEYS/H2o5z0VJdD7GDu//ZR5gZV8yGrrzxQZ9vLNpq31elxg5ugPOtS S76W8wheZjhwY/6QA7gD1lCZOjnHLEJDaeJPnRRdoDHlt9Yz5iRl0GkVcgBsj3cMf7kZtsDtp24 FSXRK3hGMNS9MHtyASYHHR0G3z2AOWcGAdGcO3Jvn+qITIDdV4oMpMKWIfqo+M+kqUQ= 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: linux-kernel@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