lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CANn89i+X7YQ6DueDQAusA+1S5Kmo75OwzO+eYRZe_nR8=YWjuQ@mail.gmail.com>
Date:   Tue, 18 Jun 2019 02:53:05 -0700
From:   Eric Dumazet <edumazet@...gle.com>
To:     Ard Biesheuvel <ard.biesheuvel@...aro.org>
Cc:     netdev <netdev@...r.kernel.org>,
        Eric Biggers <ebiggers@...nel.org>,
        "open list:HARDWARE RANDOM NUMBER GENERATOR CORE" 
        <linux-crypto@...r.kernel.org>,
        Herbert Xu <herbert@...dor.apana.org.au>,
        David Miller <davem@...emloft.net>,
        Alexey Kuznetsov <kuznet@....inr.ac.ru>,
        Hideaki YOSHIFUJI <yoshfuji@...ux-ipv6.org>,
        Jason Baron <jbaron@...mai.com>,
        Christoph Paasch <cpaasch@...le.com>,
        David Laight <David.Laight@...lab.com>,
        Yuchung Cheng <ycheng@...gle.com>
Subject: Re: [PATCH 1/2] net: fastopen: make key handling more robust against
 future changes

On Tue, Jun 18, 2019 at 2:41 AM Ard Biesheuvel
<ard.biesheuvel@...aro.org> wrote:
>
> On Tue, 18 Jun 2019 at 11:39, Eric Dumazet <edumazet@...gle.com> wrote:
> >
> > On Tue, Jun 18, 2019 at 2:32 AM Ard Biesheuvel
> > <ard.biesheuvel@...aro.org> wrote:
> > >
> > > Some changes to the TCP fastopen code to make it more robust
> > > against future changes in the choice of key/cookie size, etc.
> > >
> > > - Instead of keeping the SipHash key in an untyped u8[] buffer
> > >   and casting it to the right type upon use, use the correct
> > >   siphash_key_t type directly. This ensures that the key will
> > >   appear at the correct alignment if we ever change the way
> > >   these data structures are allocated. (Currently, they are
> > >   only allocated via kmalloc so they always appear at the
> > >   correct alignment)
> > >
> > > - Use DIV_ROUND_UP when sizing the u64[] array to hold the
> > >   cookie, so it is always of sufficient size, even when
> > >   TCP_FASTOPEN_COOKIE_MAX is no longer a multiple of 8.
> > >
> > > - Add a key length check to tcp_fastopen_reset_cipher(). No
> > >   callers exist currently that fail this check (they all pass
> > >   compile constant values that equal TCP_FASTOPEN_KEY_LENGTH),
> > >   but future changes might create problems, e.g., by leaving part
> > >   of the key uninitialized, or overflowing the key buffers.
> > >
> > > Note that none of these are functional changes wrt the current
> > > state of the code.
> > >
> > ...
> >
> > > -       memcpy(ctx->key[0], primary_key, len);
> > > +       if (unlikely(len != TCP_FASTOPEN_KEY_LENGTH)) {
> > > +               pr_err("TCP: TFO key length %u invalid\n", len);
> > > +               err = -EINVAL;
> > > +               goto out;
> > > +       }
> >
> >
> > Why a pr_err() is there ?
> >
> > Can unpriv users flood the syslog ?
>
> They can if they could do so before: there was a call to
> crypto_cipher_setkey() in the original pre-SipHash code which would
> also result in a pr_err() on an invalid key length. That call got
> removed along with the AES cipher handling, and this basically
> reinstates it, as suggested by EricB.

This tcp_fastopen_reset_cipher() function is internal to TCP stack, all callers
always pass the correct length.

We could add checks all over the place, and end up having a TCP stack
full of defensive
checks and 10,000 additional lines of code :/

I would prefer not reinstating this.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ