Skip to content

Commit 51ba14f

Browse files
author
Mikulas Patocka
committed
dm-verity: do forward error correction on metadata I/O errors
Do forward error correction if metadata I/O fails. Signed-off-by: Mikulas Patocka <[email protected]> Reviewed-by: Sami Tolvanen <[email protected]>
1 parent 3be1f25 commit 51ba14f

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

drivers/md/dm-verity-target.c

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ static int verity_verify_level(struct dm_verity *v, struct dm_verity_io *io,
311311

312312
if (static_branch_unlikely(&use_bh_wq_enabled) && io->in_bh) {
313313
data = dm_bufio_get(v->bufio, hash_block, &buf);
314-
if (data == NULL) {
314+
if (IS_ERR_OR_NULL(data)) {
315315
/*
316316
* In tasklet and the hash was not in the bufio cache.
317317
* Return early and resume execution from a work-queue
@@ -324,8 +324,24 @@ static int verity_verify_level(struct dm_verity *v, struct dm_verity_io *io,
324324
&buf, bio->bi_ioprio);
325325
}
326326

327-
if (IS_ERR(data))
328-
return PTR_ERR(data);
327+
if (IS_ERR(data)) {
328+
if (skip_unverified)
329+
return 1;
330+
r = PTR_ERR(data);
331+
data = dm_bufio_new(v->bufio, hash_block, &buf);
332+
if (IS_ERR(data))
333+
return r;
334+
if (verity_fec_decode(v, io, DM_VERITY_BLOCK_TYPE_METADATA,
335+
hash_block, data) == 0) {
336+
aux = dm_bufio_get_aux_data(buf);
337+
aux->hash_verified = 1;
338+
goto release_ok;
339+
} else {
340+
dm_bufio_release(buf);
341+
dm_bufio_forget(v->bufio, hash_block);
342+
return r;
343+
}
344+
}
329345

330346
aux = dm_bufio_get_aux_data(buf);
331347

@@ -366,6 +382,7 @@ static int verity_verify_level(struct dm_verity *v, struct dm_verity_io *io,
366382
}
367383
}
368384

385+
release_ok:
369386
data += offset;
370387
memcpy(want_digest, data, v->digest_size);
371388
r = 0;
@@ -1761,7 +1778,7 @@ static struct target_type verity_target = {
17611778
.name = "verity",
17621779
/* Note: the LSMs depend on the singleton and immutable features */
17631780
.features = DM_TARGET_SINGLETON | DM_TARGET_IMMUTABLE,
1764-
.version = {1, 10, 0},
1781+
.version = {1, 11, 0},
17651782
.module = THIS_MODULE,
17661783
.ctr = verity_ctr,
17671784
.dtr = verity_dtr,

0 commit comments

Comments
 (0)