git: 90ffac35b778 - stable/13 - eli: Zero pad bytes that arise when certain auth algorithms are used
Mark Johnston
markj at FreeBSD.org
Thu Jul 29 12:14:01 UTC 2021
The branch stable/13 has been updated by markj:
URL: https://cgit.FreeBSD.org/src/commit/?id=90ffac35b778564d1b4cb8ec7d2ff92ccc8e56dd
commit 90ffac35b778564d1b4cb8ec7d2ff92ccc8e56dd
Author: Mark Johnston <markj at FreeBSD.org>
AuthorDate: 2021-07-15 16:23:04 +0000
Commit: Mark Johnston <markj at FreeBSD.org>
CommitDate: 2021-07-29 12:12:22 +0000
eli: Zero pad bytes that arise when certain auth algorithms are used
When authentication is configured, GELI ensures that the amount of data
per sector is a multiple of 16 bytes. This is done in
eli_metadata_softc(). When the digest size is not a multiple of 16
bytes, this leaves some extra pad bytes at the end of every sector, and
they were not being zeroed before being written to disk. In particular,
this happens with the HMAC/SHA1, HMAC/RIPEMD160 and HMAC/SHA384 data
authentication algorithms.
This change ensures that they are zeroed before being written to disk.
Reported by: KMSAN
Reviewed by: delphij, asomers
Sponsored by: The FreeBSD Foundation
(cherry picked from commit 0fcafe8516d170852aa73f029a6a28bed1e29292)
---
sys/geom/eli/g_eli_integrity.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/sys/geom/eli/g_eli_integrity.c b/sys/geom/eli/g_eli_integrity.c
index 4cf982e3ddfa..d9ac0a2a3d72 100644
--- a/sys/geom/eli/g_eli_integrity.c
+++ b/sys/geom/eli/g_eli_integrity.c
@@ -510,6 +510,17 @@ g_eli_auth_run(struct g_eli_worker *wr, struct bio *bp)
if (bp->bio_cmd == BIO_WRITE)
memset(data + sc->sc_alen + data_secsize, 0,
encr_secsize - sc->sc_alen - data_secsize);
+ } else if (data_secsize + sc->sc_alen != encr_secsize) {
+ /*
+ * If the HMAC size is not a multiple of 128 bits, the
+ * per-sector data size is rounded down to ensure that
+ * encryption can be performed without requiring any
+ * padding. In this case, each sector contains unused
+ * bytes.
+ */
+ if (bp->bio_cmd == BIO_WRITE)
+ memset(data + sc->sc_alen + data_secsize, 0,
+ encr_secsize - sc->sc_alen - data_secsize);
}
if (bp->bio_cmd == BIO_WRITE) {
More information about the dev-commits-src-all
mailing list