On Tue, 18 Jun 2019 at 11:39, Eric Dumazet <edumazet@xxxxxxxxxx> wrote: > > On Tue, Jun 18, 2019 at 2:32 AM Ard Biesheuvel > <ard.biesheuvel@xxxxxxxxxx> 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.