Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 92A4F3C73F6; Sat, 17 Oct 2026 17:45:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1792259134; cv=none; b=ePcABTuQGv02NJH0mserRL+k0Rhkmdz/OCizQxyqp2VRZ32rmrOEt50Q7fnOFZyrvjk3nEs9xxddcH20/hus86oWy/WfjX6bskNOqu15V7QF97uYJDvQ5QcWui51UyBC2T/pz55KoCU9wDPtlGFtbNeQ2UysopYRCoMZp1rwZ0E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1792259134; c=relaxed/simple; bh=eRycoCI3GXK5kNtHpqF87LwlTCXeabZ5yU0QsdyZW4E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=NFkh8HpKuGfocd+pN1Gcoalu1F0RIaLsneyaVQA/DfCpPQiEXzKcg4OLBkWBWrzwonWDpyA/ryRBfw9YObltzhTfaZnmCQ0aGTgY8nIyfZgpeEnmw2CI9DiIqUTZTU1aTDRQfaEPRnG/WTI0KuVsNF2q8UgVcrX8gmxTEhq8dT4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=lvuQvAzI; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="lvuQvAzI" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E14CE1F000C4; Sat, 17 Oct 2026 17:45:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1792259133; bh=nt1Li3ESQJo9CvsAz2U62m0Kke6oAlSkajYyqtyNvio=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=lvuQvAzIzng0HeYHI5DFPcLH0zAnisr9HSif5FUQxa42J2vHJqhgVouUIQ+klKEi+ 2QwtV5/aTPMCSlQBkKMF3xoEqug3tIx7gtQ19pGC8unU7QJijpSKj0e+4SAGry5tHa aoKtlGKM7Qu79QjGJTnIJ7tMOJSdFQu1hhqTtrW8= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Mikulas Patocka , Sami Tolvanen , Sasha Levin Subject: [PATCH 6.6 1114/1674] dm-verity: fix buffer overflow in FEC calculation Date: Sat, 17 Oct 2026 17:56:26 +0200 Message-ID: <20261017160459.723147891@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261017160431.119607952@linuxfoundation.org> References: <20261017160431.119607952@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Mikulas Patocka [ Upstream commit 31d6e6c0ba8d5a7bd59660035a089307100c5e8e ] There's a buffer overflow in dm-verity-fec: if (neras && *neras <= v->fec->roots) fio->erasures[(*neras)++] = i; This allows *neras to reach roots + 1 (the post-increment pushes it past roots). This value is then passed as no_eras to decode_rs8(). Inside the RS decoder (lib/reed_solomon/decode_rs.c:113-121), the erasure locator polynomial loop writes lambda[j] where j can reach nroots + 1 — one element past the end of lambda[] (which is sized nroots + 1, valid indices 0..nroots). The out-of-bounds write lands on syn[0], corrupting the syndrome buffer. Signed-off-by: Mikulas Patocka Assisted-by: Claude:claude-opus-4-6 Cc: stable@vger.kernel.org Fixes: a739ff3f543a ("dm verity: add support for forward error correction") Reviewed-by: Sami Tolvanen Signed-off-by: Mikulas Patocka Signed-off-by: Sasha Levin --- drivers/md/dm-verity-fec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/md/dm-verity-fec.c b/drivers/md/dm-verity-fec.c index 5073c93cf962c..a9e3d44980862 100644 --- a/drivers/md/dm-verity-fec.c +++ b/drivers/md/dm-verity-fec.c @@ -261,7 +261,7 @@ static int fec_read_bufs(struct dm_verity *v, struct dm_verity_io *io, (unsigned long long)block, PTR_ERR(bbuf)); /* assume the block is corrupted */ - if (neras && *neras <= v->fec->roots) + if (neras && *neras < v->fec->roots) fio->erasures[(*neras)++] = i; continue; @@ -279,7 +279,7 @@ static int fec_read_bufs(struct dm_verity *v, struct dm_verity_io *io, * skip if we have already found the theoretical * maximum number (i.e. fec->roots) of erasures */ - if (neras && *neras <= v->fec->roots && + if (neras && *neras < v->fec->roots && fec_is_erasure(v, io, want_digest, bbuf)) fio->erasures[(*neras)++] = i; } -- 2.53.0