Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756230AbcLNOrZ (ORCPT ); Wed, 14 Dec 2016 09:47:25 -0500 Received: from smtp-out6.electric.net ([192.162.217.190]:53648 "EHLO smtp-out6.electric.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752737AbcLNOrX (ORCPT ); Wed, 14 Dec 2016 09:47:23 -0500 From: David Laight To: "'Jason A. Donenfeld'" , Hannes Frederic Sowa CC: Netdev , "kernel-hardening@lists.openwall.com" , Andi Kleen , LKML , Linux Crypto Mailing List Subject: RE: [PATCH v2 3/4] secure_seq: use siphash24 instead of md5_transform Thread-Topic: [PATCH v2 3/4] secure_seq: use siphash24 instead of md5_transform Thread-Index: AQHSVhAtcZGtZTXzAUqRDCIPc4NX2qEHhMdg Date: Wed, 14 Dec 2016 14:47:11 +0000 Message-ID: <063D6719AE5E284EB5DD2968C1650D6DB023F7BD@AcuExch.aculab.com> References: <20161214035927.30004-1-Jason@zx2c4.com> <20161214035927.30004-3-Jason@zx2c4.com> <1e502c6b-cda3-c46d-2535-fcfb58f443a9@stressinduktion.org> In-Reply-To: Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.202.99.200] Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 X-Outbound-IP: 213.249.233.130 X-Env-From: David.Laight@ACULAB.COM X-Proto: esmtps X-Revdns: X-HELO: AcuExch.aculab.com X-TLS: TLSv1:AES128-SHA:128 X-Authenticated_ID: X-PolicySMART: 3396946, 3397078 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by mail.home.local id uBEElUnB029507 Content-Length: 1391 Lines: 29 From: Jason A. Donenfeld > Sent: 14 December 2016 13:44 > To: Hannes Frederic Sowa > > __packed not only removes all padding of the struct but also changes the > > alignment assumptions for the whole struct itself. The rule, the struct > > is aligned by its maximum alignment of a member is no longer true. That > > said, the code accessing this struct will change (not on archs that can > > deal efficiently with unaligned access, but on others). > > That's interesting. There currently aren't any alignment requirements > in siphash because we use the unaligned helper functions, but as David > pointed out in another thread, maybe that too should change. In that > case, we'd have an aligned-only version of the function that requires > 8-byte aligned input. Perhaps the best way to go about that would be > to just mark the struct as __packed __aligned(8). Or, I guess, since > 64-bit accesses gets split into two on 32-bit, that'd be best descried > as __packed __aligned(sizeof(long)). Would that be an acceptable > solution? Just remove the __packed and ensure that the structure is 'nice'. This includes ensuring there is no 'tail padding'. In some cases you'll need to put the port number into a 32bit field. I'd also require that the key be aligned. It probably ought to be a named structure type with two 64bit members (or with an array member that has two elements). David