From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56780) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZG9fn-0000oP-4W for qemu-devel@nongnu.org; Fri, 17 Jul 2015 13:43:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZG9fi-0007rr-5F for qemu-devel@nongnu.org; Fri, 17 Jul 2015 13:43:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47379) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZG9fi-0007rl-0O for qemu-devel@nongnu.org; Fri, 17 Jul 2015 13:43:42 -0400 Date: Fri, 17 Jul 2015 19:43:39 +0200 From: Kevin Wolf Message-ID: <20150717174339.GD4622@noname.redhat.com> References: <1437062641-12684-1-git-send-email-rkrcmar@redhat.com> <1437062641-12684-3-git-send-email-rkrcmar@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <1437062641-12684-3-git-send-email-rkrcmar@redhat.com> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v3 2/3] crypto: avoid undefined behavior in nettle calls List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Radim =?utf-8?B?S3LEjW3DocWZ?= Cc: Peter Maydell , qemu-devel@nongnu.org Am 16.07.2015 um 18:04 hat Radim Kr=C4=8Dm=C3=A1=C5=99 geschrieben: > Calling a function pointer that was cast from an incompatible function > results in undefined behavior. 'void *' isn't compatible with 'struct > XXX *', so we can't cast to nettle_cipher_func, but have to provide a > wrapper. (Conversion from 'void *' to 'struct XXX *' might require > computation, which won't be done if we drop argument's true type and > pointers can have different sizes so passing arguments on stack would > bug.) >=20 > Having two different prototypes based on nettle version doesn't make > this solution any nicer. >=20 > Reported-by: Peter Maydell > Signed-off-by: Radim Kr=C4=8Dm=C3=A1=C5=99 git bisect says that it's this commit which broke qemu-iotests 134. > +static void aes_decrypt_wrapper(cipher_ctx_t ctx, cipher_length_t leng= th, > + uint8_t *dst, const uint8_t *src) > +{ > + aes_encrypt(ctx, length, dst, src); > +} And this is why (decrypt -> encrypt). I'll send a fix. Kevin