From nobody Tue Apr 7 14:38:09 2026 Received: from m16.mail.163.com (m16.mail.163.com [220.197.31.5]) (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 3899525E469; Thu, 26 Feb 2026 04:35:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=220.197.31.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772080548; cv=none; b=UkmH+/CK0FYrBw9VQa8EDskX5szSTNelzof+H8Gq3Lrv1BAdDrPz+Ym9OHysrcqEvVrB/rpeUIMHaBH2k+J1cYSUguc564B0sxDsQcTq7EB9lk9gtfdZMMsmVbG3TLPEksi8HowC0SEGE0VDmqvQeGmUMEmnwr3CoXuMi0oToIc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772080548; c=relaxed/simple; bh=VgKZ7h5jF94IMBFjoGg6OlKJR1vxd/PAP/SHux2b4Kk=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=FJUsmv5K7ZIDvlcLEwhZZaIWWlbMPO4nVoVs3o2adzjiUkqzPusd7ZxzU2l2AeBF6StgcIjhFBjGffvH3vqgxtrEqucIVK4btoQYYA6wNX7gNizh7ZW0sPkkK7KTj33fyrVaB8FzuHr1xpx7b6TfiHdPorAybUG7k4dOa1ow1dc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com; spf=pass smtp.mailfrom=163.com; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b=jMG+qnLT; arc=none smtp.client-ip=220.197.31.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b="jMG+qnLT" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=xd FrtjJUkRGvjv55SiKHuajTga/BZquBU8gFVuUTEYs=; b=jMG+qnLT7AcVeFLEJX KGWmp+pJc7o3ThLR+K9oXNBiQwhBTV5+IAsp0Ca1md+6LPyuZf+IuB6so+SPpYEV 7V1qN/k5IIVcWHVaoF13x+lnA7rqzmGEH8Nt6OvjIzTzg8Drv+2Fqgd5oYQ7xewu YFMgRXlH6lrTulfIJGaI98Rbo= Received: from pek-lpg-core6.wrs.com (unknown []) by gzga-smtp-mtada-g1-4 (Coremail) with SMTP id _____wAnM7V1zZ9pMaEyNg--.63411S2; Thu, 26 Feb 2026 12:35:02 +0800 (CST) From: Rahul Sharma To: gregkh@linuxfoundation.org, stable@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Mikulas Patocka , Guangwu Zhang , Sami Tolvanen , Eric Biggers , Rahul Sharma Subject: [PATCH 6.12.y] dm-verity: disable recursive forward error correction Date: Thu, 26 Feb 2026 12:35:00 +0800 Message-Id: <20260226043500.3945988-1-black.hawk@163.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: _____wAnM7V1zZ9pMaEyNg--.63411S2 X-Coremail-Antispam: 1Uf129KBjvJXoWxCFWfKw1DtrW8uF1rZr4DCFg_yoW5Jw47pF Z09a4fCr1rJF47GryDJ3WUZa45u34DK393GFW3uwna9a4Fyry8WryUtFW7ZFW0qr9rGFyY qF4qkFW5Z3s7uFJanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0zEwID-UUUUU= X-CM-SenderInfo: 5eoduy4okd4yi6rwjhhfrp/xtbC3RbSbGmfzXbspQAA3x Content-Type: text/plain; charset="utf-8" From: Mikulas Patocka [ Upstream commit d9f3e47d3fae0c101d9094bc956ed24e7a0ee801 ] There are two problems with the recursive correction: 1. It may cause denial-of-service. In fec_read_bufs, there is a loop that has 253 iterations. For each iteration, we may call verity_hash_for_block recursively. There is a limit of 4 nested recursions - that means that there may be at most 253^4 (4 billion) iterations. Red Hat QE team actually created an image that pushes dm-verity to this limit - and this image just makes the udev-worker process get stuck in the 'D' state. 2. It doesn't work. In fec_read_bufs we store data into the variable "fio->bufs", but fio bufs is shared between recursive invocations, if "verity_hash_for_block" invoked correction recursively, it would overwrite partially filled fio->bufs. Signed-off-by: Mikulas Patocka Reported-by: Guangwu Zhang Reviewed-by: Sami Tolvanen Reviewed-by: Eric Biggers [ The context change is due to the commit bdf253d580d7 ("dm-verity: remove support for asynchronous hashes") in v6.18 which is irrelevant to the logic of this patch. ] Signed-off-by: Rahul Sharma --- drivers/md/dm-verity-fec.c | 4 +--- drivers/md/dm-verity-fec.h | 3 --- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/md/dm-verity-fec.c b/drivers/md/dm-verity-fec.c index 7d477ff6f26b..c55f454ff979 100644 --- a/drivers/md/dm-verity-fec.c +++ b/drivers/md/dm-verity-fec.c @@ -424,10 +424,8 @@ int verity_fec_decode(struct dm_verity *v, struct dm_v= erity_io *io, if (!verity_fec_is_enabled(v)) return -EOPNOTSUPP; =20 - if (fio->level >=3D DM_VERITY_FEC_MAX_RECURSION) { - DMWARN_LIMIT("%s: FEC: recursion too deep", v->data_dev->name); + if (fio->level) return -EIO; - } =20 fio->level++; =20 diff --git a/drivers/md/dm-verity-fec.h b/drivers/md/dm-verity-fec.h index 09123a612953..ec37e607cb3f 100644 --- a/drivers/md/dm-verity-fec.h +++ b/drivers/md/dm-verity-fec.h @@ -23,9 +23,6 @@ #define DM_VERITY_FEC_BUF_MAX \ (1 << (PAGE_SHIFT - DM_VERITY_FEC_BUF_RS_BITS)) =20 -/* maximum recursion level for verity_fec_decode */ -#define DM_VERITY_FEC_MAX_RECURSION 4 - #define DM_VERITY_OPT_FEC_DEV "use_fec_from_device" #define DM_VERITY_OPT_FEC_BLOCKS "fec_blocks" #define DM_VERITY_OPT_FEC_START "fec_start" --=20 2.34.1