From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50149) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bdLlN-0005bO-IQ for qemu-devel@nongnu.org; Fri, 26 Aug 2016 14:21:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bdLlJ-0007iR-B6 for qemu-devel@nongnu.org; Fri, 26 Aug 2016 14:21:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46522) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bdLlJ-0007i8-35 for qemu-devel@nongnu.org; Fri, 26 Aug 2016 14:21:53 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id ED02215567 for ; Fri, 26 Aug 2016 18:21:51 +0000 (UTC) References: <1472215666-13263-1-git-send-email-berrange@redhat.com> From: Eric Blake Message-ID: <57C088BE.3090106@redhat.com> Date: Fri, 26 Aug 2016 13:21:50 -0500 MIME-Version: 1.0 In-Reply-To: <1472215666-13263-1-git-send-email-berrange@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="Q9b1u40RPbHKcx7elfPiwGvqilC4I9B39" Subject: Re: [Qemu-devel] [PATCH] crypto: ensure XTS is only used with ciphers with 16 byte blocks List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Daniel P. Berrange" , qemu-devel@nongnu.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --Q9b1u40RPbHKcx7elfPiwGvqilC4I9B39 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 08/26/2016 07:47 AM, Daniel P. Berrange wrote: > The XTS cipher mode needs to be used with a cipher which has > a block size of 16 bytes. If a mis-matching block size is used, > the code will either corrupt memory beyond the IV array, or > not fully encrypt/decrypt the IV. >=20 > This fixes a memory curruption crash when attempting to use s/curruption/corruption/ > cast5-128 with xts, since the former has an 8 byte block size. >=20 > A test case is added to ensure the cipher creation fails with > such an invalid combination. >=20 > Signed-off-by: Daniel P. Berrange > --- > crypto/cipher-gcrypt.c | 6 ++++++ > crypto/cipher-nettle.c | 12 +++++++----- > tests/test-crypto-cipher.c | 44 ++++++++++++++++++++++++++++++++++++--= ------ > 3 files changed, 49 insertions(+), 13 deletions(-) Are you aiming for a last-minute 2.7 fix, or should this just be 2.8 material and cc qemu-stable? Reviewed-by: Eric Blake > +++ b/tests/test-crypto-cipher.c > @@ -370,6 +370,17 @@ static QCryptoCipherTestData test_data[] =3D { > @@ -449,8 +468,16 @@ static void test_cipher(const void *opaque) > cipher =3D qcrypto_cipher_new( > data->alg, data->mode, > key, nkey, > - &error_abort); > - g_assert(cipher !=3D NULL); > + &err); > + if (data->plaintext) { > + g_assert(err =3D=3D NULL); > + g_assert(cipher !=3D NULL); > + } else { > + g_assert(err !=3D NULL); > + error_free(err); Could shorten these two lines as error_free_or_abort(&err), but that's cosmetic. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --Q9b1u40RPbHKcx7elfPiwGvqilC4I9B39 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJXwIi+AAoJEKeha0olJ0NqZjIH/3moc2kV/U+PJlnq8He/eySz +GeY2NWZQmo33vt5mbgM0G0YTRhkIOC3ZEPSqzirXj+Q+GgeFIzJdI7xdp/ugz89 yrGWDUEPNYn+fic1ZLX6y3a/rPNZ3mlxFtbFFlceBVfjmfU4fiBfY4iN2SarEVHz OgygvlyO9eTLqSPW4pVVMB7WJQDtZeZ+gjMkrPGsydfVfL34a1SGwc7H4B5Mvee4 yXdNpehQRqhcewKGK12abL8z9X7hgUfHwoxU7PlvCK0/0e0thRhfF81ejHga6dfk Vu2h5qc0z9p/4Ae+1dHKkXizQLLNpewRZKFMbyD/S4vqv/nBCqNS2NP1YIKccnA= =0Rnb -----END PGP SIGNATURE----- --Q9b1u40RPbHKcx7elfPiwGvqilC4I9B39--