Skip to content

Commit d9f3e47

Browse files
author
Mikulas Patocka
committed
dm-verity: disable recursive forward error correction
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 <mpatocka@redhat.com> Reported-by: Guangwu Zhang <guazhang@redhat.com> Reviewed-by: Sami Tolvanen <samitolvanen@google.com> Reviewed-by: Eric Biggers <ebiggers@kernel.org>
1 parent 7fa3e7d commit d9f3e47

3 files changed

Lines changed: 2 additions & 7 deletions

File tree

drivers/md/dm-verity-fec.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -418,10 +418,8 @@ int verity_fec_decode(struct dm_verity *v, struct dm_verity_io *io,
418418
if (!verity_fec_is_enabled(v))
419419
return -EOPNOTSUPP;
420420

421-
if (fio->level >= DM_VERITY_FEC_MAX_RECURSION) {
422-
DMWARN_LIMIT("%s: FEC: recursion too deep", v->data_dev->name);
421+
if (fio->level)
423422
return -EIO;
424-
}
425423

426424
fio->level++;
427425

drivers/md/dm-verity-fec.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@
2323
#define DM_VERITY_FEC_BUF_MAX \
2424
(1 << (PAGE_SHIFT - DM_VERITY_FEC_BUF_RS_BITS))
2525

26-
/* maximum recursion level for verity_fec_decode */
27-
#define DM_VERITY_FEC_MAX_RECURSION 4
28-
2926
#define DM_VERITY_OPT_FEC_DEV "use_fec_from_device"
3027
#define DM_VERITY_OPT_FEC_BLOCKS "fec_blocks"
3128
#define DM_VERITY_OPT_FEC_START "fec_start"

drivers/md/dm-verity-target.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1789,7 +1789,7 @@ static struct target_type verity_target = {
17891789
.name = "verity",
17901790
/* Note: the LSMs depend on the singleton and immutable features */
17911791
.features = DM_TARGET_SINGLETON | DM_TARGET_IMMUTABLE,
1792-
.version = {1, 12, 0},
1792+
.version = {1, 13, 0},
17931793
.module = THIS_MODULE,
17941794
.ctr = verity_ctr,
17951795
.dtr = verity_dtr,

0 commit comments

Comments
 (0)