Skip to content

Commit 02ac7ae

Browse files
Eric Biggersgregkh
authored andcommitted
dm-verity-fec: correctly reject too-small hash devices
commit 4355142 upstream. Fix verity_fec_ctr() to reject too-small hash devices by correctly taking hash_start into account. Note that this is necessary because dm-verity doesn't call dm_bufio_set_sector_offset() on the hash device's bufio client (v->bufio). Thus, dm_bufio_get_device_size(v->bufio) returns a size relative to 0 rather than hash_start. An alternative fix would be to call dm_bufio_set_sector_offset() on v->bufio, but then all the code that reads from the hash device would have to be adjusted accordingly. Fixes: a739ff3 ("dm verity: add support for forward error correction") Cc: stable@vger.kernel.org Signed-off-by: Eric Biggers <ebiggers@kernel.org> Signed-off-by: Mikulas Patocka <mpatocka@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 4399f07 commit 02ac7ae

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

drivers/md/dm-verity-fec.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,8 @@ int verity_fec_ctr(struct dm_verity *v)
688688
* it to be large enough.
689689
*/
690690
f->hash_blocks = f->blocks - v->data_blocks;
691-
if (dm_bufio_get_device_size(v->bufio) < f->hash_blocks) {
691+
if (dm_bufio_get_device_size(v->bufio) <
692+
v->hash_start + f->hash_blocks) {
692693
ti->error = "Hash device is too small for "
693694
DM_VERITY_OPT_FEC_BLOCKS;
694695
return -E2BIG;

0 commit comments

Comments
 (0)