1. 11 6月, 2020 1 次提交
  2. 02 6月, 2020 2 次提交
    • A
      Crypto/chcr: Fixes a coccinile check error · 055be686
      Ayush Sawal 提交于
      This fixes an error observed after running coccinile check.
      drivers/crypto/chelsio/chcr_algo.c:1462:5-8: Unneeded variable:
      "err". Return "0" on line 1480
      
      This line is missed in the commit 567be3a5 ("crypto:
      chelsio - Use multiple txq/rxq per tfm to process the requests").
      
      Fixes: 567be3a5 ("crypto:
      chelsio - Use multiple txq/rxq per tfm to process the requests").
      
      V1->V2
      -Modified subject.
      Signed-off-by: NAyush Sawal <ayush.sawal@chelsio.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      055be686
    • A
      Crypto/chcr: Fixes compilations warnings · f3b140ad
      Ayush Sawal 提交于
      This patch fixes the compilation warnings displayed by sparse tool for
      chcr driver.
      
      V1->V2
      
      Avoid type casting by using get_unaligned_be32() and
      put_unaligned_be16/32() functions.
      
      The key which comes from stack is an u8 byte stream so we store it in
      an unsigned char array(ablkctx->key). The function get_aes_decrypt_key()
      is a used to calculate  the reverse round key for decryption, for this
      operation the key has to be divided into 4 bytes, so to extract 4 bytes
      from an u8 byte stream and store it in an u32 variable, get_aligned_be32()
      is used. Similarly for copying back the key from u32 variable to the
      original u8 key stream, put_aligned_be32() is used.
      Signed-off-by: NAyush Sawal <ayush.sawal@chelsio.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      f3b140ad
  3. 08 5月, 2020 1 次提交
    • E
      crypto: lib/sha1 - remove unnecessary includes of linux/cryptohash.h · 2aaba014
      Eric Biggers 提交于
      <linux/cryptohash.h> sounds very generic and important, like it's the
      header to include if you're doing cryptographic hashing in the kernel.
      But actually it only includes the library implementation of the SHA-1
      compression function (not even the full SHA-1).  This should basically
      never be used anymore; SHA-1 is no longer considered secure, and there
      are much better ways to do cryptographic hashing in the kernel.
      
      Most files that include this header don't actually need it.  So in
      preparation for removing it, remove all these unneeded includes of it.
      Signed-off-by: NEric Biggers <ebiggers@google.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      2aaba014
  4. 07 5月, 2020 5 次提交
  5. 24 4月, 2020 1 次提交
  6. 20 3月, 2020 1 次提交
  7. 06 3月, 2020 2 次提交
  8. 22 2月, 2020 1 次提交
    • A
      crypto: chelsio - Endianess bug in create_authenc_wr · ff462ddf
      Al Viro 提交于
      kctx_len = (ntohl(KEY_CONTEXT_CTX_LEN_V(aeadctx->key_ctx_hdr)) << 4)
                      - sizeof(chcr_req->key_ctx);
      can't possibly be endian-safe.  Look: ->key_ctx_hdr is __be32.  And
      KEY_CONTEXT_CTX_LEN_V is "shift up by 24 bits".  On little-endian hosts it
      sees
      	b0 b1 b2 b3
      in memory, inteprets that into b0 + (b1 << 8) + (b2 << 16) + (b3 << 24),
      shifts up by 24, resulting in b0 << 24, does ntohl (byteswap on l-e),
      gets b0 and shifts that up by 4.  So we get b0 * 16 - sizeof(...).
      
      Sounds reasonable, but on b-e we get
      b3 + (b2 << 8) + (b1 << 16) + (b0 << 24), shift up by 24,
      yielding b3 << 24, do ntohl (no-op on b-e) and then shift up by 4.
      Resulting in b3 << 28 - sizeof(...), i.e. slightly under b3 * 256M.
      
      Then we increase it some more and pass to alloc_skb() as size.
      Somehow I doubt that we really want a quarter-gigabyte skb allocation
      here...
      
      Note that when you are building those values in
      #define  FILL_KEY_CTX_HDR(ck_size, mk_size, d_ck, opad, ctx_len) \
                      htonl(KEY_CONTEXT_VALID_V(1) | \
                            KEY_CONTEXT_CK_SIZE_V((ck_size)) | \
                            KEY_CONTEXT_MK_SIZE_V(mk_size) | \
                            KEY_CONTEXT_DUAL_CK_V((d_ck)) | \
                            KEY_CONTEXT_OPAD_PRESENT_V((opad)) | \
                            KEY_CONTEXT_SALT_PRESENT_V(1) | \
                            KEY_CONTEXT_CTX_LEN_V((ctx_len)))
      ctx_len ends up in the first octet (i.e. b0 in the above), which
      matches the current behaviour on l-e.  If that's the intent, this
      thing should've been
              kctx_len = (KEY_CONTEXT_CTX_LEN_G(ntohl(aeadctx->key_ctx_hdr)) << 4)
                      - sizeof(chcr_req->key_ctx);
      instead - fetch after ntohl() we get (b0 << 24) + (b1 << 16) + (b2 << 8) + b3,
      shift it down by 24 (b0), resuling in b0 * 16 - sizeof(...) both on l-e and
      on b-e.
      
      PS: when sparse warns you about endianness problems, it might be worth checking
      if there really is something wrong.  And I don't mean "slap __force cast on it"...
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      ff462ddf
  9. 13 2月, 2020 2 次提交
  10. 09 1月, 2020 3 次提交
    • E
      crypto: remove propagation of CRYPTO_TFM_RES_* flags · af5034e8
      Eric Biggers 提交于
      The CRYPTO_TFM_RES_* flags were apparently meant as a way to make the
      ->setkey() functions provide more information about errors.  But these
      flags weren't actually being used or tested, and in many cases they
      weren't being set correctly anyway.  So they've now been removed.
      
      Also, if someone ever actually needs to start better distinguishing
      ->setkey() errors (which is somewhat unlikely, as this has been unneeded
      for a long time), we'd be much better off just defining different return
      values, like -EINVAL if the key is invalid for the algorithm vs.
      -EKEYREJECTED if the key was rejected by a policy like "no weak keys".
      That would be much simpler, less error-prone, and easier to test.
      
      So just remove CRYPTO_TFM_RES_MASK and all the unneeded logic that
      propagates these flags around.
      Signed-off-by: NEric Biggers <ebiggers@google.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      af5034e8
    • E
      crypto: remove CRYPTO_TFM_RES_BAD_KEY_LEN · 674f368a
      Eric Biggers 提交于
      The CRYPTO_TFM_RES_BAD_KEY_LEN flag was apparently meant as a way to
      make the ->setkey() functions provide more information about errors.
      
      However, no one actually checks for this flag, which makes it pointless.
      
      Also, many algorithms fail to set this flag when given a bad length key.
      Reviewing just the generic implementations, this is the case for
      aes-fixed-time, cbcmac, echainiv, nhpoly1305, pcrypt, rfc3686, rfc4309,
      rfc7539, rfc7539esp, salsa20, seqiv, and xcbc.  But there are probably
      many more in arch/*/crypto/ and drivers/crypto/.
      
      Some algorithms can even set this flag when the key is the correct
      length.  For example, authenc and authencesn set it when the key payload
      is malformed in any way (not just a bad length), the atmel-sha and ccree
      drivers can set it if a memory allocation fails, and the chelsio driver
      sets it for bad auth tag lengths, not just bad key lengths.
      
      So even if someone actually wanted to start checking this flag (which
      seems unlikely, since it's been unused for a long time), there would be
      a lot of work needed to get it working correctly.  But it would probably
      be much better to go back to the drawing board and just define different
      return values, like -EINVAL if the key is invalid for the algorithm vs.
      -EKEYREJECTED if the key was rejected by a policy like "no weak keys".
      That would be much simpler, less error-prone, and easier to test.
      
      So just remove this flag.
      Signed-off-by: NEric Biggers <ebiggers@google.com>
      Reviewed-by: NHoria Geantă <horia.geanta@nxp.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      674f368a
    • E
      crypto: chelsio - fix writing tfm flags to wrong place · bd56cea0
      Eric Biggers 提交于
      The chelsio crypto driver is casting 'struct crypto_aead' directly to
      'struct crypto_tfm', which is incorrect because the crypto_tfm isn't the
      first field of 'struct crypto_aead'.  Consequently, the calls to
      crypto_tfm_set_flags() are modifying some other field in the struct.
      
      Also, the driver is setting CRYPTO_TFM_RES_BAD_KEY_LEN in
      ->setauthsize(), not just in ->setkey().  This is incorrect since this
      flag is for bad key lengths, not for bad authentication tag lengths.
      
      Fix these bugs by removing the broken crypto_tfm_set_flags() calls from
      ->setauthsize() and by fixing them in ->setkey().
      
      Fixes: 324429d7 ("chcr: Support for Chelsio's Crypto Hardware")
      Cc: <stable@vger.kernel.org> # v4.9+
      Cc: Atul Gupta <atul.gupta@chelsio.com>
      Signed-off-by: NEric Biggers <ebiggers@google.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      bd56cea0
  11. 20 12月, 2019 1 次提交
  12. 17 11月, 2019 1 次提交
    • A
      crypto: chelsio - switch to skcipher API · 7cea6d3e
      Ard Biesheuvel 提交于
      Commit 7a7ffe65 ("crypto: skcipher - Add top-level skcipher interface")
      dated 20 august 2015 introduced the new skcipher API which is supposed to
      replace both blkcipher and ablkcipher. While all consumers of the API have
      been converted long ago, some producers of the ablkcipher remain, forcing
      us to keep the ablkcipher support routines alive, along with the matching
      code to expose [a]blkciphers via the skcipher API.
      
      So switch this driver to the skcipher API, allowing us to finally drop the
      ablkcipher code in the near future.
      
      Cc: Atul Gupta <atul.gupta@chelsio.com>
      Signed-off-by: NArd Biesheuvel <ardb@kernel.org>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      7cea6d3e
  13. 26 7月, 2019 1 次提交
  14. 09 5月, 2019 2 次提交
  15. 25 4月, 2019 1 次提交
    • E
      crypto: shash - remove shash_desc::flags · 877b5691
      Eric Biggers 提交于
      The flags field in 'struct shash_desc' never actually does anything.
      The only ostensibly supported flag is CRYPTO_TFM_REQ_MAY_SLEEP.
      However, no shash algorithm ever sleeps, making this flag a no-op.
      
      With this being the case, inevitably some users who can't sleep wrongly
      pass MAY_SLEEP.  These would all need to be fixed if any shash algorithm
      actually started sleeping.  For example, the shash_ahash_*() functions,
      which wrap a shash algorithm with the ahash API, pass through MAY_SLEEP
      from the ahash API to the shash API.  However, the shash functions are
      called under kmap_atomic(), so actually they're assumed to never sleep.
      
      Even if it turns out that some users do need preemption points while
      hashing large buffers, we could easily provide a helper function
      crypto_shash_update_large() which divides the data into smaller chunks
      and calls crypto_shash_update() and cond_resched() for each chunk.  It's
      not necessary to have a flag in 'struct shash_desc', nor is it necessary
      to make individual shash algorithms aware of this at all.
      
      Therefore, remove shash_desc::flags, and document that the
      crypto_shash_*() functions can be called from any context.
      Signed-off-by: NEric Biggers <ebiggers@google.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      877b5691
  16. 01 2月, 2019 1 次提交
  17. 11 1月, 2019 2 次提交
  18. 23 12月, 2018 6 次提交
  19. 09 11月, 2018 1 次提交
  20. 17 10月, 2018 1 次提交
  21. 28 9月, 2018 2 次提交
  22. 09 7月, 2018 2 次提交