14 Oct, 2020

1 commit

  • Pull block driver updates from Jens Axboe:
    "Here are the driver updates for 5.10.

    A few SCSI updates in here too, in coordination with Martin as they
    depend on core block changes for the shared tag bitmap.

    This contains:

    - NVMe pull requests via Christoph:
    - fix keep alive timer modification (Amit Engel)
    - order the PCI ID list more sensibly (Andy Shevchenko)
    - cleanup the open by controller helper (Chaitanya Kulkarni)
    - use an xarray for the CSE log lookup (Chaitanya Kulkarni)
    - support ZNS in nvmet passthrough mode (Chaitanya Kulkarni)
    - fix nvme_ns_report_zones (Christoph Hellwig)
    - add a sanity check to nvmet-fc (James Smart)
    - fix interrupt allocation when too many polled queues are
    specified (Jeffle Xu)
    - small nvmet-tcp optimization (Mark Wunderlich)
    - fix a controller refcount leak on init failure (Chaitanya
    Kulkarni)
    - misc cleanups (Chaitanya Kulkarni)
    - major refactoring of the scanning code (Christoph Hellwig)

    - MD updates via Song:
    - Bug fixes in bitmap code, from Zhao Heming
    - Fix a work queue check, from Guoqing Jiang
    - Fix raid5 oops with reshape, from Song Liu
    - Clean up unused code, from Jason Yan
    - Discard improvements, from Xiao Ni
    - raid5/6 page offset support, from Yufen Yu

    - Shared tag bitmap for SCSI/hisi_sas/null_blk (John, Kashyap,
    Hannes)

    - null_blk open/active zone limit support (Niklas)

    - Set of bcache updates (Coly, Dongsheng, Qinglang)"

    * tag 'drivers-5.10-2020-10-12' of git://git.kernel.dk/linux-block: (78 commits)
    md/raid5: fix oops during stripe resizing
    md/bitmap: fix memory leak of temporary bitmap
    md: fix the checking of wrong work queue
    md/bitmap: md_bitmap_get_counter returns wrong blocks
    md/bitmap: md_bitmap_read_sb uses wrong bitmap blocks
    md/raid0: remove unused function is_io_in_chunk_boundary()
    nvme-core: remove extra condition for vwc
    nvme-core: remove extra variable
    nvme: remove nvme_identify_ns_list
    nvme: refactor nvme_validate_ns
    nvme: move nvme_validate_ns
    nvme: query namespace identifiers before adding the namespace
    nvme: revalidate zone bitmaps in nvme_update_ns_info
    nvme: remove nvme_update_formats
    nvme: update the known admin effects
    nvme: set the queue limits in nvme_update_ns_info
    nvme: remove the 0 lba_shift check in nvme_update_ns_info
    nvme: clean up the check for too large logic block sizes
    nvme: freeze the queue over ->lba_shift updates
    nvme: factor out a nvme_configure_metadata helper
    ...

    Linus Torvalds
     

13 Oct, 2020

1 commit

  • Pull crypto updates from Herbert Xu:
    "API:
    - Allow DRBG testing through user-space af_alg
    - Add tcrypt speed testing support for keyed hashes
    - Add type-safe init/exit hooks for ahash

    Algorithms:
    - Mark arc4 as obsolete and pending for future removal
    - Mark anubis, khazad, sead and tea as obsolete
    - Improve boot-time xor benchmark
    - Add OSCCA SM2 asymmetric cipher algorithm and use it for integrity

    Drivers:
    - Fixes and enhancement for XTS in caam
    - Add support for XIP8001B hwrng in xiphera-trng
    - Add RNG and hash support in sun8i-ce/sun8i-ss
    - Allow imx-rngc to be used by kernel entropy pool
    - Use crypto engine in omap-sham
    - Add support for Ingenic X1830 with ingenic"

    * 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6: (205 commits)
    X.509: Fix modular build of public_key_sm2
    crypto: xor - Remove unused variable count in do_xor_speed
    X.509: fix error return value on the failed path
    crypto: bcm - Verify GCM/CCM key length in setkey
    crypto: qat - drop input parameter from adf_enable_aer()
    crypto: qat - fix function parameters descriptions
    crypto: atmel-tdes - use semicolons rather than commas to separate statements
    crypto: drivers - use semicolons rather than commas to separate statements
    hwrng: mxc-rnga - use semicolons rather than commas to separate statements
    hwrng: iproc-rng200 - use semicolons rather than commas to separate statements
    hwrng: stm32 - use semicolons rather than commas to separate statements
    crypto: xor - use ktime for template benchmarking
    crypto: xor - defer load time benchmark to a later time
    crypto: hisilicon/zip - fix the uninitalized 'curr_qm_qp_num'
    crypto: hisilicon/zip - fix the return value when device is busy
    crypto: hisilicon/zip - fix zero length input in GZIP decompress
    crypto: hisilicon/zip - fix the uncleared debug registers
    lib/mpi: Fix unused variable warnings
    crypto: x86/poly1305 - Remove assignments with no effect
    hwrng: npcm - modify readl to readb
    ...

    Linus Torvalds
     

08 Oct, 2020

3 commits

  • The sm2 code was split out of public_key.c in a way that breaks
    modular builds. This patch moves the code back into the same file
    as the original motivation was to minimise ifdefs and that has
    nothing to do with splitting the code out.

    Fixes: 215525639631 ("X.509: support OSCCA SM2-with-SM3...")
    Reported-by: kernel test robot
    Signed-off-by: Herbert Xu

    Herbert Xu
     
  • Clang warns:

    crypto/xor.c:101:4: warning: variable 'count' is uninitialized when used
    here [-Wuninitialized]
    count++;
    ^~~~~
    crypto/xor.c:86:17: note: initialize the variable 'count' to silence
    this warning
    int i, j, count;
    ^
    = 0
    1 warning generated.

    After the refactoring to use ktime that happened in this function, count
    is only assigned, never read. Just remove the variable to get rid of the
    warning.

    Fixes: c055e3eae0f1 ("crypto: xor - use ktime for template benchmarking")
    Link: https://github.com/ClangBuiltLinux/linux/issues/1171
    Signed-off-by: Nathan Chancellor
    Reviewed-by: Douglas Anderson
    Acked-by: Ard Biesheuvel
    Signed-off-by: Herbert Xu

    Nathan Chancellor
     
  • When memory allocation fails, an appropriate return value
    should be set.

    Fixes: 215525639631 ("X.509: support OSCCA SM2-with-SM3 certificate verification")
    Signed-off-by: Tianjia Zhang
    Signed-off-by: Herbert Xu

    Tianjia Zhang
     

02 Oct, 2020

2 commits

  • Currently, we use the jiffies counter as a time source, by staring at
    it until a HZ period elapses, and then staring at it again and perform
    as many XOR operations as we can at the same time until another HZ
    period elapses, so that we can calculate the throughput. This takes
    longer than necessary, and depends on HZ, which is undesirable, since
    HZ is system dependent.

    Let's use the ktime interface instead, and use it to time a fixed
    number of XOR operations, which can be done much faster, and makes
    the time spent depend on the performance level of the system itself,
    which is much more reasonable. To ensure that we have the resolution
    we need even on systems with 32 kHz time sources, while not spending too
    much time in the benchmark on a slow CPU, let's switch to 3 attempts of
    800 repetitions each: that way, we will only misidentify algorithms that
    perform within 10% of each other as the fastest if they are faster than
    10 GB/s to begin with, which is not expected to occur on systems with
    such coarse clocks.

    On ThunderX2, I get the following results:

    Before:

    [72625.956765] xor: measuring software checksum speed
    [72625.993104] 8regs : 10169.000 MB/sec
    [72626.033099] 32regs : 12050.000 MB/sec
    [72626.073095] arm64_neon: 11100.000 MB/sec
    [72626.073097] xor: using function: 32regs (12050.000 MB/sec)

    After:

    [72599.650216] xor: measuring software checksum speed
    [72599.651188] 8regs : 10491 MB/sec
    [72599.652006] 32regs : 12345 MB/sec
    [72599.652871] arm64_neon : 11402 MB/sec
    [72599.652873] xor: using function: 32regs (12345 MB/sec)

    Link: https://lore.kernel.org/linux-crypto/20200923182230.22715-3-ardb@kernel.org/
    Signed-off-by: Ard Biesheuvel
    Reviewed-by: Douglas Anderson
    Signed-off-by: Herbert Xu

    Ard Biesheuvel
     
  • Currently, the XOR module performs its boot time benchmark at core
    initcall time when it is built-in, to ensure that the RAID code can
    make use of it when it is built-in as well.

    Let's defer this to a later stage during the boot, to avoid impacting
    the overall boot time of the system. Instead, just pick an arbitrary
    implementation from the list, and use that as the preliminary default.

    Reviewed-by: Douglas Anderson
    Signed-off-by: Ard Biesheuvel
    Signed-off-by: Herbert Xu

    Ard Biesheuvel
     

25 Sep, 2020

12 commits

  • The digital certificate format based on SM2 crypto algorithm as
    specified in GM/T 0015-2012. It was published by State Encryption
    Management Bureau, China.

    The method of generating Other User Information is defined as
    ZA=H256(ENTLA || IDA || a || b || xG || yG || xA || yA), it also
    specified in https://tools.ietf.org/html/draft-shen-sm2-ecdsa-02.

    The x509 certificate supports SM2-with-SM3 type certificate
    verification. Because certificate verification requires ZA
    in addition to tbs data, ZA also depends on elliptic curve
    parameters and public key data, so you need to access tbs in sig
    and calculate ZA. Finally calculate the digest of the
    signature and complete the verification work. The calculation
    process of ZA is declared in specifications GM/T 0009-2012
    and GM/T 0003.2-2012.

    Signed-off-by: Tianjia Zhang
    Tested-by: Xufeng Zhang
    Reviewed-by: Gilad Ben-Yossef
    Signed-off-by: Herbert Xu

    Tianjia Zhang
     
  • The digital certificate format based on SM2 crypto algorithm as
    specified in GM/T 0015-2012. It was published by State Encryption
    Management Bureau, China.

    This patch adds the OID object identifier defined by OSCCA. The
    x509 certificate supports SM2-with-SM3 type certificate parsing.
    It uses the standard elliptic curve public key, and the sm2
    algorithm signs the hash generated by sm3.

    Signed-off-by: Tianjia Zhang
    Tested-by: Xufeng Zhang
    Reviewed-by: Vitaly Chikunov
    Signed-off-by: Herbert Xu

    Tianjia Zhang
     
  • Add testmgr test vectors for SM2 algorithm. These vectors come
    from `openssl pkeyutl -sign` and libgcrypt.

    Signed-off-by: Tianjia Zhang
    Tested-by: Xufeng Zhang
    Signed-off-by: Herbert Xu

    Tianjia Zhang
     
  • When the 'key' allocation fails, the 'req' will not be released,
    which will cause memory leakage on this path. This patch adds a
    'free_req' tag used to solve this problem, and two new err values
    are added to reflect the real reason of the error.

    Signed-off-by: Tianjia Zhang
    Signed-off-by: Herbert Xu

    Tianjia Zhang
     
  • Some asymmetric algorithms will get different ciphertext after
    each encryption, such as SM2, and let testmgr support the testing
    of such algorithms.

    In struct akcipher_testvec, set c and c_size to be empty, skip
    the comparison of the ciphertext, and compare the decrypted
    plaintext with m to achieve the test purpose.

    Signed-off-by: Tianjia Zhang
    Tested-by: Xufeng Zhang
    Signed-off-by: Herbert Xu

    Tianjia Zhang
     
  • This new module implement the SM2 public key algorithm. It was
    published by State Encryption Management Bureau, China.
    List of specifications for SM2 elliptic curve public key cryptography:

    * GM/T 0003.1-2012
    * GM/T 0003.2-2012
    * GM/T 0003.3-2012
    * GM/T 0003.4-2012
    * GM/T 0003.5-2012

    IETF: https://tools.ietf.org/html/draft-shen-sm2-ecdsa-02
    oscca: http://www.oscca.gov.cn/sca/xxgk/2010-12/17/content_1002386.shtml
    scctc: http://www.gmbz.org.cn/main/bzlb.html

    Signed-off-by: Tianjia Zhang
    Tested-by: Xufeng Zhang
    Signed-off-by: Herbert Xu

    Tianjia Zhang
     
  • Both crypto_sm3_update and crypto_sm3_finup have been
    exported, exporting crypto_sm3_final, to avoid having to
    use crypto_sm3_finup(desc, NULL, 0, dgst) to calculate
    the hash in some cases.

    Signed-off-by: Tianjia Zhang
    Tested-by: Xufeng Zhang
    Signed-off-by: Herbert Xu

    Tianjia Zhang
     
  • Extend the user-space RNG interface:
    1. Add entropy input via ALG_SET_DRBG_ENTROPY setsockopt option;
    2. Add additional data input via sendmsg syscall.

    This allows DRBG to be tested with test vectors, for example for the
    purpose of CAVP testing, which otherwise isn't possible.

    To prevent erroneous use of entropy input, it is hidden under
    CRYPTO_USER_API_RNG_CAVP config option and requires CAP_SYS_ADMIN to
    succeed.

    Signed-off-by: Elena Petrova
    Acked-by: Stephan Müller
    Reviewed-by: Eric Biggers
    Signed-off-by: Herbert Xu

    Elena Petrova
     
  • Some line got only spaces, remove them

    Signed-off-by: Corentin Labbe
    Signed-off-by: Herbert Xu

    Corentin Labbe
     
  • For now, asynchronous raid6 recovery calculate functions are require
    common offset for pages. But, we expect them to support different page
    offset after introducing stripe shared page. Do that by simplily adding
    page offset where each page address are referred. Then, replace the
    old interface with the new ones in raid6 and raid6test.

    Signed-off-by: Yufen Yu
    Signed-off-by: Song Liu

    Yufen Yu
     
  • For now, syndrome compute functions require common offset in the pages
    array. However, we expect them to support different offset when try to
    use shared page in the following. Simplily covert them by adding page
    offset where each page address are referred.

    Since the only caller of async_gen_syndrome() and async_syndrome_val()
    are in raid6, we don't want to reserve the old interface but modify the
    interface directly. After that, replacing old interfaces with new ones
    for raid6 and raid6test.

    Signed-off-by: Yufen Yu
    Signed-off-by: Song Liu

    Yufen Yu
     
  • raid5 will call async_xor() and async_xor_val() to compute xor.
    For now, both of them require the common src/dst page offset. But,
    we want them to support different src/dst page offset for following
    shared page.

    Here, adding two new function async_xor_offs() and async_xor_val_offs()
    respectively for async_xor() and async_xor_val().

    Signed-off-by: Yufen Yu
    Signed-off-by: Song Liu

    Yufen Yu
     

18 Sep, 2020

1 commit

  • We have a few interesting pieces in our cipher museum, which are never
    used internally, and were only ever provided as generic C implementations.

    Unfortunately, we cannot simply remove this code, as we cannot be sure
    that it is not being used via the AF_ALG socket API, however unlikely.

    So let's mark the Anubis, Khazad, SEED and TEA algorithms as obsolete,
    which means they can only be enabled in the build if the socket API is
    enabled in the first place.

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

    Ard Biesheuvel
     

11 Sep, 2020

2 commits

  • Now that crypto/cbc.h is only used by the generic cbc template,
    we can merge it back into the CBC code.

    Signed-off-by: Herbert Xu

    Herbert Xu
     
  • Cryptographic algorithms may have a lifespan that is significantly
    shorter than Linux's, and so we need to start phasing out algorithms
    that are known to be broken, and are no longer fit for general use.

    RC4 (or arc4) is a good example here: there are a few areas where its
    use is still somewhat acceptable, e.g., for interoperability with legacy
    wifi hardware that can only use WEP or TKIP data encryption, but that
    should not imply that, for instance, use of RC4 based EAP-TLS by the WPA
    supplicant for negotiating TKIP keys is equally acceptable, or that RC4
    should remain available as a general purpose cryptographic transform for
    all in-kernel and user space clients.

    Now that all in-kernel users that need to retain support have moved to
    the arc4 library interface, and the known users of ecb(arc4) via the
    socket API (iwd [0] and libell [1][2]) have been updated to switch to a
    local implementation, we can take the next step, and mark the ecb(arc4)
    skcipher as obsolete, and only provide it if the socket API is enabled in
    the first place, as well as provide the option to disable all algorithms
    that have been marked as obsolete.

    [0] https://git.kernel.org/pub/scm/network/wireless/iwd.git/commit/?id=1db8a85a60c64523
    [1] https://git.kernel.org/pub/scm/libs/ell/ell.git/commit/?id=53482ce421b727c2
    [2] https://git.kernel.org/pub/scm/libs/ell/ell.git/commit/?id=7f6a137809d42f6b

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

    Ard Biesheuvel
     

31 Aug, 2020

1 commit

  • Pull crypto fixes from Herbert Xu:

    - fix regression in af_alg that affects iwd

    - restore polling delay in qat

    - fix double free in ingenic on error path

    - fix potential build failure in sa2ul due to missing Kconfig dependency

    * 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6:
    crypto: af_alg - Work around empty control messages without MSG_MORE
    crypto: sa2ul - add Kconfig selects to fix build error
    crypto: ingenic - Drop kfree for memory allocated with devm_kzalloc
    crypto: qat - add delay before polling mailbox

    Linus Torvalds
     

28 Aug, 2020

1 commit


27 Aug, 2020

1 commit

  • The iwd daemon uses libell which sets up the skcipher operation with
    two separate control messages. As the first control message is sent
    without MSG_MORE, it is interpreted as an empty request.

    While libell should be fixed to use MSG_MORE where appropriate, this
    patch works around the bug in the kernel so that existing binaries
    continue to work.

    We will print a warning however.

    A separate issue is that the new kernel code no longer allows the
    control message to be sent twice within the same request. This
    restriction is obviously incompatible with what iwd was doing (first
    setting an IV and then sending the real control message). This
    patch changes the kernel so that this is explicitly allowed.

    Reported-by: Caleb Jorden
    Fixes: f3c802a1f300 ("crypto: algif_aead - Only wake up when...")
    Cc:
    Signed-off-by: Herbert Xu

    Herbert Xu
     

24 Aug, 2020

1 commit

  • Replace the existing /* fall through */ comments and its variants with
    the new pseudo-keyword macro fallthrough[1]. Also, remove unnecessary
    fall-through markings when it is the case.

    [1] https://www.kernel.org/doc/html/v5.7/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through

    Signed-off-by: Gustavo A. R. Silva

    Gustavo A. R. Silva
     

21 Aug, 2020

9 commits


20 Aug, 2020

1 commit

  • The header file algapi.h includes skbuff.h unnecessarily since
    all we need is a forward declaration for struct sk_buff. This
    patch removes that inclusion.

    Unfortunately skbuff.h pulls in a lot of things and drivers over
    the years have come to rely on it so this patch adds a lot of
    missing inclusions that result from this.

    Signed-off-by: Herbert Xu

    Herbert Xu
     

19 Aug, 2020

1 commit

  • This patch moves crypto_yield into internal.h as it's only used
    by internal code such as skcipher. It also adds a missing inclusion
    of sched.h which is required for cond_resched.

    The header files in internal.h have been cleaned up to remove some
    ancient junk and add some more specific inclusions.

    Signed-off-by: Herbert Xu

    Herbert Xu
     

15 Aug, 2020

1 commit


13 Aug, 2020

1 commit

  • In skcipher_accept_parent_nokey() the whole af_alg_ctx structure is
    cleared by memset() after allocation, so add such memset() also to
    aead_accept_parent_nokey() so that the new "init" field is also
    initialized to zero. Without that the initial ctx->init checks might
    randomly return true and cause errors.

    While there, also remove the redundant zero assignments in both
    functions.

    Found via libkcapi testsuite.

    Cc: Stephan Mueller
    Fixes: f3c802a1f300 ("crypto: algif_aead - Only wake up when ctx->more is zero")
    Suggested-by: Herbert Xu
    Signed-off-by: Ondrej Mosnacek
    Signed-off-by: Herbert Xu

    Ondrej Mosnacek
     

08 Aug, 2020

1 commit

  • As said by Linus:

    A symmetric naming is only helpful if it implies symmetries in use.
    Otherwise it's actively misleading.

    In "kzalloc()", the z is meaningful and an important part of what the
    caller wants.

    In "kzfree()", the z is actively detrimental, because maybe in the
    future we really _might_ want to use that "memfill(0xdeadbeef)" or
    something. The "zero" part of the interface isn't even _relevant_.

    The main reason that kzfree() exists is to clear sensitive information
    that should not be leaked to other future users of the same memory
    objects.

    Rename kzfree() to kfree_sensitive() to follow the example of the recently
    added kvfree_sensitive() and make the intention of the API more explicit.
    In addition, memzero_explicit() is used to clear the memory to make sure
    that it won't get optimized away by the compiler.

    The renaming is done by using the command sequence:

    git grep -w --name-only kzfree |\
    xargs sed -i 's/kzfree/kfree_sensitive/'

    followed by some editing of the kfree_sensitive() kerneldoc and adding
    a kzfree backward compatibility macro in slab.h.

    [akpm@linux-foundation.org: fs/crypto/inline_crypt.c needs linux/slab.h]
    [akpm@linux-foundation.org: fix fs/crypto/inline_crypt.c some more]

    Suggested-by: Joe Perches
    Signed-off-by: Waiman Long
    Signed-off-by: Andrew Morton
    Acked-by: David Howells
    Acked-by: Michal Hocko
    Acked-by: Johannes Weiner
    Cc: Jarkko Sakkinen
    Cc: James Morris
    Cc: "Serge E. Hallyn"
    Cc: Joe Perches
    Cc: Matthew Wilcox
    Cc: David Rientjes
    Cc: Dan Carpenter
    Cc: "Jason A . Donenfeld"
    Link: http://lkml.kernel.org/r/20200616154311.12314-3-longman@redhat.com
    Signed-off-by: Linus Torvalds

    Waiman Long