23 Jul, 2020

1 commit

  • Rationale:
    Reduces attack surface on kernel devs opening the links for MITM
    as HTTPS traffic is much harder to manipulate.

    Deterministic algorithm:
    For each file:
    If not .svg:
    For each line:
    If doesn't contain `\bxmlns\b`:
    For each link, `\bhttp://[^# \t\r\n]*(?:\w|/)`:
    If neither `\bgnu\.org/license`, nor `\bmozilla\.org/MPL\b`:
    If both the HTTP and HTTPS versions
    return 200 OK and serve the same content:
    Replace HTTP with HTTPS.

    Signed-off-by: Alexander A. Klimov
    Signed-off-by: Herbert Xu

    Alexander A. Klimov
     

31 May, 2019

1 commit

  • Based on 1 normalized pattern(s):

    this program is free software you can redistribute it and or modify
    it under the terms of the gnu general public license as published by
    the free software foundation either version 2 of the license or at
    your option any later version

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-or-later

    has been chosen to replace the boilerplate/reference in 3029 file(s).

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Allison Randal
    Cc: linux-spdx@vger.kernel.org
    Link: https://lkml.kernel.org/r/20190527070032.746973796@linutronix.de
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     

18 Apr, 2019

1 commit

  • Use subsys_initcall for registration of all templates and generic
    algorithm implementations, rather than module_init. Then change
    cryptomgr to use arch_initcall, to place it before the subsys_initcalls.

    This is needed so that when both a generic and optimized implementation
    of an algorithm are built into the kernel (not loadable modules), the
    generic implementation is registered before the optimized one.
    Otherwise, the self-tests for the optimized implementation are unable to
    allocate the generic implementation for the new comparison fuzz tests.

    Note that on arm, a side effect of this change is that self-tests for
    generic implementations may run before the unaligned access handler has
    been installed. So, unaligned accesses will crash the kernel. This is
    arguably a good thing as it makes it easier to detect that type of bug.

    Signed-off-by: Eric Biggers
    Signed-off-by: Herbert Xu

    Eric Biggers
     

03 Aug, 2018

1 commit


09 Jul, 2018

1 commit

  • Many shash algorithms set .cra_flags = CRYPTO_ALG_TYPE_SHASH. But this
    is redundant with the C structure type ('struct shash_alg'), and
    crypto_register_shash() already sets the type flag automatically,
    clearing any type flag that was already there. Apparently the useless
    assignment has just been copy+pasted around.

    So, remove the useless assignment from all the shash algorithms.

    This patch shouldn't change any actual behavior.

    Signed-off-by: Eric Biggers
    Signed-off-by: Herbert Xu

    Eric Biggers
     

15 Jun, 2018

1 commit

  • keccakf() is the only function in kernel that uses __optimize() macro.
    __optimize() breaks frame pointer unwinder as optimized code uses RBP,
    and amusingly this always lead to degraded performance as gcc does not
    inline across different optimizations levels, so keccakf() wasn't inlined
    into its callers and keccakf_round() wasn't inlined into keccakf().

    Drop __optimize() to resolve both problems.

    Signed-off-by: Dmitry Vyukov
    Fixes: 83dee2ce1ae7 ("crypto: sha3-generic - rewrite KECCAK transform to help the compiler optimize")
    Reported-by: syzbot+37035ccfa9a0a017ffcf@syzkaller.appspotmail.com
    Reported-by: syzbot+e073e4740cfbb3ae200b@syzkaller.appspotmail.com
    Cc: linux-crypto@vger.kernel.org
    Cc: "David S. Miller"
    Cc: Herbert Xu
    Cc: Ard Biesheuvel
    Acked-by: Ard Biesheuvel
    Signed-off-by: Herbert Xu

    Dmitry Vyukov
     

10 Mar, 2018

1 commit


08 Feb, 2018

2 commits

  • With gcc-4.1.2:

    crypto/sha3_generic.c:39: warning: ‘__optimize__’ attribute directive ignored

    Use the newly introduced __optimize macro to fix this.

    Fixes: 83dee2ce1ae791c3 ("crypto: sha3-generic - rewrite KECCAK transform to help the compiler optimize")
    Signed-off-by: Geert Uytterhoeven
    Acked-by: Ard Biesheuvel
    Signed-off-by: Herbert Xu

    Geert Uytterhoeven
     
  • As reported by kbuild test robot, the optimized SHA3 C implementation
    compiles to mn10300 code that uses a disproportionate amount of stack
    space, i.e.,

    crypto/sha3_generic.c: In function 'keccakf':
    crypto/sha3_generic.c:147:1: warning: the frame size of 1232 bytes is larger than 1024 bytes [-Wframe-larger-than=]

    As kindly diagnosed by Arnd, this does not only occur when building for
    the mn10300 architecture (which is what the report was about) but also
    for h8300, and builds for other 32-bit architectures show an increase in
    stack space utilization as well.

    Given that SHA3 operates on 64-bit quantities, and keeps a state matrix
    of 25 64-bit words, it is not surprising that 32-bit architectures with
    few general purpose registers are impacted the most by this, and it is
    therefore reasonable to implement a workaround that distinguishes between
    32-bit and 64-bit architectures.

    Arnd figured out that taking the round calculation out of the loop, and
    inlining it explicitly but only on 64-bit architectures preserves most
    of the performance gain achieved by the rewrite, and also gets rid of
    the excessive use of stack space.

    Reported-by: kbuild test robot
    Suggested-by: Arnd Bergmann
    Signed-off-by: Ard Biesheuvel
    Signed-off-by: Herbert Xu

    Ard Biesheuvel
     

25 Jan, 2018

4 commits

  • To allow accelerated implementations to fall back to the generic
    routines, e.g., in contexts where a SIMD based implementation is
    not allowed to run, expose the generic SHA3 init/update/final
    routines to other modules.

    Signed-off-by: Ard Biesheuvel
    Signed-off-by: Herbert Xu

    Ard Biesheuvel
     
  • In preparation of exposing the generic SHA3 implementation to other
    versions as a fallback, simplify the code, and remove an inconsistency
    in the output handling (endian swabbing rsizw words of state before
    writing the output does not make sense)

    Signed-off-by: Ard Biesheuvel
    Signed-off-by: Herbert Xu

    Ard Biesheuvel
     
  • The way the KECCAK transform is currently coded involves many references
    into the state array using indexes that are calculated at runtime using
    simple but non-trivial arithmetic. This forces the compiler to treat the
    state matrix as an array in memory rather than keep it in registers,
    which results in poor performance.

    So instead, let's rephrase the algorithm using fixed array indexes only.
    This helps the compiler keep the state matrix in registers, resulting
    in the following speedup (SHA3-256 performance in cycles per byte):

    before after speedup
    Intel Core i7 @ 2.0 GHz (2.9 turbo) 100.6 35.7 2.8x
    Cortex-A57 @ 2.0 GHz (64-bit mode) 101.6 12.7 8.0x
    Cortex-A53 @ 1.0 GHz 224.4 15.8 14.2x
    Cortex-A57 @ 2.0 GHz (32-bit mode) 201.8 63.0 3.2x

    Signed-off-by: Ard Biesheuvel
    Signed-off-by: Herbert Xu

    Ard Biesheuvel
     
  • Ensure that the input is byte swabbed before injecting it into the
    SHA3 transform. Use the get_unaligned() accessor for this so that
    we don't perform unaligned access inadvertently on architectures
    that do not support that.

    Cc:
    Fixes: 53964b9ee63b7075 ("crypto: sha3 - Add SHA-3 hash algorithm")
    Signed-off-by: Ard Biesheuvel
    Signed-off-by: Herbert Xu

    Ard Biesheuvel
     

08 Aug, 2016

1 commit

  • On 32-bit (e.g. with m68k-linux-gnu-gcc-4.1):

    crypto/sha3_generic.c:27: warning: integer constant is too large for ‘long’ type
    crypto/sha3_generic.c:28: warning: integer constant is too large for ‘long’ type
    crypto/sha3_generic.c:29: warning: integer constant is too large for ‘long’ type
    crypto/sha3_generic.c:29: warning: integer constant is too large for ‘long’ type
    crypto/sha3_generic.c:31: warning: integer constant is too large for ‘long’ type
    crypto/sha3_generic.c:31: warning: integer constant is too large for ‘long’ type
    crypto/sha3_generic.c:32: warning: integer constant is too large for ‘long’ type
    crypto/sha3_generic.c:32: warning: integer constant is too large for ‘long’ type
    crypto/sha3_generic.c:32: warning: integer constant is too large for ‘long’ type
    crypto/sha3_generic.c:33: warning: integer constant is too large for ‘long’ type
    crypto/sha3_generic.c:33: warning: integer constant is too large for ‘long’ type
    crypto/sha3_generic.c:34: warning: integer constant is too large for ‘long’ type
    crypto/sha3_generic.c:34: warning: integer constant is too large for ‘long’ type

    Fixes: 53964b9ee63b7075 ("crypto: sha3 - Add SHA-3 hash algorithm")
    Signed-off-by: Geert Uytterhoeven
    Signed-off-by: Herbert Xu

    Geert Uytterhoeven
     

20 Jun, 2016

1 commit

  • This patch adds the implementation of SHA3 algorithm
    in software and it's based on original implementation
    pushed in patch https://lwn.net/Articles/518415/ with
    additional changes to match the padding rules specified
    in SHA-3 specification.

    Signed-off-by: Jeff Garzik
    Signed-off-by: Raveendra Padasalagi
    Signed-off-by: Herbert Xu

    Jeff Garzik