Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S938508AbcLOPxU (ORCPT ); Thu, 15 Dec 2016 10:53:20 -0500 Received: from out3-smtp.messagingengine.com ([66.111.4.27]:52930 "EHLO out3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752480AbcLOPxR (ORCPT ); Thu, 15 Dec 2016 10:53:17 -0500 X-ME-Sender: X-Sasl-enc: VQqBM6oySZGwmEVdgIQEABCFjQZfUU4dPb+/BpQe9c6M 1481817196 Subject: Re: [PATCH v2 1/4] siphash: add cryptographically secure hashtable function To: David Laight , "Jason A. Donenfeld" References: <20161214035927.30004-1-Jason@zx2c4.com> <8ea3fdff-23c4-b81d-2588-44549bd2d8c1@stressinduktion.org> <063D6719AE5E284EB5DD2968C1650D6DB02401ED@AcuExch.aculab.com> <707472e1-b385-836d-c4c6-791c1dcc0776@stressinduktion.org> <063D6719AE5E284EB5DD2968C1650D6DB02402C0@AcuExch.aculab.com> <0f3c3694-c00b-aae2-5b08-25bc64bf6372@stressinduktion.org> <063D6719AE5E284EB5DD2968C1650D6DB0240437@AcuExch.aculab.com> <063D6719AE5E284EB5DD2968C1650D6DB0240529@AcuExch.aculab.com> Cc: Netdev , "kernel-hardening@lists.openwall.com" , Jean-Philippe Aumasson , LKML , Linux Crypto Mailing List , "Daniel J . Bernstein" , Linus Torvalds , Eric Biggers From: Hannes Frederic Sowa Message-ID: <924ef794-eae0-2a6b-508b-069718339edc@stressinduktion.org> Date: Thu, 15 Dec 2016 16:53:12 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: <063D6719AE5E284EB5DD2968C1650D6DB0240529@AcuExch.aculab.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1032 Lines: 28 On 15.12.2016 16:41, David Laight wrote: > Try (retyped): > > echo 'struct { long a; long long b; } s; int bar { return sizeof s; }' >foo.c > gcc [-m32] -O2 -S foo.c; cat foo.s > > And look at what is generated. I used __alignof__(unsigned long long) with -m32. >> Right now ipv6 addresses have an alignment of 4. So we couldn't even >> naturally pass them to siphash but would need to copy them around, which >> I feel like a source of bugs. > > That is more of a problem on systems that don't support misaligned accesses. > Reading the 64bit values with two explicit 32bit reads would work. > I think you can get gcc to do that by adding an aligned(4) attribute to the > structure member. Yes, and that is actually my fear, because we support those architectures. I can't comment on that as I don't understand enough of this. If someone finds a way to cause misaligned reads on a small box this seems (maybe depending on sysctls they get fixed up or panic) to be a much bigger issue than having a hash DoS. Thanks, Hannes