From owner-dev-commits-src-all@freebsd.org Thu Jul 29 12:14:01 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 68968672F6E; Thu, 29 Jul 2021 12:14:01 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gb8Zx0RmWz4b36; Thu, 29 Jul 2021 12:14:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D30B111669; Thu, 29 Jul 2021 12:14:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 16TCE0bL056628; Thu, 29 Jul 2021 12:14:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 16TCE0As056627; Thu, 29 Jul 2021 12:14:00 GMT (envelope-from git) Date: Thu, 29 Jul 2021 12:14:00 GMT Message-Id: <202107291214.16TCE0As056627@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 90ffac35b778 - stable/13 - eli: Zero pad bytes that arise when certain auth algorithms are used MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 90ffac35b778564d1b4cb8ec7d2ff92ccc8e56dd Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 Jul 2021 12:14:01 -0000 The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=90ffac35b778564d1b4cb8ec7d2ff92ccc8e56dd commit 90ffac35b778564d1b4cb8ec7d2ff92ccc8e56dd Author: Mark Johnston AuthorDate: 2021-07-15 16:23:04 +0000 Commit: Mark Johnston 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) {