21 Apr, 2018

2 commits

  • During freeing of the internal buffers used by the DRBG, set the pointer
    to NULL. It is possible that the context with the freed buffers is
    reused. In case of an error during initialization where the pointers
    do not yet point to allocated memory, the NULL value prevents a double
    free.

    Cc: stable@vger.kernel.org
    Fixes: 3cfc3b9721123 ("crypto: drbg - use aligned buffers")
    Signed-off-by: Stephan Mueller
    Reported-by: syzbot+75397ee3df5c70164154@syzkaller.appspotmail.com
    Signed-off-by: Herbert Xu

    Stephan Mueller
     
  • Commit eb02c38f0197 ("crypto: api - Keep failed instances alive") is
    making allocating crypto transforms sometimes fail with ELIBBAD, when
    multiple processes try to access encrypted files with fscrypt for the
    first time since boot. The problem is that the "request larval" for the
    algorithm is being mistaken for an algorithm which failed its tests.

    Fix it by only returning ELIBBAD for "non-larval" algorithms. Also
    don't leak a reference to the algorithm.

    Fixes: eb02c38f0197 ("crypto: api - Keep failed instances alive")
    Signed-off-by: Eric Biggers
    Signed-off-by: Herbert Xu

    Eric Biggers
     

16 Apr, 2018

1 commit

  • Pull more Kbuild updates from Masahiro Yamada:

    - pass HOSTLDFLAGS when compiling single .c host programs

    - build genksyms lexer and parser files instead of using shipped
    versions

    - rename *-asn1.[ch] to *.asn1.[ch] for suffix consistency

    - let the top .gitignore globally ignore artifacts generated by flex,
    bison, and asn1_compiler

    - let the top Makefile globally clean artifacts generated by flex,
    bison, and asn1_compiler

    - use safer .SECONDARY marker instead of .PRECIOUS to prevent
    intermediate files from being removed

    - support -fmacro-prefix-map option to make __FILE__ a relative path

    - fix # escaping to prepare for the future GNU Make release

    - clean up deb-pkg by using debian tools instead of handrolled
    source/changes generation

    - improve rpm-pkg portability by supporting kernel-install as a
    fallback of new-kernel-pkg

    - extend Kconfig listnewconfig target to provide more information

    * tag 'kbuild-v4.17-2' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild:
    kconfig: extend output of 'listnewconfig'
    kbuild: rpm-pkg: use kernel-install as a fallback for new-kernel-pkg
    Kbuild: fix # escaping in .cmd files for future Make
    kbuild: deb-pkg: split generating packaging and build
    kbuild: use -fmacro-prefix-map to make __FILE__ a relative path
    kbuild: mark $(targets) as .SECONDARY and remove .PRECIOUS markers
    kbuild: rename *-asn1.[ch] to *.asn1.[ch]
    kbuild: clean up *-asn1.[ch] patterns from top-level Makefile
    .gitignore: move *-asn1.[ch] patterns to the top-level .gitignore
    kbuild: add %.dtb.S and %.dtb to 'targets' automatically
    kbuild: add %.lex.c and %.tab.[ch] to 'targets' automatically
    genksyms: generate lexer and parser during build instead of shipping
    kbuild: clean up *.lex.c and *.tab.[ch] patterns from top-level Makefile
    .gitignore: move *.lex.c *.tab.[ch] patterns to the top-level .gitignore
    kbuild: use HOSTLDFLAGS for single .c executables

    Linus Torvalds
     

11 Apr, 2018

1 commit

  • Pull MIPS updates from James Hogan:
    "These are the main MIPS changes for 4.17. Rough overview:

    (1) generic platform: Add support for Microsemi Ocelot SoCs

    (2) crypto: Add CRC32 and CRC32C HW acceleration module

    (3) Various cleanups and misc improvements

    More detailed summary:

    Miscellaneous:
    - hang more efficiently on halt/powerdown/restart
    - pm-cps: Block system suspend when a JTAG probe is present
    - expand make help text for generic defconfigs
    - refactor handling of legacy defconfigs
    - determine the entry point from the ELF file header to fix microMIPS
    for certain toolchains
    - introduce isa-rev.h for MIPS_ISA_REV and use to simplify other code

    Minor cleanups:
    - DTS: boston/ci20: Unit name cleanups and correction
    - kdump: Make the default for PHYSICAL_START always 64-bit
    - constify gpio_led in Alchemy, AR7, and TXX9
    - silence a couple of W=1 warnings
    - remove duplicate includes

    Platform support:
    Generic platform:
    - add support for Microsemi Ocelot
    - dt-bindings: Add vendor prefix for Microsemi Corporation
    - dt-bindings: Add bindings for Microsemi SoCs
    - add ocelot SoC & PCB123 board DTS files
    - MAINTAINERS: Add entry for Microsemi MIPS SoCs
    - enable crc32-mips on r6 configs

    ath79:
    - fix AR724X_PLL_REG_PCIE_CONFIG offset

    BCM47xx:
    - firmware: Use mac_pton() for MAC address parsing
    - add Luxul XAP1500/XWR1750 WiFi LEDs
    - use standard reset button for Luxul XWR-1750

    BMIPS:
    - enable CONFIG_BRCMSTB_PM in bmips_stb_defconfig for build coverage
    - add STB PM, wake-up timer, watchdog DT nodes

    Octeon:
    - drop '.' after newlines in printk calls

    ralink:
    - pci-mt7621: Enable PCIe on MT7688"

    * tag 'mips_4.17' of git://git.kernel.org/pub/scm/linux/kernel/git/jhogan/mips: (37 commits)
    MIPS: BCM47XX: Use standard reset button for Luxul XWR-1750
    MIPS: BCM47XX: Add Luxul XAP1500/XWR1750 WiFi LEDs
    MIPS: Make the default for PHYSICAL_START always 64-bit
    MIPS: Use the entry point from the ELF file header
    MAINTAINERS: Add entry for Microsemi MIPS SoCs
    MIPS: generic: Add support for Microsemi Ocelot
    MIPS: mscc: Add ocelot PCB123 device tree
    MIPS: mscc: Add ocelot dtsi
    dt-bindings: mips: Add bindings for Microsemi SoCs
    dt-bindings: Add vendor prefix for Microsemi Corporation
    MIPS: ath79: Fix AR724X_PLL_REG_PCIE_CONFIG offset
    MIPS: pci-mt7620: Enable PCIe on MT7688
    MIPS: pm-cps: Block system suspend when a JTAG probe is present
    MIPS: VDSO: Replace __mips_isa_rev with MIPS_ISA_REV
    MIPS: BPF: Replace __mips_isa_rev with MIPS_ISA_REV
    MIPS: cpu-features.h: Replace __mips_isa_rev with MIPS_ISA_REV
    MIPS: Introduce isa-rev.h to define MIPS_ISA_REV
    MIPS: Hang more efficiently on halt/powerdown/restart
    FIRMWARE: bcm47xx_nvram: Replace mac address parsing
    MIPS: BMIPS: Add Broadcom STB watchdog nodes
    ...

    Linus Torvalds
     

08 Apr, 2018

1 commit

  • syzbot reported :

    BUG: KMSAN: uninit-value in alg_bind+0xe3/0xd90 crypto/af_alg.c:162

    We need to check addr_len before dereferencing sa (or uaddr)

    Fixes: bb30b8848c85 ("crypto: af_alg - whitelist mask and type")
    Signed-off-by: Eric Dumazet
    Reported-by: syzbot
    Cc: Stephan Mueller
    Cc: Herbert Xu
    Signed-off-by: David S. Miller

    Eric Dumazet
     

07 Apr, 2018

3 commits


05 Apr, 2018

1 commit

  • Pull crypto updates from Herbert Xu:
    "API:

    - add AEAD support to crypto engine

    - allow batch registration in simd

    Algorithms:

    - add CFB mode

    - add speck block cipher

    - add sm4 block cipher

    - new test case for crct10dif

    - improve scheduling latency on ARM

    - scatter/gather support to gcm in aesni

    - convert x86 crypto algorithms to skcihper

    Drivers:

    - hmac(sha224/sha256) support in inside-secure

    - aes gcm/ccm support in stm32

    - stm32mp1 support in stm32

    - ccree driver from staging tree

    - gcm support over QI in caam

    - add ks-sa hwrng driver"

    * 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6: (212 commits)
    crypto: ccree - remove unused enums
    crypto: ahash - Fix early termination in hash walk
    crypto: brcm - explicitly cast cipher to hash type
    crypto: talitos - don't leak pointers to authenc keys
    crypto: qat - don't leak pointers to authenc keys
    crypto: picoxcell - don't leak pointers to authenc keys
    crypto: ixp4xx - don't leak pointers to authenc keys
    crypto: chelsio - don't leak pointers to authenc keys
    crypto: caam/qi - don't leak pointers to authenc keys
    crypto: caam - don't leak pointers to authenc keys
    crypto: lrw - Free rctx->ext with kzfree
    crypto: talitos - fix IPsec cipher in length
    crypto: Deduplicate le32_to_cpu_array() and cpu_to_le32_array()
    crypto: doc - clarify hash callbacks state machine
    crypto: api - Keep failed instances alive
    crypto: api - Make crypto_alg_lookup static
    crypto: api - Remove unused crypto_type lookup function
    crypto: chelsio - Remove declaration of static function from header
    crypto: inside-secure - hmac(sha224) support
    crypto: inside-secure - hmac(sha256) support
    ..

    Linus Torvalds
     

31 Mar, 2018

6 commits

  • When we have an unaligned SG list entry where there is no leftover
    aligned data, the hash walk code will incorrectly return zero as if
    the entire SG list has been processed.

    This patch fixes it by moving onto the next page instead.

    Reported-by: Eli Cooper
    Cc:
    Signed-off-by: Herbert Xu

    Herbert Xu
     
  • The buffer rctx->ext contains potentially sensitive data and should
    be freed with kzfree.

    Cc:
    Fixes: 700cb3f5fe75 ("crypto: lrw - Convert to skcipher")
    Reported-by: Dan Carpenter
    Signed-off-by: Herbert Xu

    Herbert Xu
     
  • Deduplicate le32_to_cpu_array() and cpu_to_le32_array() by moving them
    to the generic header.

    No functional change implied.

    Signed-off-by: Andy Shevchenko
    Signed-off-by: Herbert Xu

    Andy Shevchenko
     
  • This patch reverts commit 9c521a200bc3 ("crypto: api - remove
    instance when test failed") and fixes the underlying problem
    in a different way.

    To recap, prior to the reverted commit, an instance that fails
    a self-test is kept around. However, it would satisfy any new
    lookups against its name and therefore the system may accumlulate
    an unbounded number of failed instances for the same algorithm
    name.

    The reverted commit fixed it by unregistering the instance. Hoever,
    this still does not prevent the creation of the same failed instance
    over and over again each time the name is looked up.

    This patch fixes it by keeping the failed instance around, just as
    we would if it were a normal algorithm. However, the lookup code
    has been udpated so that we do not attempt to create another
    instance as long as this failed one is still registered. Of course,
    you could still force a new creation by deleting the instance from
    user-space.

    A new error (ELIBBAD) has been commandeered for this purpose and
    will be returned when all registered algorithm of a given name
    have failed the self-test.

    Signed-off-by: Herbert Xu

    Herbert Xu
     
  • The function crypto_alg_lookup is only usd within the crypto API
    and should be not be exported to the modules. This patch marks
    it as a static function.

    Signed-off-by: Herbert Xu

    Herbert Xu
     
  • The lookup function in crypto_type was only used for the implicit
    IV generators which have been completely removed from the crypto
    API.

    This patch removes the lookup function as it is now useless.

    Signed-off-by: Herbert Xu

    Herbert Xu
     

16 Mar, 2018

4 commits

  • In order to be able to test yield support under preempt, add a test
    vector for CRC-T10DIF that is long enough to take multiple iterations
    (and thus possible preemption between them) of the primary loop of the
    accelerated x86 and arm64 implementations.

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

    Ard Biesheuvel
     
  • On the quest to remove all VLAs from the kernel[1], this switches to
    a pair of kmalloc regions instead of using the stack. This also moves
    the get_random_bytes() after all allocations (and drops the needless
    "nbytes" variable).

    [1] https://lkml.org/lkml/2018/3/7/621

    Signed-off-by: Kees Cook
    Reviewed-by: Tudor Ambarus
    Signed-off-by: Herbert Xu

    Kees Cook
     
  • Add testmgr tests for the newly introduced SM4 ECB symmetric cipher.

    Signed-off-by: Gilad Ben-Yossef
    Signed-off-by: Herbert Xu

    Gilad Ben-Yossef
     
  • Introduce the SM4 cipher algorithms (OSCCA GB/T 32907-2016).

    SM4 (GBT.32907-2016) is a cryptographic standard issued by the
    Organization of State Commercial Administration of China (OSCCA)
    as an authorized cryptographic algorithms for the use within China.

    SMS4 was originally created for use in protecting wireless
    networks, and is mandated in the Chinese National Standard for
    Wireless LAN WAPI (Wired Authentication and Privacy Infrastructure)
    (GB.15629.11-2003).

    Signed-off-by: Gilad Ben-Yossef
    Signed-off-by: Herbert Xu

    Gilad Ben-Yossef
     

10 Mar, 2018

1 commit


09 Mar, 2018

2 commits

  • Apparently the ecdh use case was in bluetooth which always has single
    element scatterlists, so the ecdh module was hard coded to expect
    them. Now we're using this in TPM, we need multi-element
    scatterlists, so remove this limitation.

    Signed-off-by: James Bottomley
    Signed-off-by: Herbert Xu

    James Bottomley
     
  • TPM security routines require encryption and decryption with AES in
    CFB mode, so add it to the Linux Crypto schemes. CFB is basically a
    one time pad where the pad is generated initially from the encrypted
    IV and then subsequently from the encrypted previous block of
    ciphertext. The pad is XOR'd into the plain text to get the final
    ciphertext.

    https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation#CFB

    Signed-off-by: James Bottomley
    Signed-off-by: Herbert Xu

    James Bottomley
     

03 Mar, 2018

18 commits

  • All users of ablk_helper have been converted over to crypto_simd, so
    remove ablk_helper.

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

    Eric Biggers
     
  • Now that all users of lrw_crypt() have been removed in favor of the LRW
    template wrapping an ECB mode algorithm, remove lrw_crypt(). Also
    remove crypto/lrw.h as that is no longer needed either; and fold
    'struct lrw_table_ctx' into 'struct priv', lrw_init_table() into
    setkey(), and lrw_free_table() into exit_tfm().

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

    Eric Biggers
     
  • Now that all users of xts_crypt() have been removed in favor of the XTS
    template wrapping an ECB mode algorithm, remove xts_crypt().

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

    Eric Biggers
     
  • Convert the AESNI AVX and AESNI AVX2 implementations of Camellia from
    the (deprecated) ablkcipher and blkcipher interfaces over to the
    skcipher interface. Note that this includes replacing the use of
    ablk_helper with crypto_simd.

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

    Eric Biggers
     
  • Convert the x86 asm implementation of Camellia from the (deprecated)
    blkcipher interface over to the skcipher interface.

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

    Eric Biggers
     
  • The XTS template now wraps an ECB mode algorithm rather than the block
    cipher directly. Therefore it is now redundant for crypto modules to
    wrap their ECB code with generic XTS code themselves via xts_crypt().

    Remove the xts-camellia-asm algorithm which did this. Users who request
    xts(camellia) and previously would have gotten xts-camellia-asm will now
    get xts(ecb-camellia-asm) instead, which is just as fast.

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

    Eric Biggers
     
  • The LRW template now wraps an ECB mode algorithm rather than the block
    cipher directly. Therefore it is now redundant for crypto modules to
    wrap their ECB code with generic LRW code themselves via lrw_crypt().

    Remove the lrw-camellia-asm algorithm which did this. Users who request
    lrw(camellia) and previously would have gotten lrw-camellia-asm will now
    get lrw(ecb-camellia-asm) instead, which is just as fast.

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

    Eric Biggers
     
  • The LRW template now wraps an ECB mode algorithm rather than the block
    cipher directly. Therefore it is now redundant for crypto modules to
    wrap their ECB code with generic LRW code themselves via lrw_crypt().

    Remove the lrw-camellia-aesni-avx2 algorithm which did this. Users who
    request lrw(camellia) and previously would have gotten
    lrw-camellia-aesni-avx2 will now get lrw(ecb-camellia-aesni-avx2)
    instead, which is just as fast.

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

    Eric Biggers
     
  • The LRW template now wraps an ECB mode algorithm rather than the block
    cipher directly. Therefore it is now redundant for crypto modules to
    wrap their ECB code with generic LRW code themselves via lrw_crypt().

    Remove the lrw-camellia-aesni algorithm which did this. Users who
    request lrw(camellia) and previously would have gotten
    lrw-camellia-aesni will now get lrw(ecb-camellia-aesni) instead, which
    is just as fast.

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

    Eric Biggers
     
  • Convert the x86 asm implementation of Triple DES from the (deprecated)
    blkcipher interface over to the skcipher interface.

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

    Eric Biggers
     
  • Convert the x86 asm implementation of Blowfish from the (deprecated)
    blkcipher interface over to the skcipher interface.

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

    Eric Biggers
     
  • Convert the AVX implementation of CAST6 from the (deprecated) ablkcipher
    and blkcipher interfaces over to the skcipher interface. Note that this
    includes replacing the use of ablk_helper with crypto_simd.

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

    Eric Biggers
     
  • The LRW template now wraps an ECB mode algorithm rather than the block
    cipher directly. Therefore it is now redundant for crypto modules to
    wrap their ECB code with generic LRW code themselves via lrw_crypt().

    Remove the lrw-cast6-avx algorithm which did this. Users who request
    lrw(cast6) and previously would have gotten lrw-cast6-avx will now get
    lrw(ecb-cast6-avx) instead, which is just as fast.

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

    Eric Biggers
     
  • Convert the AVX implementation of CAST5 from the (deprecated) ablkcipher
    and blkcipher interfaces over to the skcipher interface. Note that this
    includes replacing the use of ablk_helper with crypto_simd.

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

    Eric Biggers
     
  • Convert the AVX implementation of Twofish from the (deprecated)
    ablkcipher and blkcipher interfaces over to the skcipher interface.
    Note that this includes replacing the use of ablk_helper with
    crypto_simd.

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

    Eric Biggers
     
  • The LRW template now wraps an ECB mode algorithm rather than the block
    cipher directly. Therefore it is now redundant for crypto modules to
    wrap their ECB code with generic LRW code themselves via lrw_crypt().

    Remove the lrw-twofish-avx algorithm which did this. Users who request
    lrw(twofish) and previously would have gotten lrw-twofish-avx will now
    get lrw(ecb-twofish-avx) instead, which is just as fast.

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

    Eric Biggers
     
  • Convert the 3-way implementation of Twofish from the (deprecated)
    blkcipher interface over to the skcipher interface.

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

    Eric Biggers
     
  • The XTS template now wraps an ECB mode algorithm rather than the block
    cipher directly. Therefore it is now redundant for crypto modules to
    wrap their ECB code with generic XTS code themselves via xts_crypt().

    Remove the xts-twofish-3way algorithm which did this. Users who request
    xts(twofish) and previously would have gotten xts-twofish-3way will now
    get xts(ecb-twofish-3way) instead, which is just as fast.

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

    Eric Biggers