From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.169 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796452908; b=E4n9QH/Y9DOBmvcLZ9eLmDup1NAeUzdUUWRfe09CQU9izBTNhpy2GmKaf/sAC2gC7jvd lGPoaY+5D0QOnyBIFDWoPD6nWdjwGhytWgk8S+TliH+nNaw2crKbrAV99h5AfFmwJJ1Jh Rs3Q2yiogILKVgu8xaXGY0SDHhgrhP474gJPaU0Zj9OjCyz8Nbq7H/TfggqokjaDJ6zZ8 1s2HAGQgj+sfZLItR0tjgttrUwWSzSccdWrdag1FG7LauHQfuPge0kKHs4fl5QXdoQuwH gkhRPkbiaJMPTNpueH1wNr5SzZzKGbx+CgEo022sN+9gznfp3fYasXAh9fOB4zFV6bA== 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=pUQpc3/+90hOlq2Mi2D9fyOA8LcAZ0agNKrZ9ARht09u/0rcnH+d4KL5aUGG6a12663k j2HDbboEyswmGiq0nJhO+FNJyRy1t+Bn2ObaIQ+hsEdTFKs0Djrq9frad37dCEjkOFvRV iz8FTLU530/QQHkx6DRT1uPxjWOOVhjRXPY+BOKF6Wlcg7fx6lNVgQrb1bFlCX5FWU0s+ dLuuK8F5ZdJYOzQkmUuzRDn5ooEOGzcCypa99nuBni//C3IdPeaqgKx7b77qn3vwX6yJf C/BwCv+sCDCAU/KoY0jwRIL4IRY/MRWmuhSfdf4mN4uwFL0RDejdKWWqyNxdo5A2h4A== 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.169 Received: from mail-dy1-f169.google.com (mail-dy1-f169.google.com [74.125.82.169]) (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 EC6C8606A322 for ; Sat, 5 Dec 2026 06:41:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org EC6C8606A322 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-f169.google.com with SMTP id 5a478bee46e88-3869f03af6aso2092542eec.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=FhY3WpYD1twZBbVZD1Gjpyozh3XU3++LewJ270laCf41EiUCu7pX/Uaip3Egg6A0Zn iUmw1KlBIIHxHwYHEITmd71wxOelDMZL9bXf+JfA1U/o1qhHXytl0rT0CX4xjgOKsnIY z7wv0oNqP4Br14komi/g0231Gq7vo1Z9v0Oau6ICzeAp0Hw6fdHK546gmWt3TryuwcBK bqqE3kUyc0koXKjgm/a9Sy/e8172PT1rrKUr9tpGIZJjQY25x930MTrJdAXhNUAZjUR0 JdFyQ0DkckIiQRr16WgV/o/y7WygEOsc/sYg+YkxUIcJvpAJJVb06CynNUIe5UB9Z1J4 9Jnw== X-Forwarded-Encrypted: i=1; AL+hErFObatWuIHADjccdcAIZgnTm1F/VKuUoVLdTkFD6BTjRO1mgWFTCqYre+PKoGU0cjooNaKZD2rBF7Q=@vger.kernel.org X-Gm-Message-State: AB4q+uEmEWnP1KK0AQE4p93P4obkex3OHkO5sOrwnv2Ak6pv44HLu0Jo /O0ZUhEIwlbfFgtHvCkzouCLPBLCMdol90TehfH10zmfVTAhe84QzWYp X-Gm-Gg: AZFdTZdreHqJzQLTN8Mna03tjcXm2G9quIZnw+2jWLWMWKFbDfZse7VM5edPOdfzZ2b nm8QL8eHHWXlMSQEfxCI6jCohsFtWkuWwG8ugl+5JpnbcfuWNv4oCriOwoeGCXI+WWQHlC7Khwg +I6Y6X0mVEHyZfhX9QWmf5x/TLtL/HsV+ZmnqvNLQOjVZgu0H5+dXf3wrpGDQg7j3gY/F7UeoOx sQPDvn3tzPzNAe/LBp19Vdz6CceA7OtcIPa8nCRy/B9XlFdvImeITEBPNyxjvbacNFMHCZ7AfTc 0lkVRzhlIe4tmswgF36zj8wcgWzh3bwvaVGbG27/EHFa2L7k0Jo8lS6QNauPl0M8c9Ote6Pec9f rM54+gncHvy3+WzyF2n6XfkRMKkgxjsehINvxbSGIqiauRYklVUe7yxUqpeus17PF1lUql46TL+ z6cBEufaYJaHN+9Qin2Bh7WT6ZyTnDDL/91VZdLnCu/+lGOu8NnxlV2uvzSDGTPwgeFL1fnZks0 HgYZS6OkVtwmYC+SKc6KVDlMU6TdOiEjMayy+pCKTEDxR3M1fshLM7XVuiXkXAL1rtTz0oRXf2F 3LA3tWsu7pqsmi2QXnrhlJ2fsPZN//kseLWPpfegnY8rkRbYVD/cfcFOOT/7KlPZjh0= 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: dmaengine@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