12 Jul, 2019

1 commit

  • Pull USB / PHY updates from Greg KH:
    "Here is the big USB and PHY driver pull request for 5.3-rc1.

    Lots of stuff here, all of which has been in linux-next for a while
    with no reported issues. Nothing is earth-shattering, just constant
    forward progress for more devices supported and cleanups and small
    fixes:

    - USB gadget driver updates and fixes

    - new USB gadget driver for some hardware, followed by a quick revert
    of those patches as they were not ready to be merged...

    - PHY driver updates

    - Lots of new driver additions and cleanups with a few fixes mixed
    in"

    * tag 'usb-5.3-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (145 commits)
    Revert "usb: gadget: storage: Remove warning message"
    Revert "dt-bindings: add binding for USBSS-DRD controller."
    Revert "usb:gadget Separated decoding functions from dwc3 driver."
    Revert "usb:gadget Patch simplify usb_decode_set_clear_feature function."
    Revert "usb:gadget Simplify usb_decode_get_set_descriptor function."
    Revert "usb:cdns3 Add Cadence USB3 DRD Driver"
    Revert "usb:cdns3 Fix for stuck packets in on-chip OUT buffer."
    usb :fsl: Change string format for errata property
    usb: host: Stops USB controller init if PLL fails to lock
    usb: linux/fsl_device: Add platform member has_fsl_erratum_a006918
    usb: phy: Workaround for USB erratum-A005728
    usb: fsl: Set USB_EN bit to select ULPI phy
    usb: Handle USB3 remote wakeup for LPM enabled devices correctly
    drivers/usb/typec/tps6598x.c: fix 4CC cmd write
    drivers/usb/typec/tps6598x.c: fix portinfo width
    usb: storage: scsiglue: Do not skip VPD if try_vpd_pages is set
    usb: renesas_usbhs: add a workaround for a race condition of workqueue
    usb: gadget: udc: renesas_usb3: remove redundant assignment to ret
    usb: dwc2: use a longer AHB idle timeout in dwc2_core_reset()
    USB: gadget: function: fix issue Unneeded variable: "value"
    ...

    Linus Torvalds
     

09 Jul, 2019

2 commits

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

    API:
    - Test shash interface directly in testmgr
    - cra_driver_name is now mandatory

    Algorithms:
    - Replace arc4 crypto_cipher with library helper
    - Implement 5 way interleave for ECB, CBC and CTR on arm64
    - Add xxhash
    - Add continuous self-test on noise source to drbg
    - Update jitter RNG

    Drivers:
    - Add support for SHA204A random number generator
    - Add support for 7211 in iproc-rng200
    - Fix fuzz test failures in inside-secure
    - Fix fuzz test failures in talitos
    - Fix fuzz test failures in qat"

    * 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6: (143 commits)
    crypto: stm32/hash - remove interruptible condition for dma
    crypto: stm32/hash - Fix hmac issue more than 256 bytes
    crypto: stm32/crc32 - rename driver file
    crypto: amcc - remove memset after dma_alloc_coherent
    crypto: ccp - Switch to SPDX license identifiers
    crypto: ccp - Validate the the error value used to index error messages
    crypto: doc - Fix formatting of new crypto engine content
    crypto: doc - Add parameter documentation
    crypto: arm64/aes-ce - implement 5 way interleave for ECB, CBC and CTR
    crypto: arm64/aes-ce - add 5 way interleave routines
    crypto: talitos - drop icv_ool
    crypto: talitos - fix hash on SEC1.
    crypto: talitos - move struct talitos_edesc into talitos.h
    lib/scatterlist: Fix mapping iterator when sg->offset is greater than PAGE_SIZE
    crypto/NX: Set receive window credits to max number of CRBs in RxFIFO
    crypto: asymmetric_keys - select CRYPTO_HASH where needed
    crypto: serpent - mark __serpent_setkey_sbox noinline
    crypto: testmgr - dynamically allocate crypto_shash
    crypto: testmgr - dynamically allocate testvec_config
    crypto: talitos - eliminate unneeded 'done' functions at build time
    ...

    Linus Torvalds
     
  • …/git/dhowells/linux-fs

    Pull keyring namespacing from David Howells:
    "These patches help make keys and keyrings more namespace aware.

    Firstly some miscellaneous patches to make the process easier:

    - Simplify key index_key handling so that the word-sized chunks
    assoc_array requires don't have to be shifted about, making it
    easier to add more bits into the key.

    - Cache the hash value in the key so that we don't have to calculate
    on every key we examine during a search (it involves a bunch of
    multiplications).

    - Allow keying_search() to search non-recursively.

    Then the main patches:

    - Make it so that keyring names are per-user_namespace from the point
    of view of KEYCTL_JOIN_SESSION_KEYRING so that they're not
    accessible cross-user_namespace.

    keyctl_capabilities() shows KEYCTL_CAPS1_NS_KEYRING_NAME for this.

    - Move the user and user-session keyrings to the user_namespace
    rather than the user_struct. This prevents them propagating
    directly across user_namespaces boundaries (ie. the KEY_SPEC_*
    flags will only pick from the current user_namespace).

    - Make it possible to include the target namespace in which the key
    shall operate in the index_key. This will allow the possibility of
    multiple keys with the same description, but different target
    domains to be held in the same keyring.

    keyctl_capabilities() shows KEYCTL_CAPS1_NS_KEY_TAG for this.

    - Make it so that keys are implicitly invalidated by removal of a
    domain tag, causing them to be garbage collected.

    - Institute a network namespace domain tag that allows keys to be
    differentiated by the network namespace in which they operate. New
    keys that are of a type marked 'KEY_TYPE_NET_DOMAIN' are assigned
    the network domain in force when they are created.

    - Make it so that the desired network namespace can be handed down
    into the request_key() mechanism. This allows AFS, NFS, etc. to
    request keys specific to the network namespace of the superblock.

    This also means that the keys in the DNS record cache are
    thenceforth namespaced, provided network filesystems pass the
    appropriate network namespace down into dns_query().

    For DNS, AFS and NFS are good, whilst CIFS and Ceph are not. Other
    cache keyrings, such as idmapper keyrings, also need to set the
    domain tag - for which they need access to the network namespace of
    the superblock"

    * tag 'keys-namespace-20190627' of git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs:
    keys: Pass the network namespace into request_key mechanism
    keys: Network namespace domain tag
    keys: Garbage collect keys for which the domain has been removed
    keys: Include target namespace in match criteria
    keys: Move the user and user-session keyrings to the user_namespace
    keys: Namespace keyring names
    keys: Add a 'recurse' flag for keyring searches
    keys: Cache the hash value to avoid lots of recalculation
    keys: Simplify key description management

    Linus Torvalds
     

05 Jul, 2019

1 commit


03 Jul, 2019

2 commits

  • Michal Suchanek reported [1] that running the pcrypt_aead01 test from
    LTP [2] in a loop and holding Ctrl-C causes a NULL dereference of
    alg->cra_users.next in crypto_remove_spawns(), via crypto_del_alg().
    The test repeatedly uses CRYPTO_MSG_NEWALG and CRYPTO_MSG_DELALG.

    The crash occurs when the instance that CRYPTO_MSG_DELALG is trying to
    unregister isn't a real registered algorithm, but rather is a "test
    larval", which is a special "algorithm" added to the algorithms list
    while the real algorithm is still being tested. Larvals don't have
    initialized cra_users, so that causes the crash. Normally pcrypt_aead01
    doesn't trigger this because CRYPTO_MSG_NEWALG waits for the algorithm
    to be tested; however, CRYPTO_MSG_NEWALG returns early when interrupted.

    Everything else in the "crypto user configuration" API has this same bug
    too, i.e. it inappropriately allows operating on larval algorithms
    (though it doesn't look like the other cases can cause a crash).

    Fix this by making crypto_alg_match() exclude larval algorithms.

    [1] https://lkml.kernel.org/r/20190625071624.27039-1-msuchanek@suse.de
    [2] https://github.com/linux-test-project/ltp/blob/20190517/testcases/kernel/crypto/pcrypt_aead01.c

    Reported-by: Michal Suchanek
    Fixes: a38f7907b926 ("crypto: Add userspace configuration API")
    Cc: # v3.2+
    Cc: Steffen Klassert
    Signed-off-by: Eric Biggers
    Signed-off-by: Herbert Xu

    Eric Biggers
     
  • cryptd_skcipher_free() fails to free the struct skcipher_instance
    allocated in cryptd_create_skcipher(), leading to a memory leak. This
    is detected by kmemleak on bootup on ARM64 platforms:

    unreferenced object 0xffff80003377b180 (size 1024):
    comm "cryptomgr_probe", pid 822, jiffies 4294894830 (age 52.760s)
    backtrace:
    kmem_cache_alloc_trace+0x270/0x2d0
    cryptd_create+0x990/0x124c
    cryptomgr_probe+0x5c/0x1e8
    kthread+0x258/0x318
    ret_from_fork+0x10/0x1c

    Fixes: 4e0958d19bd8 ("crypto: cryptd - Add support for skcipher")
    Cc:
    Signed-off-by: Vincent Whitchurch
    Signed-off-by: Herbert Xu

    Vincent Whitchurch
     

27 Jun, 2019

5 commits

  • Build testing with some core crypto options disabled revealed
    a few modules that are missing CRYPTO_HASH:

    crypto/asymmetric_keys/x509_public_key.o: In function `x509_get_sig_params':
    x509_public_key.c:(.text+0x4c7): undefined reference to `crypto_alloc_shash'
    x509_public_key.c:(.text+0x5e5): undefined reference to `crypto_shash_digest'
    crypto/asymmetric_keys/pkcs7_verify.o: In function `pkcs7_digest.isra.0':
    pkcs7_verify.c:(.text+0xab): undefined reference to `crypto_alloc_shash'
    pkcs7_verify.c:(.text+0x1b2): undefined reference to `crypto_shash_digest'
    pkcs7_verify.c:(.text+0x3c1): undefined reference to `crypto_shash_update'
    pkcs7_verify.c:(.text+0x411): undefined reference to `crypto_shash_finup'

    This normally doesn't show up in randconfig tests because there is
    a large number of other options that select CRYPTO_HASH.

    Signed-off-by: Arnd Bergmann
    Signed-off-by: Herbert Xu

    Arnd Bergmann
     
  • The same bug that gcc hit in the past is apparently now showing
    up with clang, which decides to inline __serpent_setkey_sbox:

    crypto/serpent_generic.c:268:5: error: stack frame size of 2112 bytes in function '__serpent_setkey' [-Werror,-Wframe-larger-than=]

    Marking it 'noinline' reduces the stack usage from 2112 bytes to
    192 and 96 bytes, respectively, and seems to generate more
    useful object code.

    Fixes: c871c10e4ea7 ("crypto: serpent - improve __serpent_setkey with UBSAN")
    Signed-off-by: Arnd Bergmann
    Reviewed-by: Eric Biggers
    Signed-off-by: Herbert Xu

    Arnd Bergmann
     
  • The largest stack object in this file is now the shash descriptor.
    Since there are many other stack variables, this can push it
    over the 1024 byte warning limit, in particular with clang and
    KASAN:

    crypto/testmgr.c:1693:12: error: stack frame size of 1312 bytes in function '__alg_test_hash' [-Werror,-Wframe-larger-than=]

    Make test_hash_vs_generic_impl() do the same thing as the
    corresponding eaed and skcipher functions by allocating the
    descriptor dynamically. We can still do better than this,
    but it brings us well below the 1024 byte limit.

    Suggested-by: Eric Biggers
    Fixes: 9a8a6b3f0950 ("crypto: testmgr - fuzz hashes against their generic implementation")
    Signed-off-by: Arnd Bergmann
    Reviewed-by: Eric Biggers
    Signed-off-by: Herbert Xu

    Arnd Bergmann
     
  • On arm32, we get warnings about high stack usage in some of the functions:

    crypto/testmgr.c:2269:12: error: stack frame size of 1032 bytes in function 'alg_test_aead' [-Werror,-Wframe-larger-than=]
    static int alg_test_aead(const struct alg_test_desc *desc, const char *driver,
    ^
    crypto/testmgr.c:1693:12: error: stack frame size of 1312 bytes in function '__alg_test_hash' [-Werror,-Wframe-larger-than=]
    static int __alg_test_hash(const struct hash_testvec *vecs,
    ^

    On of the larger objects on the stack here is struct testvec_config, so
    change that to dynamic allocation.

    Fixes: 40153b10d91c ("crypto: testmgr - fuzz AEADs against their generic implementation")
    Fixes: d435e10e67be ("crypto: testmgr - fuzz skciphers against their generic implementation")
    Fixes: 9a8a6b3f0950 ("crypto: testmgr - fuzz hashes against their generic implementation")
    Signed-off-by: Arnd Bergmann
    Reviewed-by: Eric Biggers
    Signed-off-by: Herbert Xu

    Arnd Bergmann
     
  • Add a 'recurse' flag for keyring searches so that the flag can be omitted
    and recursion disabled, thereby allowing just the nominated keyring to be
    searched and none of the children.

    Signed-off-by: David Howells

    David Howells
     

23 Jun, 2019

1 commit


20 Jun, 2019

3 commits


19 Jun, 2019

2 commits

  • Based on 2 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 version 2 as
    published by the free software foundation

    this program is free software you can redistribute it and or modify
    it under the terms of the gnu general public license version 2 as
    published by the free software foundation #

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-only

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

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

    Thomas Gleixner
     
  • 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 version 2 as
    published by the free software foundation this program is
    distributed in the hope that it will be useful but without any
    warranty without even the implied warranty of merchantability or
    fitness for a particular purpose see the gnu general public license
    for more details you should have received a copy of the gnu general
    public license along with this program if not see http www gnu org
    licenses

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-only

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

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

    Thomas Gleixner
     

18 Jun, 2019

1 commit

  • The wusb code takes a very peculiar approach at implementing CBC-MAC,
    by using plain CBC into a scratch buffer, and taking the output IV
    as the MAC.

    We can clean up this code substantially by switching to the cbcmac
    shash, as exposed by the CCM template. To ensure that the module is
    loaded on demand, add the cbcmac template name as a module alias.

    Signed-off-by: Ard Biesheuvel
    Signed-off-by: Greg Kroah-Hartman

    Ard Biesheuvel
     

13 Jun, 2019

7 commits

  • Constify the ctx and iv arguments to crypto_chacha_init() and the
    various chacha*_stream_xor() functions. This makes it clear that they
    are not modified.

    Signed-off-by: Eric Biggers
    Acked-by: Ard Biesheuvel
    Signed-off-by: Herbert Xu

    Eric Biggers
     
  • - Use sg_init_one() instead of sg_init_table() then sg_set_buf().

    - Remove unneeded calls to sg_init_table() prior to scatterwalk_ffwd().

    - Simplify initializing the poly tail block.

    - Simplify computing padlen.

    This doesn't change any actual behavior.

    Cc: Martin Willi
    Signed-off-by: Eric Biggers
    Signed-off-by: Herbert Xu

    Eric Biggers
     
  • crypto_skcipher_encrypt() and crypto_skcipher_decrypt() have grown to be
    more than a single indirect function call. They now also check whether
    a key has been set, and with CONFIG_CRYPTO_STATS=y they also update the
    crypto statistics. That can add up to a lot of bloat at every call
    site. Moreover, these always involve a function call anyway, which
    greatly limits the benefits of inlining.

    So change them to be non-inline.

    Signed-off-by: Eric Biggers
    Acked-by: Ard Biesheuvel
    Signed-off-by: Herbert Xu

    Eric Biggers
     
  • crypto_aead_encrypt() and crypto_aead_decrypt() have grown to be more
    than a single indirect function call. They now also check whether a key
    has been set, the decryption side checks whether the input is at least
    as long as the authentication tag length, and with CONFIG_CRYPTO_STATS=y
    they also update the crypto statistics. That can add up to a lot of
    bloat at every call site. Moreover, these always involve a function
    call anyway, which greatly limits the benefits of inlining.

    So change them to be non-inline.

    Signed-off-by: Eric Biggers
    Acked-by: Ard Biesheuvel
    Signed-off-by: Herbert Xu

    Eric Biggers
     
  • Call cond_resched() after each fuzz test iteration. This avoids stall
    warnings if fuzz_iterations is set very high for testing purposes.

    While we're at it, also call cond_resched() after finishing testing each
    test vector.

    Signed-off-by: Eric Biggers
    Acked-by: Ard Biesheuvel
    Signed-off-by: Herbert Xu

    Eric Biggers
     
  • Now that all algorithms explicitly set cra_driver_name, make it required
    for algorithm registration and remove the code that generated a default
    cra_driver_name.

    Also add an explicit check that cra_name is set too, since that's
    obviously required too, yet it didn't seem to be checked anywhere.

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

    Eric Biggers
     
  • Most generic crypto algorithms declare a driver name ending in
    "-generic". The rest don't declare a driver name and instead rely on
    the crypto API automagically appending "-generic" upon registration.

    Having multiple conventions is unnecessarily confusing and makes it
    harder to grep for all generic algorithms in the kernel source tree.
    But also, allowing NULL driver names is problematic because sometimes
    people fail to set it, e.g. the case fixed by commit 417980364300
    ("crypto: cavium/zip - fix collision with generic cra_driver_name").

    Of course, people can also incorrectly name their drivers "-generic".
    But that's much easier to notice / grep for.

    Therefore, let's make cra_driver_name mandatory. In preparation for
    this, this patch makes all generic algorithms set cra_driver_name.

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

    Eric Biggers
     

09 Jun, 2019

1 commit

  • Pull yet more SPDX updates from Greg KH:
    "Another round of SPDX header file fixes for 5.2-rc4

    These are all more "GPL-2.0-or-later" or "GPL-2.0-only" tags being
    added, based on the text in the files. We are slowly chipping away at
    the 700+ different ways people tried to write the license text. All of
    these were reviewed on the spdx mailing list by a number of different
    people.

    We now have over 60% of the kernel files covered with SPDX tags:
    $ ./scripts/spdxcheck.py -v 2>&1 | grep Files
    Files checked: 64533
    Files with SPDX: 40392
    Files with errors: 0

    I think the majority of the "easy" fixups are now done, it's now the
    start of the longer-tail of crazy variants to wade through"

    * tag 'spdx-5.2-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core: (159 commits)
    treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 450
    treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 449
    treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 448
    treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 446
    treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 445
    treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 444
    treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 443
    treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 442
    treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 441
    treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 440
    treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 438
    treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 437
    treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 436
    treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 435
    treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 434
    treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 433
    treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 432
    treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 431
    treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 430
    treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 429
    ...

    Linus Torvalds
     

07 Jun, 2019

1 commit


06 Jun, 2019

6 commits

  • Clear the CRYPTO_TFM_REQ_MAY_SLEEP flag when the chacha20poly1305
    operation is being continued from an async completion callback, since
    sleeping may not be allowed in that context.

    This is basically the same bug that was recently fixed in the xts and
    lrw templates. But, it's always been broken in chacha20poly1305 too.
    This was found using syzkaller in combination with the updated crypto
    self-tests which actually test the MAY_SLEEP flag now.

    Reproducer:

    python -c 'import socket; socket.socket(socket.AF_ALG, 5, 0).bind(
    ("aead", "rfc7539(cryptd(chacha20-generic),poly1305-generic)"))'

    Kernel output:

    BUG: sleeping function called from invalid context at include/crypto/algapi.h:426
    in_atomic(): 1, irqs_disabled(): 0, pid: 1001, name: kworker/2:2
    [...]
    CPU: 2 PID: 1001 Comm: kworker/2:2 Not tainted 5.2.0-rc2 #5
    Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.12.0-20181126_142135-anatol 04/01/2014
    Workqueue: crypto cryptd_queue_worker
    Call Trace:
    __dump_stack lib/dump_stack.c:77 [inline]
    dump_stack+0x4d/0x6a lib/dump_stack.c:113
    ___might_sleep kernel/sched/core.c:6138 [inline]
    ___might_sleep.cold.19+0x8e/0x9f kernel/sched/core.c:6095
    crypto_yield include/crypto/algapi.h:426 [inline]
    crypto_hash_walk_done+0xd6/0x100 crypto/ahash.c:113
    shash_ahash_update+0x41/0x60 crypto/shash.c:251
    shash_async_update+0xd/0x10 crypto/shash.c:260
    crypto_ahash_update include/crypto/hash.h:539 [inline]
    poly_setkey+0xf6/0x130 crypto/chacha20poly1305.c:337
    poly_init+0x51/0x60 crypto/chacha20poly1305.c:364
    async_done_continue crypto/chacha20poly1305.c:78 [inline]
    poly_genkey_done+0x15/0x30 crypto/chacha20poly1305.c:369
    cryptd_skcipher_complete+0x29/0x70 crypto/cryptd.c:279
    cryptd_skcipher_decrypt+0xcd/0x110 crypto/cryptd.c:339
    cryptd_queue_worker+0x70/0xa0 crypto/cryptd.c:184
    process_one_work+0x1ed/0x420 kernel/workqueue.c:2269
    worker_thread+0x3e/0x3a0 kernel/workqueue.c:2415
    kthread+0x11f/0x140 kernel/kthread.c:255
    ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:352

    Fixes: 71ebc4d1b27d ("crypto: chacha20poly1305 - Add a ChaCha20-Poly1305 AEAD construction, RFC7539")
    Cc: # v4.2+
    Cc: Martin Willi
    Signed-off-by: Eric Biggers
    Signed-off-by: Herbert Xu

    Eric Biggers
     
  • Commit c778f96bf347 ("crypto: lrw - Optimize tweak computation")
    incorrectly reduced the alignmask of LRW instances from
    '__alignof__(u64) - 1' to '__alignof__(__be32) - 1'.

    However, xor_tweak() and setkey() assume that the data and key,
    respectively, are aligned to 'be128', which has u64 alignment.

    Fix the alignmask to be at least '__alignof__(be128) - 1'.

    Fixes: c778f96bf347 ("crypto: lrw - Optimize tweak computation")
    Cc: # v4.20+
    Cc: Ondrej Mosnacek
    Signed-off-by: Eric Biggers
    Signed-off-by: Herbert Xu

    Eric Biggers
     
  • Changing ghash_mod_init() to be subsys_initcall made it start running
    before the alignment fault handler has been installed on ARM. In kernel
    builds where the keys in the ghash test vectors happened to be
    misaligned in the kernel image, this exposed the longstanding bug that
    ghash_setkey() is incorrectly casting the key buffer (which can have any
    alignment) to be128 for passing to gf128mul_init_4k_lle().

    Fix this by memcpy()ing the key to a temporary buffer.

    Don't fix it by setting an alignmask on the algorithm instead because
    that would unnecessarily force alignment of the data too.

    Fixes: 2cdc6899a88e ("crypto: ghash - Add GHASH digest algorithm for GCM")
    Reported-by: Peter Robinson
    Cc: stable@vger.kernel.org
    Signed-off-by: Eric Biggers
    Tested-by: Peter Robinson
    Signed-off-by: Herbert Xu

    Eric Biggers
     
  • xxhash is currently implemented as a self-contained module in /lib.
    This patch enables that module to be used as part of the generic kernel
    crypto framework. It adds a simple wrapper to the 64bit version.

    I've also added test vectors (with help from Nick Terrell). The upstream
    xxhash code is tested by running hashing operation on random 222 byte
    data with seed values of 0 and a prime number. The upstream test
    suite can be found at https://github.com/Cyan4973/xxHash/blob/cf46e0c/xxhsum.c#L664

    Essentially hashing is run on data of length 0,1,14,222 with the
    aforementioned seed values 0 and prime 2654435761. The particular random
    222 byte string was provided to me by Nick Terrell by reading
    /dev/random and the checksums were calculated by the upstream xxsum
    utility with the following bash script:

    dd if=/dev/random of=TEST_VECTOR bs=1 count=222

    for a in 0 1; do
    for l in 0 1 14 222; do
    for s in 0 2654435761; do
    echo algo $a length $l seed $s;
    head -c $l TEST_VECTOR | ~/projects/kernel/xxHash/xxhsum -H$a -s$s
    done
    done
    done

    This produces output as follows:

    algo 0 length 0 seed 0
    02cc5d05 stdin
    algo 0 length 0 seed 2654435761
    02cc5d05 stdin
    algo 0 length 1 seed 0
    25201171 stdin
    algo 0 length 1 seed 2654435761
    25201171 stdin
    algo 0 length 14 seed 0
    c1d95975 stdin
    algo 0 length 14 seed 2654435761
    c1d95975 stdin
    algo 0 length 222 seed 0
    b38662a6 stdin
    algo 0 length 222 seed 2654435761
    b38662a6 stdin
    algo 1 length 0 seed 0
    ef46db3751d8e999 stdin
    algo 1 length 0 seed 2654435761
    ac75fda2929b17ef stdin
    algo 1 length 1 seed 0
    27c3f04c2881203a stdin
    algo 1 length 1 seed 2654435761
    4a15ed26415dfe4d stdin
    algo 1 length 14 seed 0
    3d33dc700231dfad stdin
    algo 1 length 14 seed 2654435761
    ea5f7ddef9a64f80 stdin
    algo 1 length 222 seed 0
    5f3d3c08ec2bef34 stdin
    algo 1 length 222 seed 2654435761
    6a9df59664c7ed62 stdin

    algo 1 is xx64 variant, algo 0 is the 32 bit variant which is currently
    not hooked up.

    Signed-off-by: Nikolay Borisov
    Reviewed-by: Eric Biggers
    Signed-off-by: Herbert Xu

    Nikolay Borisov
     
  • The Jitter RNG implementation is updated to comply with upstream version
    2.1.2. The change covers the following aspects:

    * Time variation measurement is conducted over the LFSR operation
    instead of the XOR folding

    * Invcation of stuck test during initialization

    * Removal of the stirring functionality and the Von-Neumann
    unbiaser as the LFSR using a primitive and irreducible polynomial
    generates an identical distribution of random bits

    This implementation was successfully used in FIPS 140-2 validations
    as well as in German BSI evaluations.

    This kernel implementation was tested as follows:

    * The unchanged kernel code file jitterentropy.c is compiled as part
    of user space application to generate raw unconditioned noise
    data. That data is processed with the NIST SP800-90B non-IID test
    tool to verify that the kernel code exhibits an equal amount of noise
    as the upstream Jitter RNG version 2.1.2.

    * Using AF_ALG with the libkcapi tool of kcapi-rng the Jitter RNG was
    output tested with dieharder to verify that the output does not
    exhibit statistical weaknesses. The following command was used:
    kcapi-rng -n "jitterentropy_rng" -b 100000000000 | dieharder -a -g 200

    * The unchanged kernel code file jitterentropy.c is compiled as part
    of user space application to test the LFSR implementation. The
    LFSR is injected a monotonically increasing counter as input and
    the output is fed into dieharder to verify that the LFSR operation
    does not exhibit statistical weaknesses.

    * The patch was tested on the Muen separation kernel which returns
    a more coarse time stamp to verify that the Jitter RNG does not cause
    regressions with its initialization test considering that the Jitter
    RNG depends on a high-resolution timer.

    Tested-by: Reto Buerki
    Signed-off-by: Stephan Mueller
    Signed-off-by: Herbert Xu

    Stephan Müller
     
  • For hash algorithms implemented using the "shash" algorithm type, test
    both the ahash and shash APIs, not just the ahash API.

    Testing the ahash API already tests the shash API indirectly, which is
    normally good enough. However, there have been corner cases where there
    have been shash bugs that don't get exposed through the ahash API. So,
    update testmgr to test the shash API too.

    This would have detected the arm64 SHA-1 and SHA-2 bugs for which fixes
    were just sent out (https://patchwork.kernel.org/patch/10964843/ and
    https://patchwork.kernel.org/patch/10965089/):

    alg: shash: sha1-ce test failed (wrong result) on test vector 0, cfg="init+finup aligned buffer"
    alg: shash: sha224-ce test failed (wrong result) on test vector 0, cfg="init+finup aligned buffer"
    alg: shash: sha256-ce test failed (wrong result) on test vector 0, cfg="init+finup aligned buffer"

    This also would have detected the bugs fixed by commit 307508d10729
    ("crypto: crct10dif-generic - fix use via crypto_shash_digest()") and
    commit dec3d0b1071a
    ("crypto: x86/crct10dif-pcl - fix use via crypto_shash_digest()").

    Signed-off-by: Eric Biggers
    Acked-by: Ard Biesheuvel
    Signed-off-by: Herbert Xu

    Eric Biggers
     

05 Jun, 2019

2 commits

  • 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 version 2 as
    published by the free software foundation this program is
    distributed in the hope that it will be useful but without any
    warranty without even the implied warranty of merchantability or
    fitness for a particular purpose see the gnu general public license
    for more details you should have received a copy of the gnu general
    public license along with this program if not write to the free
    software foundation inc 51 franklin st fifth floor boston ma 02110
    1301 usa

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-only

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

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

    Thomas Gleixner
     
  • Based on 1 normalized pattern(s):

    this program is free software you can redistribute it and or modify
    it under the terms and conditions of the gnu general public license
    version 2 as published by the free software foundation this program
    is distributed in the hope it will be useful but without any
    warranty without even the implied warranty of merchantability or
    fitness for a particular purpose see the gnu general public license
    for more details you should have received a copy of the gnu general
    public license along with this program if not write to the free
    software foundation inc 51 franklin st fifth floor boston ma 02110
    1301 usa

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-only

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

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

    Thomas Gleixner
     

31 May, 2019

4 commits

  • 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 version 2 as
    published by the free software foundation this program is
    distributed in the hope that it will be useful but without any
    warranty without even the implied warranty of merchantability or
    fitness for a particular purpose see the gnu general public license
    for more details

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-only

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

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

    Thomas Gleixner
     
  • Based on 3 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 this program is distributed in the
    hope that it will be useful but without any warranty without even
    the implied warranty of merchantability or fitness for a particular
    purpose see the gnu general public license for more details

    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 [author] [kishon] [vijay] [abraham]
    [i] [kishon]@[ti] [com] this program is distributed in the hope that
    it will be useful but without any warranty without even the implied
    warranty of merchantability or fitness for a particular purpose see
    the gnu general public license for more details

    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 [author] [graeme] [gregory]
    [gg]@[slimlogic] [co] [uk] [author] [kishon] [vijay] [abraham] [i]
    [kishon]@[ti] [com] [based] [on] [twl6030]_[usb] [c] [author] [hema]
    [hk] [hemahk]@[ti] [com] this program is distributed in the hope
    that it will be useful but without any warranty without even the
    implied warranty of merchantability or fitness for a particular
    purpose see the gnu general public license for more details

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-or-later

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

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

    Thomas Gleixner
     
  • 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
     
  • Based on 1 normalized pattern(s):

    this program is free software you can redistribute it and or modify
    it under the terms of gnu general public license as published by the
    free software foundation either version 2 of the license or at your
    option any later version you should have received a copy of the gnu
    general public license along with this program if not see http www
    gnu org licenses

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-or-later

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

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

    Thomas Gleixner
     

30 May, 2019

1 commit