Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756812AbcLOXvQ (ORCPT ); Thu, 15 Dec 2016 18:51:16 -0500 Received: from frisell.zx2c4.com ([192.95.5.64]:58793 "EHLO frisell.zx2c4.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753995AbcLOXvP (ORCPT ); Thu, 15 Dec 2016 18:51:15 -0500 MIME-Version: 1.0 In-Reply-To: References: From: "Jason A. Donenfeld" Date: Fri, 16 Dec 2016 00:43:52 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 1/4] siphash: add cryptographically secure hashtable function To: Hannes Frederic Sowa Cc: David Laight , Netdev , "kernel-hardening@lists.openwall.com" , Jean-Philippe Aumasson , LKML , Linux Crypto Mailing List , "Daniel J . Bernstein" , Linus Torvalds , Eric Biggers Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1068 Lines: 28 Hi Hannes, Good news. On Thu, Dec 15, 2016 at 10:45 PM, Hannes Frederic Sowa wrote: >> How's that sound? > > I am still very much concerned about the API. Thanks for pushing me and putting up with my daftness... the constant folding works absolutely perfectly. I've run several tests. When gcc knows that a struct is aligned (say, via __aligned(8)), then it erases the branch and makes a direct jump to the aligned code. When it's uncertain, it evaluates at runtime. So, now there is a single siphash() function that chooses the best one automatically. Behind the scene there's siphash_aligned and siphash_unaligned, but nobody needs to call these directly. (Should I rename these to have a double underscore prefix?) On platforms that have CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS, of course all of this disappears and everything goes directly to the aligned version. So, I think this assuages your concerns entirely. A single API entry point that does the right thing. Whew! Good thinking, and thanks again for the suggestion. Jason