From mboxrd@z Thu Jan 1 00:00:00 1970 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 4544333AD99; Sat, 30 May 2026 18:35:32 +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=1780166133; cv=none; b=U8+d69/VPhAoJl1Kx2mCyyD72l+z5gRSn9Ty6IiyMJtx0zs8cFfSIsdJ8stA6nEJwgyIYIeM546rVU33GZb3n+s4qNuCRFArEtsghVTDidiaLLzcJYIeLKjhuoCVx1JUCSwoLHKBReoUmqfueGS749cras+jlbWNqSC4nft5mMg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780166133; c=relaxed/simple; bh=57xWj9n9YrpJRdyVgmIGywZXEox4dK0UBnFrzrlmWtg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=A6XNTdPeBZrmAo2jSnlHFbUAyPgWv1iDFTHLCTpE4Pl10+jpTJFrqmHiGdrvFipnNKTJE/WLgKBJ9+JK3+kwZNN5zz9ECVrku46VZFRrN+HR6Y/4euAFI64ekTDkAk8Fr0ve5jHC43takbOPt7rPlkmTxXHqCnw1bO8HHglHIjc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=AxonT+Rh; 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="AxonT+Rh" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8A6CE1F00893; Sat, 30 May 2026 18:35:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1780166132; bh=dvXZDdcjz6R6wrpN2REHxTbB/OPl11gLlSGNTzgXclU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=AxonT+Rhg6II5Yx1Neyq7tFXZlJ0lYctTFartqYQK3QGf5QNzeu0ux1JVL1FP8hKU GjjHsML575vMLzMFcPzlQjFgrNvDvHLLkydwfgoQm2co1C90qFgiGcDvWUJ/j1MIn9 TJylE92RV9cyqlitHNFXATqD4RFBbSV/La6NpRXw= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Eric Biggers , Mikulas Patocka Subject: [PATCH 5.10 249/589] dm-verity-fec: correctly reject too-small FEC devices Date: Sat, 30 May 2026 18:02:10 +0200 Message-ID: <20260530160231.536859934@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260530160224.570625122@linuxfoundation.org> References: <20260530160224.570625122@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-Transfer-Encoding: 8bit 5.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Eric Biggers commit 2b14e0bb63cc671120e7791658f5c494fc66d072 upstream. Fix verity_fec_ctr() to reject too-small FEC devices by correctly computing the number of parity blocks as 'f->rounds * f->roots'. Previously it incorrectly used 'div64_u64(f->rounds * f->roots, v->fec->roots << SECTOR_SHIFT)' which is a much smaller value. Note that the units of 'rounds' are blocks, not bytes. This matches the units of the value returned by dm_bufio_get_device_size(), which are also blocks. A later commit will give 'rounds' a clearer name. Fixes: a739ff3f543a ("dm verity: add support for forward error correction") Cc: stable@vger.kernel.org Signed-off-by: Eric Biggers Signed-off-by: Mikulas Patocka Signed-off-by: Greg Kroah-Hartman --- drivers/md/dm-verity-fec.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) --- a/drivers/md/dm-verity-fec.c +++ b/drivers/md/dm-verity-fec.c @@ -670,7 +670,7 @@ int verity_fec_ctr(struct dm_verity *v) { struct dm_verity_fec *f = v->fec; struct dm_target *ti = v->ti; - u64 hash_blocks, fec_blocks; + u64 hash_blocks; int ret; if (!verity_fec_is_enabled(v)) { @@ -754,8 +754,7 @@ int verity_fec_ctr(struct dm_verity *v) dm_bufio_set_sector_offset(f->bufio, f->start << (v->data_dev_block_bits - SECTOR_SHIFT)); - fec_blocks = div64_u64(f->rounds * f->roots, v->fec->roots << SECTOR_SHIFT); - if (dm_bufio_get_device_size(f->bufio) < fec_blocks) { + if (dm_bufio_get_device_size(f->bufio) < f->rounds * f->roots) { ti->error = "FEC device is too small"; return -E2BIG; }