1. 30 Sep, 2022 4 commits
    • lei he's avatar
      crypto: virtio - fix memory-leak · 4a209078
      lei he authored
      Fix memory-leak for virtio-crypto akcipher request, this problem is
      introduced by 59ca6c93(virtio-crypto: implement RSA algorithm).
      The leak can be reproduced and tested with the following script
      inside virtual machine:
      
      #!/bin/bash
      
      LOOP_TIMES=10000
      
      # required module: pkcs8_key_parser, virtio_crypto
      modprobe pkcs8_key_parser # if CONFIG_PKCS8_PRIVATE_KEY_PARSER=m
      modprobe virtio_crypto # if CONFIG_CRYPTO_DEV_VIRTIO=m
      rm -rf /tmp/data
      dd if=/dev/random of=/tmp/data count=1 bs=230
      
      # generate private key and self-signed cert
      openssl req -nodes -x509 -newkey rsa:2048 -keyout key.pem \
      		-outform der -out cert.der  \
      		-subj "/C=CN/ST=GD/L=SZ/O=vihoo/OU=dev/CN=always.com/emailAddress=yy@always.com"
      # convert private key from pem to der
      openssl pkcs8 -in key.pem -topk8 -nocrypt -outform DER -out key.der
      
      # add key
      PRIV_KEY_ID=`cat key.der | keyctl padd asymmetric test_priv_key @s`
      echo "priv key id = "$PRIV_KEY_ID
      PUB_KEY_ID=`cat cert.der | keyctl padd asymmetric test_pub_key @s`
      echo "pub key id = "$PUB_KEY_ID
      
      # query key
      keyctl pkey_query $PRIV_KEY_ID 0
      keyctl pkey_query $PUB_KEY_ID 0
      
      # here we only run pkey_encrypt becasuse it is the fastest interface
      function bench_pub() {
      	keyctl pkey_encrypt $PUB_KEY_ID 0 /tmp/data enc=pkcs1 >/tmp/enc.pub
      }
      
      # do bench_pub in loop to obtain the memory leak
      for (( i = 0; i < ${LOOP_TIMES}; ++i )); do
      	bench_pub
      done
      Signed-off-by: default avatarlei he <helei.sig11@bytedance.com>
      Acked-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Reviewed-by: default avatarGonglei <arei.gonglei@huawei.com>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      4a209078
    • Dan Carpenter's avatar
      crypto: cavium - prevent integer overflow loading firmware · 2526d6bf
      Dan Carpenter authored
      The "code_length" value comes from the firmware file.  If your firmware
      is untrusted realistically there is probably very little you can do to
      protect yourself.  Still we try to limit the damage as much as possible.
      Also Smatch marks any data read from the filesystem as untrusted and
      prints warnings if it not capped correctly.
      
      The "ntohl(ucode->code_length) * 2" multiplication can have an
      integer overflow.
      
      Fixes: 9e2c7d99 ("crypto: cavium - Add Support for Octeon-tx CPT Engine")
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      2526d6bf
    • Dan Carpenter's avatar
      crypto: marvell/octeontx - prevent integer overflows · caca37cf
      Dan Carpenter authored
      The "code_length" value comes from the firmware file.  If your firmware
      is untrusted realistically there is probably very little you can do to
      protect yourself.  Still we try to limit the damage as much as possible.
      Also Smatch marks any data read from the filesystem as untrusted and
      prints warnings if it not capped correctly.
      
      The "code_length * 2" can overflow.  The round_up(ucode_size, 16) +
      sizeof() expression can overflow too.  Prevent these overflows.
      
      Fixes: d9110b0b ("crypto: marvell - add support for OCTEON TX CPT engine")
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      caca37cf
    • Neal Liu's avatar
      crypto: aspeed - fix build error when only CRYPTO_DEV_ASPEED is enabled · f78f6f0b
      Neal Liu authored
      Fix build error within the following configs setting:
      - CONFIG_CRYPTO_DEV_ASPEED=y
      - CONFIG_CRYPTO_DEV_ASPEED_HACE_HASH is not set
      - CONFIG_CRYPTO_DEV_ASPEED_HACE_CRYPTO is not set
      
      Error messages:
      make[4]: *** No rule to make target 'drivers/crypto/aspeed/aspeed_crypto.o'
      , needed by 'drivers/crypto/aspeed/built-in.a'.
      make[4]: Target '__build' not remade because of errors.
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Signed-off-by: default avatarNeal Liu <neal_liu@aspeedtech.com>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      f78f6f0b
  2. 24 Sep, 2022 11 commits
  3. 16 Sep, 2022 15 commits
  4. 09 Sep, 2022 5 commits
  5. 07 Sep, 2022 2 commits
  6. 06 Sep, 2022 1 commit
  7. 02 Sep, 2022 2 commits