From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46847) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZG3J1-00035K-LH for qemu-devel@nongnu.org; Fri, 17 Jul 2015 06:55:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZG3Iy-0005jx-0k for qemu-devel@nongnu.org; Fri, 17 Jul 2015 06:55:51 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52377) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZG3Ix-0005jo-Rk for qemu-devel@nongnu.org; Fri, 17 Jul 2015 06:55:47 -0400 Date: Fri, 17 Jul 2015 11:55:43 +0100 From: "Daniel P. Berrange" Message-ID: <20150717105543.GG4835@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 Reply-To: "Daniel P. Berrange" 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 On Thu, Jul 16, 2015 at 06:04:00PM +0200, Radim Kr=C4=8Dm=C3=A1=C5=99 wro= te: > 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 > --- > v3: make wrappers 'static' > v2: new [Peter] >=20 > crypto/cipher-nettle.c | 43 +++++++++++++++++++++++++++++++++++++++---= - > 1 file changed, 39 insertions(+), 4 deletions(-) Reviewed-by: Daniel P. Berrange Regards, Daniel --=20 |: http://berrange.com -o- http://www.flickr.com/photos/dberrange= / :| |: http://libvirt.org -o- http://virt-manager.or= g :| |: http://autobuild.org -o- http://search.cpan.org/~danberr= / :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vn= c :|