Linux cryptographic layer development
 help / color / mirror / Atom feed
From: Eric Biggers <ebiggers@kernel.org>
To: "Jason A. Donenfeld" <Jason@zx2c4.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Linux Crypto Mailing List <linux-crypto@vger.kernel.org>,
	Theodore Ts'o <tytso@mit.edu>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Jean-Philippe Aumasson <jeanphilippe.aumasson@gmail.com>
Subject: Re: [PATCH v2] random: use SipHash as interrupt entropy accumulator
Date: Sat, 12 Mar 2022 16:23:14 -0800	[thread overview]
Message-ID: <Yi05ciQRhqa4MoF7@sol.localdomain> (raw)
In-Reply-To: <CAHmME9rYWyT=t8tU5MZfg6hKUqrz49haKRc51FUC+HjXFGoOdw@mail.gmail.com>

On Sat, Mar 12, 2022 at 05:07:05PM -0700, Jason A. Donenfeld wrote:
> Hi Eric,
> 
> On Sat, Mar 12, 2022 at 2:39 PM Eric Biggers <ebiggers@kernel.org> wrote:
> > On Sun, Mar 06, 2022 at 09:51:23AM -0700, Jason A. Donenfeld wrote:
> > > For this, we make use of SipHash-1-x on 64-bit and HalfSipHash-1-x on
> > > 32-bit, which are already in use in the kernel and achieve the same
> > > performance as the function they replace. It would be nice to do two
> > > rounds, but we don't exactly have the CPU budget handy for that, and one
> > > round alone is already sufficient.
> > >
> >
> > I'm a bit confused by the argument here.  It's not SipHash-1-x that's used
> > elsewhere in the kernel, but rather SipHash-2-4.  HalfSipHash-1-3 is used too
> 
> Actually the hsiphash family of functions are aliased to SipHash-1-3 on 64-bit:
> 
> /* Note that on 64-bit, we make HalfSipHash1-3 actually be SipHash1-3, for
>  * performance reasons. On 32-bit, below, we actually implement HalfSipHash1-3.
>  */

That isn't mentioned in Documentation/security/siphash.rst at all.  It actually
makes it pretty clear that hsiphash() is "HalfSipHash".

> > So on 64-bit platforms it now throws away half of the pool.
> >
> > It should use 'u8 pool[sizeof(fast_pool->pool)]' to avoid hardcoding a size.
> 
> Actually the commit message notes that we intentionally dump half of
> it on 64bit. This is intentional.
> 

It doesn't explain *why* it does that.  Also, the code is much more important
than the commit message, and there's no explanation in the code at all; it just
looks like a bug.

- Eric

  reply	other threads:[~2022-03-13  0:23 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-06 16:51 [PATCH v2] random: use SipHash as interrupt entropy accumulator Jason A. Donenfeld
2022-03-12 21:39 ` Eric Biggers
2022-03-13  0:07   ` Jason A. Donenfeld
2022-03-13  0:23     ` Eric Biggers [this message]
2022-03-13  0:24       ` Jason A. Donenfeld
2022-03-13  0:49         ` [PATCH v3] " Jason A. Donenfeld

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Yi05ciQRhqa4MoF7@sol.localdomain \
    --to=ebiggers@kernel.org \
    --cc=Jason@zx2c4.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jeanphilippe.aumasson@gmail.com \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tytso@mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox