]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
dm-verity: align struct dm_verity_fec_io properly
authorMikulas Patocka <mpatocka@redhat.com>
Tue, 28 Nov 2023 13:50:23 +0000 (14:50 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 8 Dec 2023 07:42:00 +0000 (08:42 +0100)
commit 38bc1ab135db87577695816b190e7d6d8ec75879 upstream.

dm_verity_fec_io is placed after the end of two hash digests. If the hash
digest has unaligned length, struct dm_verity_fec_io could be unaligned.

This commit fixes the placement of struct dm_verity_fec_io, so that it's
aligned.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Cc: stable@vger.kernel.org
Fixes: a739ff3f543a ("dm verity: add support for forward error correction")
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/md/dm-verity-fec.c
drivers/md/dm-verity.h

index 0fe6cc3007f582db705180ab337c98e1e45b5377..a819578408dfecd76bbbac955df6cbd1fa47cf96 100644 (file)
@@ -28,7 +28,8 @@ bool verity_fec_is_enabled(struct dm_verity *v)
  */
 static inline struct dm_verity_fec_io *fec_io(struct dm_verity_io *io)
 {
-       return (struct dm_verity_fec_io *) verity_io_digest_end(io->v, io);
+       return (struct dm_verity_fec_io *)
+               ((char *)io + io->v->ti->per_io_data_size - sizeof(struct dm_verity_fec_io));
 }
 
 /*
index a59e0ada6fd32d01b80c4032a25a67c90b048417..5509d69fd29ffcc59eb02ef8efe8eefd7870274a 100644 (file)
@@ -113,12 +113,6 @@ static inline u8 *verity_io_want_digest(struct dm_verity *v,
        return (u8 *)(io + 1) + v->ahash_reqsize + v->digest_size;
 }
 
-static inline u8 *verity_io_digest_end(struct dm_verity *v,
-                                      struct dm_verity_io *io)
-{
-       return verity_io_want_digest(v, io) + v->digest_size;
-}
-
 extern int verity_for_bv_block(struct dm_verity *v, struct dm_verity_io *io,
                               struct bvec_iter *iter,
                               int (*process)(struct dm_verity *v,