1. 09 11月, 2018 7 次提交
    • Y
      crypto: ccree - add SM3 support · 927574e0
      Yael Chemla 提交于
      Add support for SM3 cipher in CryptoCell 713.
      Signed-off-by: NYael Chemla <yael.chemla@foss.arm.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      927574e0
    • Y
      crypto: ccree - modify set_cipher_mode usage from cc_hash · 18a1dc1f
      Yael Chemla 提交于
      encapsulate set_cipher_mode call with another api,
      preparation for specific hash behavior as needed in later patches
      when SM3 introduced.
      Signed-off-by: NYael Chemla <yael.chemla@foss.arm.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      18a1dc1f
    • Y
      crypto: ccree - adjust hash length to suit certain context specifics · f1e52fd0
      Yael Chemla 提交于
      Adjust hash length such that it will not be fixed and general for all algs.
      Instead make it suitable for certain context information.
      This is preparation for SM3 support.
      Signed-off-by: NYael Chemla <yael.chemla@foss.arm.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      f1e52fd0
    • G
      crypto: ccree - add SM4 support · 9b8d51f8
      Gilad Ben-Yossef 提交于
      Add support for SM4 cipher in CryptoCell 713.
      Signed-off-by: NGilad Ben-Yossef <gilad@benyossef.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      9b8d51f8
    • G
      crypto: ccree - add support for CryptoCell 713 · e40fdb50
      Gilad Ben-Yossef 提交于
      Add support for Arm TrustZone CryptoCell 713.
      Note that this patch just enables using a 713 in backwards compatible mode
      to 712. Newer 713 specific features will follow.
      Signed-off-by: NGilad Ben-Yossef <gilad@benyossef.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      e40fdb50
    • J
      crypto: hisilicon - Fix reference after free of memories on error path · 0b0cf6af
      John Garry 提交于
      coccicheck currently warns of the following issues in the driver:
      drivers/crypto/hisilicon/sec/sec_algs.c:864:51-66: ERROR: reference preceded by free on line 812
      drivers/crypto/hisilicon/sec/sec_algs.c:864:40-49: ERROR: reference preceded by free on line 813
      drivers/crypto/hisilicon/sec/sec_algs.c:861:8-24: ERROR: reference preceded by free on line 814
      drivers/crypto/hisilicon/sec/sec_algs.c:860:41-51: ERROR: reference preceded by free on line 815
      drivers/crypto/hisilicon/sec/sec_algs.c:867:7-18: ERROR: reference preceded by free on line 816
      
      It would appear than on certain error paths that we may attempt reference-
      after-free some memories.
      
      This patch fixes those issues. The solution doesn't look perfect, but
      having same memories free'd possibly from separate functions makes it
      tricky.
      
      Fixes: 915e4e84 ("crypto: hisilicon - SEC security accelerator driver")
      Reviewed-by: NJonathan Cameron <Jonathan.Cameron@huawei.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NJohn Garry <john.garry@huawei.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      0b0cf6af
    • J
      crypto: hisilicon - Fix NULL dereference for same dst and src · 68a031d2
      John Garry 提交于
      When the source and destination addresses for the cipher are the same, we
      will get a NULL dereference from accessing the split destination
      scatterlist memories, as shown:
      
      [   56.565719] tcrypt:
      [   56.565719] testing speed of async ecb(aes) (hisi_sec_aes_ecb) encryption
      [   56.574683] tcrypt: test 0 (128 bit key, 16 byte blocks):
      [   56.587585] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000000
      [   56.596361] Mem abort info:
      [   56.599151]   ESR = 0x96000006
      [   56.602196]   Exception class = DABT (current EL), IL = 32 bits
      [   56.608105]   SET = 0, FnV = 0
      [   56.611149]   EA = 0, S1PTW = 0
      [   56.614280] Data abort info:
      [   56.617151]   ISV = 0, ISS = 0x00000006
      [   56.620976]   CM = 0, WnR = 0
      [   56.623930] user pgtable: 4k pages, 48-bit VAs, pgdp = (____ptrval____)
      [   56.630533] [0000000000000000] pgd=0000041fc7e4d003, pud=0000041fcd9bf003, pmd=0000000000000000
      [   56.639224] Internal error: Oops: 96000006 [#1] PREEMPT SMP
      [   56.644782] Modules linked in: tcrypt(+)
      [   56.648695] CPU: 21 PID: 2326 Comm: insmod Tainted: G        W         4.19.0-rc6-00001-g3fabfb8-dirty #716
      [   56.658420] Hardware name: Huawei Taishan 2280 /D05, BIOS Hisilicon D05 IT17 Nemo 2.0 RC0 10/05/2018
      [   56.667537] pstate: 20000005 (nzCv daif -PAN -UAO)
      [   56.672322] pc : sec_alg_skcipher_crypto+0x318/0x748
      [   56.677274] lr : sec_alg_skcipher_crypto+0x178/0x748
      [   56.682224] sp : ffff0000118e3840
      [   56.685525] x29: ffff0000118e3840 x28: ffff841fbb3f8118
      [   56.690825] x27: 0000000000000000 x26: 0000000000000000
      [   56.696125] x25: ffff841fbb3f8080 x24: ffff841fbadc0018
      [   56.701425] x23: ffff000009119000 x22: ffff841fbb24e280
      [   56.706724] x21: ffff841ff212e780 x20: ffff841ff212e700
      [   56.712023] x19: 0000000000000001 x18: ffffffffffffffff
      [   56.717322] x17: 0000000000000000 x16: 0000000000000000
      [   56.722621] x15: ffff0000091196c8 x14: 72635f7265687069
      [   56.727920] x13: 636b735f676c615f x12: ffff000009119940
      [   56.733219] x11: 0000000000000000 x10: 00000000006080c0
      [   56.738519] x9 : 0000000000000000 x8 : ffff841fbb24e480
      [   56.743818] x7 : ffff841fbb24e500 x6 : ffff841ff00cdcc0
      [   56.749117] x5 : 0000000000000010 x4 : 0000000000000000
      [   56.754416] x3 : ffff841fbb24e380 x2 : ffff841fbb24e480
      [   56.759715] x1 : 0000000000000000 x0 : ffff000008f682c8
      [   56.765016] Process insmod (pid: 2326, stack limit = 0x(____ptrval____))
      [   56.771702] Call trace:
      [   56.774136]  sec_alg_skcipher_crypto+0x318/0x748
      [   56.778740]  sec_alg_skcipher_encrypt+0x10/0x18
      [   56.783259]  test_skcipher_speed+0x2a0/0x700 [tcrypt]
      [   56.788298]  do_test+0x18f8/0x48c8 [tcrypt]
      [   56.792469]  tcrypt_mod_init+0x60/0x1000 [tcrypt]
      [   56.797161]  do_one_initcall+0x5c/0x178
      [   56.800985]  do_init_module+0x58/0x1b4
      [   56.804721]  load_module+0x1da4/0x2150
      [   56.808456]  __se_sys_init_module+0x14c/0x1e8
      [   56.812799]  __arm64_sys_init_module+0x18/0x20
      [   56.817231]  el0_svc_common+0x60/0xe8
      [   56.820880]  el0_svc_handler+0x2c/0x80
      [   56.824615]  el0_svc+0x8/0xc
      [   56.827483] Code: a94c87a3 910b2000 f87b7842 f9004ba2 (b87b7821)
      [   56.833564] ---[ end trace 0f63290590e93d94 ]---
      Segmentation fault
      
      Fix this by only accessing these memories when we have different src and
      dst.
      
      Fixes: 915e4e84 ("crypto: hisilicon - SEC security accelerator driver")
      Reviewed-by: NJonathan Cameron <Jonathan.Cameron@huawei.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NJohn Garry <john.garry@huawei.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      68a031d2
  2. 19 10月, 2018 1 次提交
  3. 17 10月, 2018 4 次提交
  4. 12 10月, 2018 3 次提交
  5. 08 10月, 2018 5 次提交
    • H
      s390/zcrypt: multiple zcrypt device nodes support · 00fab235
      Harald Freudenberger 提交于
      This patch is an extension to the zcrypt device driver to provide,
      support and maintain multiple zcrypt device nodes. The individual
      zcrypt device nodes can be restricted in terms of crypto cards,
      domains and available ioctls. Such a device node can be used as a
      base for container solutions like docker to control and restrict
      the access to crypto resources.
      
      The handling is done with a new sysfs subdir /sys/class/zcrypt.
      Echoing a name (or an empty sting) into the attribute "create" creates
      a new zcrypt device node. In /sys/class/zcrypt a new link will appear
      which points to the sysfs device tree of this new device. The
      attribute files "ioctlmask", "apmask" and "aqmask" in this directory
      are used to customize this new zcrypt device node instance. Finally
      the zcrypt device node can be destroyed by echoing the name into
      /sys/class/zcrypt/destroy. The internal structs holding the device
      info are reference counted - so a destroy will not hard remove a
      device but only marks it as removable when the reference counter drops
      to zero.
      
      The mask values are bitmaps in big endian order starting with bit 0.
      So adapter number 0 is the leftmost bit, mask is 0x8000...  The sysfs
      attributes accept 2 different formats:
      * Absolute hex string starting with 0x like "0x12345678" does set
        the mask starting from left to right. If the given string is shorter
        than the mask it is padded with 0s on the right. If the string is
        longer than the mask an error comes back (EINVAL).
      * Relative format - a concatenation (done with ',') of the
        terms +<bitnr>[-<bitnr>] or -<bitnr>[-<bitnr>]. <bitnr> may be any
        valid number (hex, decimal or octal) in the range 0...255. Here are
        some examples:
          "+0-15,+32,-128,-0xFF"
          "-0-255,+1-16,+0x128"
          "+1,+2,+3,+4,-5,-7-10"
      
      A simple usage examples:
      
        # create new zcrypt device 'my_zcrypt':
        echo "my_zcrypt" >/sys/class/zcrypt/create
        # go into the device dir of this new device
        echo "my_zcrypt" >create
        cd my_zcrypt/
        ls -l
        total 0
        -rw-r--r-- 1 root root 4096 Jul 20 15:23 apmask
        -rw-r--r-- 1 root root 4096 Jul 20 15:23 aqmask
        -r--r--r-- 1 root root 4096 Jul 20 15:23 dev
        -rw-r--r-- 1 root root 4096 Jul 20 15:23 ioctlmask
        lrwxrwxrwx 1 root root    0 Jul 20 15:23 subsystem -> ../../../../class/zcrypt
        ...
        # customize this zcrypt node clone
        # enable only adapter 0 and 2
        echo "0xa0" >apmask
        # enable only domain 6
        echo "+6" >aqmask
        # enable all 256 ioctls
        echo "+0-255" >ioctls
        # now the /dev/my_zcrypt may be used
        # finally destroy it
        echo "my_zcrypt" >/sys/class/zcrypt/destroy
      
      Please note that a very similar 'filtering behavior' also applies to
      the parent z90crypt device. The two mask attributes apmask and aqmask
      in /sys/bus/ap act the very same for the z90crypt device node. However
      the implementation here is totally different as the ap bus acts on
      bind/unbind of queue devices and associated drivers but the effect is
      still the same. So there are two filters active for each additional
      zcrypt device node: The adapter/domain needs to be enabled on the ap
      bus level and it needs to be active on the zcrypt device node level.
      Signed-off-by: NHarald Freudenberger <freude@linux.ibm.com>
      Signed-off-by: NMartin Schwidefsky <schwidefsky@de.ibm.com>
      00fab235
    • A
      crypto: caam/qi2 - avoid double export · 52813ab2
      Arnd Bergmann 提交于
      Both the caam ctrl file and dpaa2_caam export a couple of flags. They
      use an #ifdef check to make sure that each flag is only built once,
      but this fails if they are both loadable modules:
      
      WARNING: drivers/crypto/caam/dpaa2_caam: 'caam_little_end' exported twice. Previous export was in drivers/crypto/caam/caam.ko
      WARNING: drivers/crypto/caam/dpaa2_caam: 'caam_imx' exported twice. Previous export was in drivers/crypto/caam/caam.ko
      
      Change the #ifdef to an IS_ENABLED() check in order to make it work in
      all configurations. It may be better to redesign this aspect of the
      two drivers in a cleaner way.
      
      Fixes: 8d818c10 ("crypto: caam/qi2 - add DPAA2-CAAM driver")
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Acked-by: NHoria Geantă <horia.geanta@nxp.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      52813ab2
    • R
      crypto: mxs-dcp - Fix AES issues · fadd7a6e
      Radu Solea 提交于
      The DCP driver does not obey cryptlen, when doing android CTS this
      results in passing to hardware input stream lengths which are not
      multiple of block size.
      
      Add a check to prevent future erroneous stream lengths from reaching the
      hardware and adjust the scatterlist walking code to obey cryptlen.
      
      Also properly copy-out the IV for chaining.
      Signed-off-by: NRadu Solea <radu.solea@nxp.com>
      Signed-off-by: NFranck LENORMAND <franck.lenormand@nxp.com>
      Signed-off-by: NLeonard Crestez <leonard.crestez@nxp.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      fadd7a6e
    • R
      crypto: mxs-dcp - Fix SHA null hashes and output length · c709eeba
      Radu Solea 提交于
      DCP writes at least 32 bytes in the output buffer instead of hash length
      as documented. Add intermediate buffer to prevent write out of bounds.
      
      When requested to produce null hashes DCP fails to produce valid output.
      Add software workaround to bypass hardware and return valid output.
      Signed-off-by: NRadu Solea <radu.solea@nxp.com>
      Signed-off-by: NLeonard Crestez <leonard.crestez@nxp.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      c709eeba
    • D
      crypto: mxs-dcp - Implement sha import/export · ea9e7568
      Dan Douglass 提交于
      The mxs-dcp driver fails to probe if sha1/sha256 are supported:
      
      [    2.455404] mxs-dcp 80028000.dcp: Failed to register sha1 hash!
      [    2.464042] mxs-dcp: probe of 80028000.dcp failed with error -22
      
      This happens because since commit 8996eafd ("crypto: ahash - ensure
      statesize is non-zero") import/export is mandatory and ahash_prepare_alg
      fails on statesize == 0.
      
      A set of dummy import/export functions were implemented in commit
      9190b6fd ("crypto: mxs-dcp - Add empty hash export and import") but
      statesize is still zero and the driver fails to probe. That change was
      apparently part of some unrelated refactoring.
      
      Fix by actually implementing import/export.
      Signed-off-by: NDan Douglass <dan.douglass@nxp.com>
      Signed-off-by: NLeonard Crestez <leonard.crestez@nxp.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      ea9e7568
  6. 06 10月, 2018 1 次提交
    • K
      treewide: Replace more open-coded allocation size multiplications · 329e0989
      Kees Cook 提交于
      As done treewide earlier, this catches several more open-coded
      allocation size calculations that were added to the kernel during the
      merge window. This performs the following mechanical transformations
      using Coccinelle:
      
      	kvmalloc(a * b, ...) -> kvmalloc_array(a, b, ...)
      	kvzalloc(a * b, ...) -> kvcalloc(a, b, ...)
      	devm_kzalloc(..., a * b, ...) -> devm_kcalloc(..., a, b, ...)
      Signed-off-by: NKees Cook <keescook@chromium.org>
      329e0989
  7. 05 10月, 2018 8 次提交
  8. 03 10月, 2018 1 次提交
  9. 28 9月, 2018 10 次提交