Commit a7ddb3d4 authored by Eric Biggers's avatar Eric Biggers Committed by Mikulas Patocka

dm-verity: make real_digest and want_digest fixed-length

Change the digest fields in struct dm_verity_io from variable-length to
fixed-length, since their maximum length is fixed at
HASH_MAX_DIGESTSIZE, i.e. 64 bytes, which is not too big.  This is
simpler and makes the fields a bit faster to access.

(HASH_MAX_DIGESTSIZE did not exist when this code was written, which may
explain why it wasn't used.)

This makes the verity_io_real_digest() and verity_io_want_digest()
functions trivial, but this patch leaves them in place temporarily since
most of their callers will go away in a later patch anyway.
Reviewed-by: default avatarSami Tolvanen <samitolvanen@google.com>
Acked-by: default avatarArd Biesheuvel <ardb@kernel.org>
Signed-off-by: default avatarEric Biggers <ebiggers@google.com>
Signed-off-by: default avatarMikulas Patocka <mpatocka@redhat.com>
parent e41e52e5
...@@ -1529,8 +1529,7 @@ static int verity_ctr(struct dm_target *ti, unsigned int argc, char **argv) ...@@ -1529,8 +1529,7 @@ static int verity_ctr(struct dm_target *ti, unsigned int argc, char **argv)
goto bad; goto bad;
} }
ti->per_io_data_size = sizeof(struct dm_verity_io) + ti->per_io_data_size = sizeof(struct dm_verity_io) + v->ahash_reqsize;
v->ahash_reqsize + v->digest_size * 2;
r = verity_fec_ctr(v); r = verity_fec_ctr(v);
if (r) if (r)
......
...@@ -91,15 +91,12 @@ struct dm_verity_io { ...@@ -91,15 +91,12 @@ struct dm_verity_io {
char *recheck_buffer; char *recheck_buffer;
u8 real_digest[HASH_MAX_DIGESTSIZE];
u8 want_digest[HASH_MAX_DIGESTSIZE];
/* /*
* Three variably-size fields follow this struct: * This struct is followed by a variable-sized struct ahash_request of
* * size v->ahash_reqsize. To access it, use verity_io_hash_req().
* u8 hash_req[v->ahash_reqsize];
* u8 real_digest[v->digest_size];
* u8 want_digest[v->digest_size];
*
* To access them use: verity_io_hash_req(), verity_io_real_digest()
* and verity_io_want_digest().
*/ */
}; };
...@@ -112,13 +109,13 @@ static inline struct ahash_request *verity_io_hash_req(struct dm_verity *v, ...@@ -112,13 +109,13 @@ static inline struct ahash_request *verity_io_hash_req(struct dm_verity *v,
static inline u8 *verity_io_real_digest(struct dm_verity *v, static inline u8 *verity_io_real_digest(struct dm_verity *v,
struct dm_verity_io *io) struct dm_verity_io *io)
{ {
return (u8 *)(io + 1) + v->ahash_reqsize; return io->real_digest;
} }
static inline u8 *verity_io_want_digest(struct dm_verity *v, static inline u8 *verity_io_want_digest(struct dm_verity *v,
struct dm_verity_io *io) struct dm_verity_io *io)
{ {
return (u8 *)(io + 1) + v->ahash_reqsize + v->digest_size; return io->want_digest;
} }
extern int verity_for_bv_block(struct dm_verity *v, struct dm_verity_io *io, extern int verity_for_bv_block(struct dm_verity *v, struct dm_verity_io *io,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment