All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Laight <David.Laight@ACULAB.COM>
To: 'Ard Biesheuvel' <ard.biesheuvel@linaro.org>,
	"<netdev@vger.kernel.org>" <netdev@vger.kernel.org>,
	Eric Biggers <ebiggers@google.com>
Cc: "open list:HARDWARE RANDOM NUMBER GENERATOR CORE" 
	<linux-crypto@vger.kernel.org>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	Eric Dumazet <edumazet@google.com>,
	"David S. Miller" <davem@davemloft.net>,
	"kuznet@ms2.inr.ac.ru" <kuznet@ms2.inr.ac.ru>,
	"yoshfuji@linux-ipv6.org" <yoshfuji@linux-ipv6.org>
Subject: RE: [RFC PATCH] net: ipv4: move tcp_fastopen server side code to SipHash library
Date: Fri, 14 Jun 2019 12:37:53 +0000	[thread overview]
Message-ID: <6c21f1d9b4f54f1a82a98c9a4971e493@AcuMS.aculab.com> (raw)
In-Reply-To: <CAKv+Gu8SoEbsLyP5GWV+qX_F=z-yT67xdQJEeo2Vuaf2tt2+Qw@mail.gmail.com>

From: Ard Biesheuvel
> Sent: 14 June 2019 12:15
> (fix Eric's email address)
> 
> On Fri, 14 Jun 2019 at 13:14, Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:
> >
> > Using a bare block cipher in non-crypto code is almost always a bad idea,
> > not only for security reasons (and we've seen some examples of this in
> > the kernel in the past), but also for performance reasons.
> >
> > In the TCP fastopen case, we call into the bare AES block cipher one or
> > two times (depending on whether the connection is IPv4 or IPv6). On most
> > systems, this results in a call chain such as
> >
> >   crypto_cipher_encrypt_one(ctx, dst, src)
> >     crypto_cipher_crt(tfm)->cit_encrypt_one(crypto_cipher_tfm(tfm), ...);
> >       aesni_encrypt
> >         kernel_fpu_begin();
> >         aesni_enc(ctx, dst, src); // asm routine
> >         kernel_fpu_end();
> >
> > It is highly unlikely that the use of special AES instructions has a
> > benefit in this case, especially since we are doing the above twice
> > for IPv6 connections, instead of using a transform which can process
> > the entire input in one go.
> >
> > We could switch to the cbcmac(aes) shash, which would at least get
> > rid of the duplicated overhead in *some* cases (i.e., today, only
> > arm64 has an accelerated implementation of cbcmac(aes), while x86 will
> > end up using the generic cbcmac template wrapping the AES-NI cipher,
> > which basically ends up doing exactly the above). However, in the given
> > context, it makes more sense to use a light-weight MAC algorithm that
> > is more suitable for the purpose at hand, such as SipHash.
> >
> > Since the output size of SipHash already matches our chosen value for
> > TCP_FASTOPEN_COOKIE_SIZE, and given that it accepts arbitrary input
> > sizes, this greatly simplifies the code as well.
...
> > +       BUILD_BUG_ON(sizeof(siphash_key_t) != TCP_FASTOPEN_KEY_LENGTH);
> > +       BUILD_BUG_ON(sizeof(u64) != TCP_FASTOPEN_COOKIE_SIZE);

Those comparisons are backwards.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

  reply	other threads:[~2019-06-14 12:37 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-14 11:14 [RFC PATCH] net: ipv4: move tcp_fastopen server side code to SipHash library Ard Biesheuvel
2019-06-14 11:15 ` Ard Biesheuvel
2019-06-14 12:37   ` David Laight [this message]
2019-06-14 12:14 ` Eric Dumazet

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=6c21f1d9b4f54f1a82a98c9a4971e493@AcuMS.aculab.com \
    --to=david.laight@aculab.com \
    --cc=ard.biesheuvel@linaro.org \
    --cc=davem@davemloft.net \
    --cc=ebiggers@google.com \
    --cc=edumazet@google.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=kuznet@ms2.inr.ac.ru \
    --cc=linux-crypto@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=yoshfuji@linux-ipv6.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.