17 Feb, 2018

1 commit

  • commit a208fa8f33031b9e0aba44c7d1b7e68eb0cbd29e upstream.

    We need to consistently enforce that keyed hashes cannot be used without
    setting the key. To do this we need a reliable way to determine whether
    a given hash algorithm is keyed or not. AF_ALG currently does this by
    checking for the presence of a ->setkey() method. However, this is
    actually slightly broken because the CRC-32 algorithms implement
    ->setkey() but can also be used without a key. (The CRC-32 "key" is not
    actually a cryptographic key but rather represents the initial state.
    If not overridden, then a default initial state is used.)

    Prepare to fix this by introducing a flag CRYPTO_ALG_OPTIONAL_KEY which
    indicates that the algorithm has a ->setkey() method, but it is not
    required to be called. Then set it on all the CRC-32 algorithms.

    The same also applies to the Adler-32 implementation in Lustre.

    Also, the cryptd and mcryptd templates have to pass through the flag
    from their underlying algorithm.

    Signed-off-by: Eric Biggers
    Signed-off-by: Herbert Xu
    Signed-off-by: Greg Kroah-Hartman

    Eric Biggers
     

02 Nov, 2017

1 commit

  • Many source files in the tree are missing licensing information, which
    makes it harder for compliance tools to determine the correct license.

    By default all files without license information are under the default
    license of the kernel, which is GPL version 2.

    Update the files which contain no license information with the 'GPL-2.0'
    SPDX license identifier. The SPDX identifier is a legally binding
    shorthand, which can be used instead of the full boiler plate text.

    This patch is based on work done by Thomas Gleixner and Kate Stewart and
    Philippe Ombredanne.

    How this work was done:

    Patches were generated and checked against linux-4.14-rc6 for a subset of
    the use cases:
    - file had no licensing information it it.
    - file was a */uapi/* one with no licensing information in it,
    - file was a */uapi/* one with existing licensing information,

    Further patches will be generated in subsequent months to fix up cases
    where non-standard license headers were used, and references to license
    had to be inferred by heuristics based on keywords.

    The analysis to determine which SPDX License Identifier to be applied to
    a file was done in a spreadsheet of side by side results from of the
    output of two independent scanners (ScanCode & Windriver) producing SPDX
    tag:value files created by Philippe Ombredanne. Philippe prepared the
    base worksheet, and did an initial spot review of a few 1000 files.

    The 4.13 kernel was the starting point of the analysis with 60,537 files
    assessed. Kate Stewart did a file by file comparison of the scanner
    results in the spreadsheet to determine which SPDX license identifier(s)
    to be applied to the file. She confirmed any determination that was not
    immediately clear with lawyers working with the Linux Foundation.

    Criteria used to select files for SPDX license identifier tagging was:
    - Files considered eligible had to be source code files.
    - Make and config files were included as candidates if they contained >5
    lines of source
    - File already had some variant of a license header in it (even if
    Reviewed-by: Philippe Ombredanne
    Reviewed-by: Thomas Gleixner
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     

03 May, 2017

1 commit

  • Pull crypto updates from Herbert Xu:
    "Here is the crypto update for 4.12:

    API:
    - Add batch registration for acomp/scomp
    - Change acomp testing to non-unique compressed result
    - Extend algorithm name limit to 128 bytes
    - Require setkey before accept(2) in algif_aead

    Algorithms:
    - Add support for deflate rfc1950 (zlib)

    Drivers:
    - Add accelerated crct10dif for powerpc
    - Add crc32 in stm32
    - Add sha384/sha512 in ccp
    - Add 3des/gcm(aes) for v5 devices in ccp
    - Add Queue Interface (QI) backend support in caam
    - Add new Exynos RNG driver
    - Add ThunderX ZIP driver
    - Add driver for hardware random generator on MT7623 SoC"

    * 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6: (101 commits)
    crypto: stm32 - Fix OF module alias information
    crypto: algif_aead - Require setkey before accept(2)
    crypto: scomp - add support for deflate rfc1950 (zlib)
    crypto: scomp - allow registration of multiple scomps
    crypto: ccp - Change ISR handler method for a v5 CCP
    crypto: ccp - Change ISR handler method for a v3 CCP
    crypto: crypto4xx - rename ce_ring_contol to ce_ring_control
    crypto: testmgr - Allow ecb(cipher_null) in FIPS mode
    Revert "crypto: arm64/sha - Add constant operand modifier to ASM_EXPORT"
    crypto: ccp - Disable interrupts early on unload
    crypto: ccp - Use only the relevant interrupt bits
    hwrng: mtk - Add driver for hardware random generator on MT7623 SoC
    dt-bindings: hwrng: Add Mediatek hardware random generator bindings
    crypto: crct10dif-vpmsum - Fix missing preempt_disable()
    crypto: testmgr - replace compression known answer test
    crypto: acomp - allow registration of multiple acomps
    hwrng: n2 - Use devm_kcalloc() in n2rng_probe()
    crypto: chcr - Fix error handling related to 'chcr_alloc_shash'
    padata: get_next is never NULL
    crypto: exynos - Add new Exynos RNG driver
    ...

    Linus Torvalds
     

21 Apr, 2017

1 commit

  • In crct10dif_vpmsum() we call enable_kernel_altivec() without first
    disabling preemption, which is not allowed.

    It used to be sufficient just to call pagefault_disable(), because that
    also disabled preemption. But the two were decoupled in commit 8222dbe21e79
    ("sched/preempt, mm/fault: Decouple preemption from the page fault
    logic") in mid 2015.

    The crct10dif-vpmsum code inherited this bug from the crc32c-vpmsum code
    on which it was modelled.

    So add the missing preempt_disable/enable(). We should also call
    disable_kernel_fp(), although it does nothing by default, there is a
    debug switch to make it active and all enables should be paired with
    disables.

    Fixes: b01df1c16c9a ("crypto: powerpc - Add CRC-T10DIF acceleration")
    Acked-by: Daniel Axtens
    Signed-off-by: Michael Ellerman
    Signed-off-by: Herbert Xu

    Michael Ellerman
     

07 Apr, 2017

1 commit

  • In crc32c_vpmsum() we call enable_kernel_altivec() without first
    disabling preemption, which is not allowed:

    WARNING: CPU: 9 PID: 2949 at ../arch/powerpc/kernel/process.c:277 enable_kernel_altivec+0x100/0x120
    Modules linked in: dm_thin_pool dm_persistent_data dm_bio_prison dm_bufio libcrc32c vmx_crypto ...
    CPU: 9 PID: 2949 Comm: docker Not tainted 4.11.0-rc5-compiler_gcc-6.3.1-00033-g308ac7563944 #381
    ...
    NIP [c00000000001e320] enable_kernel_altivec+0x100/0x120
    LR [d000000003df0910] crc32c_vpmsum+0x108/0x150 [crc32c_vpmsum]
    Call Trace:
    0xc138fd09 (unreliable)
    crc32c_vpmsum+0x108/0x150 [crc32c_vpmsum]
    crc32c_vpmsum_update+0x3c/0x60 [crc32c_vpmsum]
    crypto_shash_update+0x88/0x1c0
    crc32c+0x64/0x90 [libcrc32c]
    dm_bm_checksum+0x48/0x80 [dm_persistent_data]
    sb_check+0x84/0x120 [dm_thin_pool]
    dm_bm_validate_buffer.isra.0+0xc0/0x1b0 [dm_persistent_data]
    dm_bm_read_lock+0x80/0xf0 [dm_persistent_data]
    __create_persistent_data_objects+0x16c/0x810 [dm_thin_pool]
    dm_pool_metadata_open+0xb0/0x1a0 [dm_thin_pool]
    pool_ctr+0x4cc/0xb60 [dm_thin_pool]
    dm_table_add_target+0x16c/0x3c0
    table_load+0x184/0x400
    ctl_ioctl+0x2f0/0x560
    dm_ctl_ioctl+0x38/0x50
    do_vfs_ioctl+0xd8/0x920
    SyS_ioctl+0x68/0xc0
    system_call+0x38/0xfc

    It used to be sufficient just to call pagefault_disable(), because that
    also disabled preemption. But the two were decoupled in commit 8222dbe21e79
    ("sched/preempt, mm/fault: Decouple preemption from the page fault
    logic") in mid 2015.

    So add the missing preempt_disable/enable(). We should also call
    disable_kernel_fp(), although it does nothing by default, there is a
    debug switch to make it active and all enables should be paired with
    disables.

    Fixes: 6dd7a82cc54e ("crypto: powerpc - Add POWER8 optimised crc32c")
    Cc: stable@vger.kernel.org # v4.8+
    Signed-off-by: Michael Ellerman

    Michael Ellerman
     

24 Mar, 2017

4 commits

  • vpmsum implementations often don't kick in for short test vectors.
    This is a simple test module that does a configurable number of
    random tests, each up to 64kB and each with random offsets.

    Both CRC-T10DIF and CRC32C are tested.

    Cc: Anton Blanchard
    Signed-off-by: Daniel Axtens
    Signed-off-by: Herbert Xu

    Daniel Axtens
     
  • T10DIF is a CRC16 used heavily in NVMe.

    It turns out we can accelerate it with a CRC32 library and a few
    little tricks.

    Provide the accelerator based the refactored CRC32 code.

    Cc: Anton Blanchard
    Thanks-to: Hong Bo Peng
    Signed-off-by: Daniel Axtens
    Signed-off-by: Herbert Xu

    Daniel Axtens
     
  • When CRC32c was included in the kernel, Anton ripped out
    the #ifdefs around reflected polynomials, because CRC32c
    is always reflected. However, not all CRCs use reflection
    so we'd like to make it optional.

    Restore the REFLECT parts from Anton's original CRC32
    implementation (https://github.com/antonblanchard/crc32-vpmsum)

    That implementation is available under GPLv2+, so we're OK
    from a licensing point of view:
    https://github.com/antonblanchard/crc32-vpmsum/blob/master/LICENSE.TXT

    As CRC32c requires REFLECT, add that #define.

    Cc: Anton Blanchard
    Signed-off-by: Daniel Axtens
    Signed-off-by: Herbert Xu

    Daniel Axtens
     
  • The core nuts and bolts of the crc32c vpmsum algorithm will
    also work for a number of other CRC algorithms with different
    polynomials. Factor out the function into a new asm file.

    To handle multiple users of the function, a user simply
    provides constants, defines the name of their CRC function,
    and then #includes the core algorithm file.

    Cc: Anton Blanchard
    Signed-off-by: Daniel Axtens
    Signed-off-by: Herbert Xu

    Daniel Axtens
     

08 Mar, 2017

1 commit

  • Turning on crypto self-tests on a POWER8 shows:

    alg: hash: Test 1 failed for crc32c-vpmsum
    00000000: ff ff ff ff

    Comparing the code with the Intel CRC32c implementation on which
    ours is based shows that we are doing an init with 0, not ~0
    as CRC32c requires.

    This probably wasn't caught because btrfs does its own weird
    open-coded initialisation.

    Initialise our internal context to ~0 on init.

    This makes the self-tests pass, and btrfs continues to work.

    Fixes: 6dd7a82cc54e ("crypto: powerpc - Add POWER8 optimised crc32c")
    Cc: Anton Blanchard
    Cc: stable@vger.kernel.org
    Signed-off-by: Daniel Axtens
    Acked-by: Anton Blanchard
    Signed-off-by: Herbert Xu

    Daniel Axtens
     

28 Nov, 2016

1 commit


11 Oct, 2016

1 commit

  • Pull crypto updates from Herbert Xu:
    "Here is the crypto update for 4.9:

    API:
    - The crypto engine code now supports hashes.

    Algorithms:
    - Allow keys >= 2048 bits in FIPS mode for RSA.

    Drivers:
    - Memory overwrite fix for vmx ghash.
    - Add support for building ARM sha1-neon in Thumb2 mode.
    - Reenable ARM ghash-ce code by adding import/export.
    - Reenable img-hash by adding import/export.
    - Add support for multiple cores in omap-aes.
    - Add little-endian support for sha1-powerpc.
    - Add Cavium HWRNG driver for ThunderX SoC"

    * 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6: (137 commits)
    crypto: caam - treat SGT address pointer as u64
    crypto: ccp - Make syslog errors human-readable
    crypto: ccp - clean up data structure
    crypto: vmx - Ensure ghash-generic is enabled
    crypto: testmgr - add guard to dst buffer for ahash_export
    crypto: caam - Unmap region obtained by of_iomap
    crypto: sha1-powerpc - little-endian support
    crypto: gcm - Fix IV buffer size in crypto_gcm_setkey
    crypto: vmx - Fix memory corruption caused by p8_ghash
    crypto: ghash-generic - move common definitions to a new header file
    crypto: caam - fix sg dump
    hwrng: omap - Only fail if pm_runtime_get_sync returns < 0
    crypto: omap-sham - shrink the internal buffer size
    crypto: omap-sham - add support for export/import
    crypto: omap-sham - convert driver logic to use sgs for data xmit
    crypto: omap-sham - change the DMA threshold value to a define
    crypto: omap-sham - add support functions for sg based data handling
    crypto: omap-sham - rename sgl to sgl_tmp for deprecation
    crypto: omap-sham - align algorithms on word offset
    crypto: omap-sham - add context export/import stubs
    ...

    Linus Torvalds
     

02 Oct, 2016

1 commit


09 Aug, 2016

1 commit


05 Jul, 2016

1 commit

  • Use the vector polynomial multiply-sum instructions in POWER8 to
    speed up crc32c.

    This is just over 41x faster than the slice-by-8 method that it
    replaces. Measurements on a 4.1 GHz POWER8 show it sustaining
    52 GiB/sec.

    A simple btrfs write performance test:

    dd if=/dev/zero of=/mnt/tmpfile bs=1M count=4096
    sync

    is over 3.7x faster.

    Signed-off-by: Anton Blanchard
    Signed-off-by: Herbert Xu

    Anton Blanchard
     

31 May, 2016

1 commit


20 Mar, 2016

1 commit

  • Pull powerpc updates from Michael Ellerman:
    "This was delayed a day or two by some build-breakage on old toolchains
    which we've now fixed.

    There's two PCI commits both acked by Bjorn.

    There's one commit to mm/hugepage.c which is (co)authored by Kirill.

    Highlights:
    - Restructure Linux PTE on Book3S/64 to Radix format from Paul
    Mackerras
    - Book3s 64 MMU cleanup in preparation for Radix MMU from Aneesh
    Kumar K.V
    - Add POWER9 cputable entry from Michael Neuling
    - FPU/Altivec/VSX save/restore optimisations from Cyril Bur
    - Add support for new ftrace ABI on ppc64le from Torsten Duwe

    Various cleanups & minor fixes from:
    - Adam Buchbinder, Andrew Donnellan, Balbir Singh, Christophe Leroy,
    Cyril Bur, Luis Henriques, Madhavan Srinivasan, Pan Xinhui, Russell
    Currey, Sukadev Bhattiprolu, Suraj Jitindar Singh.

    General:
    - atomics: Allow architectures to define their own __atomic_op_*
    helpers from Boqun Feng
    - Implement atomic{, 64}_*_return_* variants and acquire/release/
    relaxed variants for (cmp)xchg from Boqun Feng
    - Add powernv_defconfig from Jeremy Kerr
    - Fix BUG_ON() reporting in real mode from Balbir Singh
    - Add xmon command to dump OPAL msglog from Andrew Donnellan
    - Add xmon command to dump process/task similar to ps(1) from Douglas
    Miller
    - Clean up memory hotplug failure paths from David Gibson

    pci/eeh:
    - Redesign SR-IOV on PowerNV to give absolute isolation between VFs
    from Wei Yang.
    - EEH Support for SRIOV VFs from Wei Yang and Gavin Shan.
    - PCI/IOV: Rename and export virtfn_{add, remove} from Wei Yang
    - PCI: Add pcibios_bus_add_device() weak function from Wei Yang
    - MAINTAINERS: Update EEH details and maintainership from Russell
    Currey

    cxl:
    - Support added to the CXL driver for running on both bare-metal and
    hypervisor systems, from Christophe Lombard and Frederic Barrat.
    - Ignore probes for virtual afu pci devices from Vaibhav Jain

    perf:
    - Export Power8 generic and cache events to sysfs from Sukadev
    Bhattiprolu
    - hv-24x7: Fix usage with chip events, display change in counter
    values, display domain indices in sysfs, eliminate domain suffix in
    event names, from Sukadev Bhattiprolu

    Freescale:
    - Updates from Scott: "Highlights include 8xx optimizations, 32-bit
    checksum optimizations, 86xx consolidation, e5500/e6500 cpu
    hotplug, more fman and other dt bits, and minor fixes/cleanup"

    * tag 'powerpc-4.6-1' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux: (179 commits)
    powerpc: Fix unrecoverable SLB miss during restore_math()
    powerpc/8xx: Fix do_mtspr_cpu6() build on older compilers
    powerpc/rcpm: Fix build break when SMP=n
    powerpc/book3e-64: Use hardcoded mttmr opcode
    powerpc/fsl/dts: Add "jedec,spi-nor" flash compatible
    powerpc/T104xRDB: add tdm riser card node to device tree
    powerpc32: PAGE_EXEC required for inittext
    powerpc/mpc85xx: Add pcsphy nodes to FManV3 device tree
    powerpc/mpc85xx: Add MDIO bus muxing support to the board device tree(s)
    powerpc/86xx: Introduce and use common dtsi
    powerpc/86xx: Update device tree
    powerpc/86xx: Move dts files to fsl directory
    powerpc/86xx: Switch to kconfig fragments approach
    powerpc/86xx: Update defconfigs
    powerpc/86xx: Consolidate common platform code
    powerpc32: Remove one insn in mulhdu
    powerpc32: small optimisation in flush_icache_range()
    powerpc: Simplify test in __dma_sync()
    powerpc32: move xxxxx_dcache_range() functions inline
    powerpc32: Remove clear_pages() and define clear_page() inline
    ...

    Linus Torvalds
     

01 Mar, 2016

1 commit


17 Feb, 2016

2 commits

  • Commit 28856a9e52c7 missed the addition of the crypto/xts.h include file
    for different architecture-specific AES implementations.

    Signed-off-by: Stephan Mueller
    Signed-off-by: Herbert Xu

    Stephan Mueller
     
  • The patch centralizes the XTS key check logic into the service function
    xts_check_key which is invoked from the different XTS implementations.
    With this, the XTS implementations in ARM, ARM64, PPC and S390 have now
    a sanity check for the XTS keys similar to the other arches.

    In addition, this service function received a check to ensure that the
    key != the tweak key which is mandated by FIPS 140-2 IG A.9. As the
    check is not present in the standards defining XTS, it is only enforced
    in FIPS mode of the kernel.

    Signed-off-by: Stephan Mueller
    Signed-off-by: Herbert Xu

    Stephan Mueller
     

01 Dec, 2015

1 commit

  • The enable_kernel_*() functions leave the relevant MSR bits enabled
    until we exit the kernel sometime later. Create disable versions
    that wrap the kernel use of FP, Altivec VSX or SPE.

    While we don't want to disable it normally for performance reasons
    (MSR writes are slow), it will be used for a debug boot option that
    does this and catches bad uses in other areas of the kernel.

    Signed-off-by: Anton Blanchard
    Signed-off-by: Michael Ellerman

    Anton Blanchard
     

18 May, 2015

1 commit


09 Mar, 2015

1 commit

  • The current cryptodev-2.6 tree commits:

    d9850fc529ef ("crypto: powerpc/sha1 - kernel config")
    50ba29aaa7b0 ("crypto: powerpc/sha1 - glue")

    failed to properly place files under arch/powerpc/crypto, which
    leads to build errors:

    make[1]: *** No rule to make target 'arch/powerpc/crypto/sha1-spe-asm.o', needed by 'arch/powerpc/crypto/sha1-ppc-spe.o'. Stop.
    make[1]: *** No rule to make target 'arch/powerpc/crypto/sha1_spe_glue.o', needed by 'arch/powerpc/crypto/sha1-ppc-spe.o'. Stop.
    Makefile:947: recipe for target 'arch/powerpc/crypto' failed

    Move the two sha1 spe files under crypto/, and whilst there, rename
    other powerpc crypto files with underscores to use dashes for
    consistency.

    Cc: Markus Stockhausen
    Signed-off-by: Kim Phillips
    Signed-off-by: Herbert Xu

    Kim Phillips
     

04 Mar, 2015

3 commits


02 Mar, 2015

1 commit


01 Mar, 2015

7 commits


27 Feb, 2015

3 commits

  • Integrate the module into the kernel config tree.

    Signed-off-by: Markus Stockhausen
    Signed-off-by: Herbert Xu

    Markus Stockhausen
     
  • Glue code for crypto infrastructure. Call the assembler
    code where required. Disable preemption during calculation
    and enable SPE instructions in the kernel prior to the
    call. Avoid to disable preemption for too long.

    Take a little care about small input data. Kick out early
    for input chunks < 64 bytes and replace memset for context
    cleanup with simple loop.

    Signed-off-by: Markus Stockhausen
    Signed-off-by: Herbert Xu

    Markus Stockhausen
     
  • This is the assembler code for SHA256 implementation with
    the SIMD SPE instruction set. Although being only a 32 bit
    architecture GPRs are extended to 64 bit presenting two
    32 bit values. With the enhanced instruction set we can
    operate on them in parallel. That helps reducing the time
    to calculate W16-W64. For increasing performance even more
    the assembler function can compute hashes for more than
    one 64 byte input block. That saves a lot of register
    saving/restoring

    The state of the used SPE registers is preserved via the
    stack so we can run from interrupt context. There might
    be the case that we interrupt ourselves and push sensitive
    data from another context onto our stack. Clear this area
    in the stack afterwards to avoid information leakage.

    The code is endian independant.

    Signed-off-by: Markus Stockhausen
    Signed-off-by: Herbert Xu

    Markus Stockhausen
     

13 Jan, 2015

1 commit

  • Commit 5d26a105b5a7 ("crypto: prefix module autoloading with "crypto-"")
    changed the automatic module loading when requesting crypto algorithms
    to prefix all module requests with "crypto-". This requires all crypto
    modules to have a crypto specific module alias even if their file name
    would otherwise match the requested crypto algorithm.

    Even though commit 5d26a105b5a7 added those aliases for a vast amount of
    modules, it was missing a few. Add the required MODULE_ALIAS_CRYPTO
    annotations to those files to make them get loaded automatically, again.
    This fixes, e.g., requesting 'ecb(blowfish-generic)', which used to work
    with kernels v3.18 and below.

    Also change MODULE_ALIAS() lines to MODULE_ALIAS_CRYPTO(). The former
    won't work for crypto modules any more.

    Fixes: 5d26a105b5a7 ("crypto: prefix module autoloading with "crypto-"")
    Cc: Kees Cook
    Signed-off-by: Mathias Krause
    Signed-off-by: Herbert Xu

    Mathias Krause
     

02 Dec, 2014

1 commit

  • Memset on a local variable may be removed when it is called just before the
    variable goes out of scope. Using memzero_explicit defeats this
    optimization. A simplified version of the semantic patch that makes this
    change is as follows: (http://coccinelle.lip6.fr/)

    //
    @@
    identifier x;
    type T;
    @@

    {
    ... when any
    T x[...];
    ... when any
    when exists
    - memset
    + memzero_explicit
    (x,
    -0,
    ...)
    ... when != x
    when strict
    }
    //

    This change was suggested by Daniel Borkmann

    Signed-off-by: Julia Lawall
    Acked-by: Michael Ellerman
    Signed-off-by: Herbert Xu

    Julia Lawall
     

24 Nov, 2014

1 commit