Linux cryptographic layer development
 help / color / mirror / Atom feed
* Re: [PATCH 1/1] ARM: dts: NSP: Add crypto (SPU) to dtsi
From: Jon Mason @ 2017-02-22 23:32 UTC (permalink / raw)
  To: Steve Lin
  Cc: Herbert Xu, Rob Herring, Russell King, Ray Jui, Scott Branden,
	Florian Fainelli, Mark Rutland, BCM Kernel Feedback,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	linux-arm-kernel, open list, Rob Rice,
	linux-crypto-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <1487798543-34229-1-git-send-email-steven.lin1-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>

On Wed, Feb 22, 2017 at 4:22 PM, Steve Lin <steven.lin1-dY08KVG/lbpWk0Htik3J/w@public.gmane.org> wrote:
> Adds crypto hardware (SPU) to Northstar Plus device tree file.
>
> Signed-off-by: Steve Lin <steven.lin1-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>

Looks good to me!

Acked-by: Jon Mason <jon.mason-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>

>
> ---
> Code changes for this addition were submitted previously by Rob
> Rice: https://git.kernel.org/cgit/linux/kernel/git/herbert/cryptodev-2.6.git/commit/?id=9d12ba86f818aa9cfe9f01b750336aa441f2ffa2
> ---
>  arch/arm/boot/dts/bcm-nsp.dtsi | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/arch/arm/boot/dts/bcm-nsp.dtsi b/arch/arm/boot/dts/bcm-nsp.dtsi
> index b6142bd..9bac0c8 100644
> --- a/arch/arm/boot/dts/bcm-nsp.dtsi
> +++ b/arch/arm/boot/dts/bcm-nsp.dtsi
> @@ -241,6 +241,12 @@
>                         brcm,nand-has-wp;
>                 };
>
> +               crypto@2f000 {
> +                       compatible = "brcm,spum-nsp-crypto";
> +                       reg = <0x2f000 0x900>;
> +                       mboxes = <&mailbox 0>;
> +               };
> +
>                 gpiob: gpio@30000 {
>                         compatible = "brcm,iproc-nsp-gpio", "brcm,iproc-gpio";
>                         reg = <0x30000 0x50>;
> --
> 2.1.0
>
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* [PATCH] crypto: brcm: fix spelling mistake: "genereate" -> "generate"
From: Colin King @ 2017-02-22 23:51 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller, Rob Rice, Steve Lin, linux-crypto
  Cc: linux-kernel

From: Colin Ian King <colin.king@canonical.com>

trivial fix to spelling mistake in pr_err message

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/crypto/bcm/util.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/crypto/bcm/util.c b/drivers/crypto/bcm/util.c
index 0502f46..430c557 100644
--- a/drivers/crypto/bcm/util.c
+++ b/drivers/crypto/bcm/util.c
@@ -312,7 +312,7 @@ int do_shash(unsigned char *name, unsigned char *result,
 	}
 	rc = crypto_shash_final(&sdesc->shash, result);
 	if (rc)
-		pr_err("%s: Could not genereate %s hash", __func__, name);
+		pr_err("%s: Could not generate %s hash", __func__, name);
 
 do_shash_err:
 	crypto_free_shash(hash);
-- 
2.10.2

^ permalink raw reply related

* [PATCH] crypto: Add ECB dependency for XTS mode
From: Milan Broz @ 2017-02-23  7:38 UTC (permalink / raw)
  To: linux-crypto; +Cc: herbert, nicolasporcel06, Milan Broz
In-Reply-To: <20170221231717.GA7186@nicolas-laptop>

Since the
   commit f1c131b45410a202eb45cc55980a7a9e4e4b4f40
   crypto: xts - Convert to skcipher
the XTS mode is based on ECB, so the mode must select
ECB otherwise it can fail to initialize.

Signed-off-by: Milan Broz <gmazyland@gmail.com>
---
 crypto/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/crypto/Kconfig b/crypto/Kconfig
index 160f08e721cc..9c245eb0dd83 100644
--- a/crypto/Kconfig
+++ b/crypto/Kconfig
@@ -374,6 +374,7 @@ config CRYPTO_XTS
 	select CRYPTO_BLKCIPHER
 	select CRYPTO_MANAGER
 	select CRYPTO_GF128MUL
+	select CRYPTO_ECB
 	help
 	  XTS: IEEE1619/D16 narrow block cipher use with aes-xts-plain,
 	  key size 256, 384 or 512 bits. This implementation currently
-- 
2.11.0

^ permalink raw reply related

* Re: [PATCH 1/2] crypto: vmx - Use skcipher for cbc fallback
From: Herbert Xu @ 2017-02-23 11:20 UTC (permalink / raw)
  To: Paulo Flabiano Smorigo
  Cc: linux-kernel, benh, paulus, mpe, davem, linux-crypto,
	linuxppc-dev, pfsmorigo
In-Reply-To: <20170222180015.27573-1-pfsmorigo@linux.vnet.ibm.com>

Paulo Flabiano Smorigo <pfsmorigo@linux.vnet.ibm.com> wrote:
>
>        fallback =
> -           crypto_alloc_blkcipher(alg, 0, CRYPTO_ALG_NEED_FALLBACK);
> +           crypto_alloc_skcipher(alg, 0, CRYPTO_ALG_NEED_FALLBACK);

You need to add CRYPTO_ALG_ASYNC to the mask in order to ensure
that you get a sync algorithm.

Thanks,
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply

* Re: [PATCH 1/2] crypto: vmx - Use skcipher for cbc fallback
From: Herbert Xu @ 2017-02-23 11:21 UTC (permalink / raw)
  To: Marcelo Cerri; +Cc: linux-crypto
In-Reply-To: <20170222221700.GA19026@gallifrey>

Marcelo Cerri <marcelo.cerri@canonical.com> wrote:
>
> I noticed you used a similar approach in arch/s390/crypto/aes_s390.c
> (commit 64e2680).
> 
> How do you ensure the skcipher operation will not be asynchronous? 

You need to set the bit CRYPTO_ALG_ASYNC in the mask field when
allocating the algorithm to ensure that it's synchronous.

Cheers,
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply

* Re: crypto: hang in crypto_larval_lookup
From: Herbert Xu @ 2017-02-23 11:39 UTC (permalink / raw)
  To: Harald Freudenberger; +Cc: linux-crypto, schwidefsky
In-Reply-To: <20170223111957.GA14000@gondor.apana.org.au>

On Thu, Feb 23, 2017 at 07:19:57PM +0800, Herbert Xu wrote:
> Harald Freudenberger <freude@linux.vnet.ibm.com> wrote:
> > 
> > Hello all
> > 
> > I am currently following a hang at modprobe aes_s390 where
> > crypto_register_alg() does not come back for the xts(aes) algorithm.
> > 
> > The registration is waiting forever in algapi.c crypto_wait_for_test() but
> > the completion never occurs. The cryptomgr is triggering a test via
> > kthread_run to invoce cryptomgr_probe and this thread is calling the
> > create() function of the xts template (file xts.c). Following this thread
> > it comes down to api.c crypto_larval_lookup(name="aes") which is first
> > requesting the module "crypto-aes" via request_module() successful and then
> > blocking forever in requesting the module "crypto-aes-all".
> > 
> > The xts(aes) has at registration CRYPTO_ALG_NEED_FALLBACK flag on.
> > 
> > This problem is seen since about 6 weeks now, first only on the linux next
> > kernel. Now it appers on the 4.10-rc kernels as well. And I still have no
> > idea on how this could be fixed or what's wrong with just the xts
> > registration (ecb, cbc, ctr work fine).
> > 
> > Any ideas or hints?
> 
> Sorry, my fault.  I should've converted all the fallback users of
> the old blkcipher interface over to skcipher before converting the
> core algorithms to skcipher.
> 
> I'll send a patch.

Hmm, actually looks like I did convert this one :)

Do you have ECB enabled in your configuration? XTS doesn't work
without it.  Currently the Kconfig is missing a select on ECB so
it could stop the generic XTS from loading.

However, you seem to be stuck on straight AES which quite strange.
The reason is that s390 crypto registers AES as the first thing so
it should already be available.

The fact that it hangs is expected because it's trying to find
an acceptable AES implementation and in doing so it's loading
s390-aes again.

So we need to get to the bottom of why there is no acceptable
"aes" registered.  Can you check /proc/crypto to see if the simple
aes cipher is correctly registered (passing the selftest) after
it hangs?

You could also print out the type/mask in crypto_larval_lookup
to see if perhaps the caller is asking for something unreasonable.

Thanks,
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply

* Re: crypto: hang in crypto_larval_lookup
From: Herbert Xu @ 2017-02-23 11:19 UTC (permalink / raw)
  To: Harald Freudenberger; +Cc: linux-crypto, schwidefsky
In-Reply-To: <02b80c39-0fd5-b7bd-39da-07e5d71abbad@linux.vnet.ibm.com>

Harald Freudenberger <freude@linux.vnet.ibm.com> wrote:
> 
> Hello all
> 
> I am currently following a hang at modprobe aes_s390 where
> crypto_register_alg() does not come back for the xts(aes) algorithm.
> 
> The registration is waiting forever in algapi.c crypto_wait_for_test() but
> the completion never occurs. The cryptomgr is triggering a test via
> kthread_run to invoce cryptomgr_probe and this thread is calling the
> create() function of the xts template (file xts.c). Following this thread
> it comes down to api.c crypto_larval_lookup(name="aes") which is first
> requesting the module "crypto-aes" via request_module() successful and then
> blocking forever in requesting the module "crypto-aes-all".
> 
> The xts(aes) has at registration CRYPTO_ALG_NEED_FALLBACK flag on.
> 
> This problem is seen since about 6 weeks now, first only on the linux next
> kernel. Now it appers on the 4.10-rc kernels as well. And I still have no
> idea on how this could be fixed or what's wrong with just the xts
> registration (ecb, cbc, ctr work fine).
> 
> Any ideas or hints?

Sorry, my fault.  I should've converted all the fallback users of
the old blkcipher interface over to skcipher before converting the
core algorithms to skcipher.

I'll send a patch.

Cheers,
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply

* Re: crypto/cavium MSI-X fixups
From: Herbert Xu @ 2017-02-23 12:16 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: George Cherian, David Daney, linux-crypto, linux-kernel
In-Reply-To: <20170215071843.30108-1-hch@lst.de>

On Wed, Feb 15, 2017 at 08:18:40AM +0100, Christoph Hellwig wrote:
> Hi George,
> 
> your commit "crypto: cavium - Add Support for Octeon-tx CPT Engine"
> add a new caller to pci_enable_msix.  This API has long been deprecated
> so this series switches it to use pci_alloc_irq_vectors instead.
> 
> Can you please test it and make sure it goes in before the end of the
> merge window so that no more users of the old API hit mainline?

All applied.  Thanks.
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply

* Re: [PATCH] crypto: Add ECB dependency for XTS mode
From: Herbert Xu @ 2017-02-23 12:17 UTC (permalink / raw)
  To: Milan Broz; +Cc: linux-crypto, nicolasporcel06
In-Reply-To: <20170223073826.19066-1-gmazyland@gmail.com>

On Thu, Feb 23, 2017 at 08:38:26AM +0100, Milan Broz wrote:
> Since the
>    commit f1c131b45410a202eb45cc55980a7a9e4e4b4f40
>    crypto: xts - Convert to skcipher
> the XTS mode is based on ECB, so the mode must select
> ECB otherwise it can fail to initialize.
> 
> Signed-off-by: Milan Broz <gmazyland@gmail.com>

Patch applied.  Thanks.
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply

* Crypto Update for 4.11
From: Herbert Xu @ 2017-02-23 12:51 UTC (permalink / raw)
  To: Linus Torvalds, David S. Miller, Linux Kernel Mailing List,
	Linux Crypto Mailing List
In-Reply-To: <20161213132414.GA7898@gondor.apana.org.au>

Hi Linus: 

Here is the crypto update for 4.11:

API:

- Try to catch hash output overrun in testmgr.
- Introduce walksize attribute for batched walking.
- Make crypto_xor() and crypto_inc() alignment agnostic.

Algorithms:

- Add time-invariant AES algorithm.
- Add standalone CBCMAC algorithm.

Drivers:

- Add NEON acclerated chacha20 on ARM/ARM64.
- Expose AES-CTR as synchronous skcipher on ARM64.
- Add scalar AES implementation on ARM64.
- Improve scalar AES implementation on ARM.
- Improve NEON AES implementation on ARM/ARM64.
- Merge CRC32 and PMULL instruction based drivers on ARM64.
- Add NEON acclerated CBCMAC/CMAC/XCBC AES on ARM64.
- Add IPsec AUTHENC implementation in atmel.
- Add Support for Octeon-tx CPT Engine.
- Add Broadcom SPU driver.
- Add MediaTek driver.


Please pull from

git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6.git linus


Ahsan Atta (2):
      crypto: qat - fix indentation
      crypto: qat - fix comments describing adf_disable_sriov()

Andrew Lutomirski (1):
      crypto: testmgr - Allocate only the required output size for hash tests

Ard Biesheuvel (33):
      crypto: arm64/chacha20 - implement NEON version based on SSE3 code
      crypto: arm/chacha20 - implement NEON version based on SSE3 code
      crypto: chacha20 - convert generic and x86 versions to skcipher
      crypto: skcipher - introduce walksize attribute for SIMD algos
      crypto: arm64/aes-blk - expose AES-CTR as synchronous cipher as well
      crypto: arm64/aes - add scalar implementation
      crypto: arm/aes - replace scalar AES cipher
      crypto: arm64/aes - reimplement bit-sliced ARM/NEON implementation for arm64
      crypto: arm/aes - replace bit-sliced OpenSSL NEON code
      crypto: testmgr - use calculated count for number of test vectors
      crypto: arm/aes - avoid reserved 'tt' mnemonic in asm code
      crypto: arm64/aes-blk - honour iv_out requirement in CBC and CTR modes
      crypto: arm/aes-neonbs - fix issue with v2.22 and older assembler
      crypto: arm/aes-ce - remove cra_alignmask
      crypto: arm/chacha20 - remove cra_alignmask
      crypto: arm64/aes-ce-ccm - remove cra_alignmask
      crypto: arm64/aes-blk - remove cra_alignmask
      crypto: arm64/chacha20 - remove cra_alignmask
      crypto: arm64/aes - avoid literals for cross-module symbol references
      crypto: arm64/aes - performance tweak
      crypto: arm64/aes-neon-blk - tweak performance for low end cores
      crypto: arm64/aes - replace scalar fallback with plain NEON fallback
      crypto: arm64/aes - don't use IV buffer to return final keystream block
      crypto: arm/aes - don't use IV buffer to return final keystream block
      crypto: arm64/crc32 - merge CRC32 and PMULL instruction based drivers
      crypto: aes-generic - drop alignment requirement
      crypto: aes - add generic time invariant AES cipher
      crypto: testmgr - add test cases for cbcmac(aes)
      crypto: ccm - switch to separate cbcmac driver
      crypto: arm64/aes - add NEON/Crypto Extensions CBCMAC/CMAC/XCBC driver
      crypto: algapi - make crypto_xor() and crypto_inc() alignment agnostic
      crypto: ccm - honour alignmask of subordinate MAC cipher
      crypto: ccm - drop unnecessary minimum 32-bit alignment

Arnd Bergmann (6):
      crypto: mediatek - remove ARM dependencies
      crypto: mediatek - fix format string for 64-bit builds
      crypto: improve gcc optimization flags for serpent and wp512
      crypto: atmel - refine Kconfig dependencies
      crypto: atmel - fix 64-bit build warnings
      crypto: cavium - fix Kconfig dependencies

Christoph Hellwig (3):
      crypto: cavium - remove dead MSI-X related define
      crypto: cavium - switch to pci_alloc_irq_vectors
      crypto: cavium - switch to pci_alloc_irq_vectors

Colin Ian King (1):
      crypto: mediatek - don't return garbage err on successful return

Corentin LABBE (9):
      crypto: drivers - bring back alphabetical order of Makefile
      hwrng: core - do not use multiple blank lines
      hwrng: core - rewrite better comparison to NULL
      hwrng: core - Rewrite the header
      hwrng: core - Replace asm/uaccess.h by linux/uaccess.h
      hwrng: core - Move hwrng miscdev minor number to include/linux/miscdevice.h
      hwrng: core - remove unused PFX macro
      crypto: bfin_crc - Fix format printing warning
      crypto: bfin_crc - Remove unneeded linux/miscdevice.h include

Cyrille Pitchen (14):
      crypto: atmel-sha - create function to get an Atmel SHA device
      crypto: atmel-sha - update request queue management to make it more generic
      crypto: atmel-sha - make atmel_sha_done_task more generic
      crypto: atmel-sha - redefine SHA_FLAGS_SHA* flags to match SHA_MR_ALGO_SHA*
      crypto: atmel-sha - add atmel_sha_wait_for_data_ready()
      crypto: atmel-sha - add SHA_MR_MODE_IDATAR0
      crypto: atmel-sha - add atmel_sha_cpu_start()
      crypto: atmel-sha - add simple DMA transfers
      crypto: atmel-sha - add support to hmac(shaX)
      crypto: atmel-aes - fix atmel_aes_handle_queue()
      crypto: atmel-authenc - add support to authenc(hmac(shaX), Y(aes)) modes
      crypto: atmel-sha - add verbose debug facilities to print hw register names
      crypto: atmel-sha - fix missing "return" instructions
      crypto: atmel-sha - fix error management in atmel_sha_start()

David Daney (1):
      hwrng: cavium - Use per device name to allow for multiple devices.

Denys Vlasenko (2):
      crypto: x86/crc32c - fix %progbits -> @progbits
      crypto: x86 - make constants readonly, allow linker to merge them

Eric Biggers (1):
      crypto: testmgr - use kmemdup instead of kmalloc+memcpy

Gary R Hook (6):
      crypto: ccp - Fix DMA operations when IOMMU is enabled
      crypto: ccp - Fix double add when creating new DMA command
      crypto: ccp - Set the AES size field for all modes
      crypto: ccp - Change mode for detailed CCP init messages
      crypto: ccp - Update the command queue on errors
      crypto: ccp - Simplify some buffer management routines

George Cherian (4):
      crypto: cavium - Add Support for Octeon-tx CPT Engine
      crypto: cavium - Add the Virtual Function driver for CPT
      crypto: cavium - Enable CPT options crypto for build
      crypto: cavium - cpt_bind_vq_to_grp could return an error code

Gideon Israel Dsouza (1):
      crypto: Replaced gcc specific attributes with macros from compiler.h

Gilad Ben-Yossef (1):
      crypto: doc - fix typo

Giovanni Cabiddu (3):
      crypto: qat - replace hardcoded BIT(0) in vf_isr
      crypto: qat - fix bar discovery for c62x
      crypto: qat - zero esram only for DH85x devices

Gonglei \(Arei\) (2):
      crypto: virtio - support crypto engine framework
      crypto: virtio - adjust priority of algorithm

Harsh Jain (11):
      crypto: chcr - Fix panic on dma_unmap_sg
      crypto: chcr - Check device is allocated before use
      crypto: algif_aead - Fix kernel panic on list_del
      crypto: chcr - Fix key length for RFC4106
      crypto: chcr - Change flow IDs
      crypto: chcr - fix itnull.cocci warnings
      crypto: chcr - Use cipher instead of Block Cipher in gcm setkey
      crypto: chcr - Change cra_flags for cipher algos
      crypto: chcr - Change algo priority
      crypto: chcr - Fix wrong typecasting
      crypto: chcr - Fix Smatch Complaint

Herbert Xu (7):
      Revert "crypto: arm64/ARM: NEON accelerated ChaCha20"
      crypto: aesni - Fix failure when built-in with modular pcbc
      Merge git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux
      crypto: x86/chacha20 - Manually align stack buffer
      Merge git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6

Horia Geantă (11):
      crypto: caam - don't include unneeded headers
      crypto: caam - check return code of dma_set_mask_and_coherent()
      crypto: caam - fix HW S/G in ablkcipher_giv_edesc_alloc()
      crypto: caam - check sg_count() return value
      crypto: caam - replace sg_count() with sg_nents_for_len()
      crypto: caam - use dma_map_sg() return code
      crypto: caam - don't dma_map key for hash algorithms
      crypto: caam - fix DMA API leaks for multiple setkey() calls
      crypto: caam - fix error path for ctx_dma mapping failure
      crypto: caam - abstract ahash request double buffering
      crypto: caam - fix state buffer DMA (un)mapping

Ilya Lesokhin (1):
      crypto: aesni-intel - RFC4106 can zero copy when !PageHighMem

Javier Martinez Canillas (3):
      crypto: picoxcell - Allow driver to build COMPILE_TEST is enabled
      crypto: picoxcell - Remove platform device ID table
      crypto: picoxcell - Remove spacc_is_compatible() wrapper function

Jiri Slaby (1):
      crypto: algif_hash - avoid zero-sized array

Laura Abbott (1):
      crypto: testmgr - Use heap buffer for acomp test input

Li Zhong (1):
      crypto: vmx - disable preemption to enable vsx in aes_ctr.c

Milan Broz (1):
      crypto: xts - Add ECB dependency

Nicolas Iooss (1):
      crypto: img-hash - use dma_data_direction when calling dma_map_sg

Pablo Marcos Oltra (1):
      crypto: qat - modify format of dev top level debugfs entries

Rabin Vincent (2):
      crypto: tcrypt - Add debug prints
      crypto: doc - Fix hash export state information

Rob Rice (3):
      crypto: brcm - DT documentation for Broadcom SPU hardware
      crypto: brcm - Add Broadcom SPU driver
      crypto: brcm - Avoid double free in ahash_finup()

Russell King (1):
      hwrng: omap - update Kconfig help description

Ryder Lee (10):
      crypto: mediatek - Add crypto driver support for some MediaTek chips
      crypto: mediatek - add DT bindings documentation
      crypto: mediatek - move HW control data to transformation context
      crypto: mediatek - fix incorrect data transfer result
      crypto: mediatek - make crypto request queue management more generic
      crypto: mediatek - rework crypto request completion
      crypto: mediatek - regroup functions by usage
      crypto: mediatek - fix typo and indentation
      crypto: mediatek - add support to CTR mode
      crypto: mediatek - add support to GCM mode

Salvatore Benedetto (1):
      crypto: api - Clear CRYPTO_ALG_DEAD bit before registering an alg

Shannon Nelson (4):
      hwrng: n2 - limit error spewage when self-test fails
      hwrng: n2 - add device data descriptions
      hwrng: n2 - support new hardware register layout
      hwrng: n2 - update version info

Tim Chen (1):
      crypto: sha512-mb - Protect sha512 mb ctx mgr access

Tudor Ambarus (1):
      crypto: caam - fix JR IO mapping if one fails

Wei Yongjun (1):
      crypto: mediatek - make symbol of_crypto_id static

Xin Zeng (2):
      crypto: qat - increase number of supported devices

 Documentation/crypto/api-digest.rst                |    2 +-
 Documentation/crypto/api-skcipher.rst              |    2 +-
 .../devicetree/bindings/crypto/brcm,spu-crypto.txt |   22 +
 .../devicetree/bindings/crypto/mediatek-crypto.txt |   27 +
 MAINTAINERS                                        |    7 +
 arch/arm/crypto/Kconfig                            |   27 +-
 arch/arm/crypto/Makefile                           |   11 +-
 arch/arm/crypto/aes-armv4.S                        | 1089 -----
 arch/arm/crypto/aes-ce-core.S                      |   84 +-
 arch/arm/crypto/aes-ce-glue.c                      |   15 +-
 arch/arm/crypto/aes-cipher-core.S                  |  179 +
 arch/arm/crypto/aes-cipher-glue.c                  |   74 +
 arch/arm/crypto/aes-neonbs-core.S                  | 1023 ++++
 arch/arm/crypto/aes-neonbs-glue.c                  |  406 ++
 arch/arm/crypto/aes_glue.c                         |   98 -
 arch/arm/crypto/aes_glue.h                         |   19 -
 arch/arm/crypto/aesbs-core.S_shipped               | 2548 ----------
 arch/arm/crypto/aesbs-glue.c                       |  367 --
 arch/arm/crypto/bsaes-armv7.pl                     | 2471 ----------
 arch/arm/crypto/chacha20-neon-core.S               |  523 +++
 arch/arm/crypto/chacha20-neon-glue.c               |  127 +
 arch/arm64/configs/defconfig                       |    1 -
 arch/arm64/crypto/Kconfig                          |   24 +-
 arch/arm64/crypto/Makefile                         |   13 +-
 arch/arm64/crypto/aes-ce-ccm-glue.c                |    1 -
 arch/arm64/crypto/aes-cipher-core.S                |  110 +
 arch/arm64/crypto/aes-cipher-glue.c                |   69 +
 arch/arm64/crypto/aes-glue.c                       |  281 +-
 arch/arm64/crypto/aes-modes.S                      |   37 +-
 arch/arm64/crypto/aes-neon.S                       |  235 +-
 arch/arm64/crypto/aes-neonbs-core.S                |  972 ++++
 arch/arm64/crypto/aes-neonbs-glue.c                |  439 ++
 arch/arm64/crypto/chacha20-neon-core.S             |  450 ++
 arch/arm64/crypto/chacha20-neon-glue.c             |  126 +
 arch/arm64/crypto/crc32-arm64.c                    |  290 --
 arch/arm64/crypto/crc32-ce-glue.c                  |   49 +-
 arch/x86/crypto/aesni-intel_asm.S                  |   37 +-
 arch/x86/crypto/aesni-intel_avx-x86_64.S           |   32 +-
 arch/x86/crypto/aesni-intel_glue.c                 |   12 +-
 arch/x86/crypto/camellia-aesni-avx-asm_64.S        |    5 +-
 arch/x86/crypto/camellia-aesni-avx2-asm_64.S       |   12 +-
 arch/x86/crypto/cast5-avx-x86_64-asm_64.S          |   14 +-
 arch/x86/crypto/cast6-avx-x86_64-asm_64.S          |   12 +-
 arch/x86/crypto/chacha20-avx2-x86_64.S             |    9 +-
 arch/x86/crypto/chacha20-ssse3-x86_64.S            |    7 +-
 arch/x86/crypto/chacha20_glue.c                    |   70 +-
 arch/x86/crypto/crc32c-pcl-intel-asm_64.S          |    2 +-
 arch/x86/crypto/crct10dif-pcl-asm_64.S             |   14 +-
 arch/x86/crypto/des3_ede-asm_64.S                  |    2 +-
 arch/x86/crypto/ghash-clmulni-intel_asm.S          |    3 +-
 arch/x86/crypto/poly1305-avx2-x86_64.S             |    6 +-
 arch/x86/crypto/poly1305-sse2-x86_64.S             |    6 +-
 arch/x86/crypto/serpent-avx-x86_64-asm_64.S        |    5 +-
 arch/x86/crypto/serpent-avx2-asm_64.S              |    9 +-
 arch/x86/crypto/sha1-mb/sha1_mb_mgr_flush_avx2.S   |    6 +-
 arch/x86/crypto/sha1-mb/sha1_mb_mgr_submit_avx2.S  |    3 +-
 arch/x86/crypto/sha1-mb/sha1_x8_avx2.S             |   15 +-
 arch/x86/crypto/sha1_ni_asm.S                      |    8 +-
 arch/x86/crypto/sha256-avx-asm.S                   |    9 +-
 arch/x86/crypto/sha256-avx2-asm.S                  |    9 +-
 .../crypto/sha256-mb/sha256_mb_mgr_flush_avx2.S    |    6 +-
 .../crypto/sha256-mb/sha256_mb_mgr_submit_avx2.S   |    3 +-
 arch/x86/crypto/sha256-mb/sha256_x8_avx2.S         |    7 +-
 arch/x86/crypto/sha256-ssse3-asm.S                 |    8 +-
 arch/x86/crypto/sha256_ni_asm.S                    |    4 +-
 arch/x86/crypto/sha512-avx-asm.S                   |    9 +-
 arch/x86/crypto/sha512-avx2-asm.S                  |   10 +-
 arch/x86/crypto/sha512-mb/sha512_mb.c              |   64 +-
 .../crypto/sha512-mb/sha512_mb_mgr_flush_avx2.S    |   10 +-
 .../crypto/sha512-mb/sha512_mb_mgr_submit_avx2.S   |    4 +-
 arch/x86/crypto/sha512-mb/sha512_x4_avx2.S         |    4 +-
 arch/x86/crypto/sha512-ssse3-asm.S                 |    9 +-
 arch/x86/crypto/twofish-avx-x86_64-asm_64.S        |    6 +-
 crypto/Kconfig                                     |   19 +
 crypto/Makefile                                    |    3 +
 crypto/ablkcipher.c                                |    5 +-
 crypto/acompress.c                                 |    3 +-
 crypto/aead.c                                      |    3 +-
 crypto/aes_generic.c                               |   64 +-
 crypto/aes_ti.c                                    |  375 ++
 crypto/ahash.c                                     |    3 +-
 crypto/akcipher.c                                  |    3 +-
 crypto/algapi.c                                    |   68 +-
 crypto/algif_hash.c                                |    2 +-
 crypto/blkcipher.c                                 |    7 +-
 crypto/cbc.c                                       |    3 -
 crypto/ccm.c                                       |  386 +-
 crypto/chacha20_generic.c                          |   73 +-
 crypto/cmac.c                                      |    3 +-
 crypto/ctr.c                                       |    2 +-
 crypto/cts.c                                       |    8 +-
 crypto/kpp.c                                       |    3 +-
 crypto/pcbc.c                                      |    6 +-
 crypto/rng.c                                       |    3 +-
 crypto/scompress.c                                 |    3 +-
 crypto/seqiv.c                                     |    2 -
 crypto/shash.c                                     |    9 +-
 crypto/skcipher.c                                  |   23 +-
 crypto/tcrypt.c                                    |    6 +
 crypto/testmgr.c                                   | 1055 +----
 crypto/testmgr.h                                   |  330 +-
 drivers/char/hw_random/Kconfig                     |    4 +-
 drivers/char/hw_random/cavium-rng-vf.c             |    6 +-
 drivers/char/hw_random/core.c                      |   64 +-
 drivers/char/hw_random/n2-drv.c                    |  204 +-
 drivers/char/hw_random/n2rng.h                     |   51 +-
 drivers/crypto/Kconfig                             |   53 +-
 drivers/crypto/Makefile                            |   17 +-
 drivers/crypto/atmel-aes-regs.h                    |   16 +
 drivers/crypto/atmel-aes.c                         |  455 +-
 drivers/crypto/atmel-authenc.h                     |   64 +
 drivers/crypto/atmel-sha-regs.h                    |   20 +
 drivers/crypto/atmel-sha.c                         | 1481 +++++-
 drivers/crypto/atmel-tdes.c                        |   14 +-
 drivers/crypto/bcm/Makefile                        |   15 +
 drivers/crypto/bcm/cipher.c                        | 4963 ++++++++++++++++++++
 drivers/crypto/bcm/cipher.h                        |  483 ++
 drivers/crypto/bcm/spu.c                           | 1251 +++++
 drivers/crypto/bcm/spu.h                           |  287 ++
 drivers/crypto/bcm/spu2.c                          | 1401 ++++++
 drivers/crypto/bcm/spu2.h                          |  228 +
 drivers/crypto/bcm/spum.h                          |  174 +
 drivers/crypto/bcm/util.c                          |  581 +++
 drivers/crypto/bcm/util.h                          |  116 +
 drivers/crypto/bfin_crc.c                          |    6 +-
 drivers/crypto/bfin_crc.h                          |    1 -
 drivers/crypto/caam/caamalg.c                      |  589 +--
 drivers/crypto/caam/caamhash.c                     |  268 +-
 drivers/crypto/caam/ctrl.c                         |   33 +-
 drivers/crypto/caam/error.c                        |    2 -
 drivers/crypto/caam/jr.c                           |   19 +-
 drivers/crypto/caam/sg_sw_sec4.h                   |   11 -
 drivers/crypto/cavium/cpt/Kconfig                  |   17 +
 drivers/crypto/cavium/cpt/Makefile                 |    3 +
 drivers/crypto/cavium/cpt/cpt_common.h             |  156 +
 drivers/crypto/cavium/cpt/cpt_hw_types.h           |  658 +++
 drivers/crypto/cavium/cpt/cptpf.h                  |   64 +
 drivers/crypto/cavium/cpt/cptpf_main.c             |  670 +++
 drivers/crypto/cavium/cpt/cptpf_mbox.c             |  163 +
 drivers/crypto/cavium/cpt/cptvf.h                  |  132 +
 drivers/crypto/cavium/cpt/cptvf_algs.c             |  444 ++
 drivers/crypto/cavium/cpt/cptvf_algs.h             |  113 +
 drivers/crypto/cavium/cpt/cptvf_main.c             |  863 ++++
 drivers/crypto/cavium/cpt/cptvf_mbox.c             |  211 +
 drivers/crypto/cavium/cpt/cptvf_reqmanager.c       |  593 +++
 drivers/crypto/cavium/cpt/request_manager.h        |  147 +
 drivers/crypto/ccp/ccp-dev-v5.c                    |   15 +-
 drivers/crypto/ccp/ccp-dev.h                       |    1 +
 drivers/crypto/ccp/ccp-ops.c                       |  150 +-
 drivers/crypto/chelsio/chcr_algo.c                 |   49 +-
 drivers/crypto/chelsio/chcr_algo.h                 |    9 +-
 drivers/crypto/chelsio/chcr_core.c                 |   11 +-
 drivers/crypto/chelsio/chcr_core.h                 |    1 +
 drivers/crypto/chelsio/chcr_crypto.h               |    2 +-
 drivers/crypto/img-hash.c                          |    4 +-
 drivers/crypto/mediatek/Makefile                   |    2 +
 drivers/crypto/mediatek/mtk-aes.c                  | 1299 +++++
 drivers/crypto/mediatek/mtk-platform.c             |  604 +++
 drivers/crypto/mediatek/mtk-platform.h             |  231 +
 drivers/crypto/mediatek/mtk-regs.h                 |  194 +
 drivers/crypto/mediatek/mtk-sha.c                  | 1435 ++++++
 drivers/crypto/picoxcell_crypto.c                  |   28 +-
 drivers/crypto/qat/qat_c3xxx/adf_drv.c             |    2 +-
 drivers/crypto/qat/qat_c3xxxvf/adf_drv.c           |    2 +-
 drivers/crypto/qat/qat_c62x/adf_drv.c              |    2 +-
 drivers/crypto/qat/qat_c62xvf/adf_drv.c            |    2 +-
 drivers/crypto/qat/qat_common/adf_cfg_common.h     |    1 +
 drivers/crypto/qat/qat_common/adf_common_drv.h     |    4 +-
 drivers/crypto/qat/qat_common/adf_dev_mgr.c        |    2 +-
 drivers/crypto/qat/qat_common/adf_init.c           |   28 +-
 drivers/crypto/qat/qat_common/adf_sriov.c          |    4 +-
 drivers/crypto/qat/qat_common/adf_vf_isr.c         |    4 +-
 drivers/crypto/qat/qat_dh895xcc/adf_drv.c          |    2 +-
 drivers/crypto/qat/qat_dh895xccvf/adf_drv.c        |    2 +-
 drivers/crypto/virtio/Kconfig                      |    1 +
 drivers/crypto/virtio/virtio_crypto_algs.c         |   54 +-
 drivers/crypto/virtio/virtio_crypto_common.h       |   16 +
 drivers/crypto/virtio/virtio_crypto_core.c         |   74 +-
 drivers/crypto/vmx/aes_ctr.c                       |    6 +
 drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h      |    8 +
 include/crypto/algapi.h                            |   20 +-
 include/crypto/chacha20.h                          |    6 +-
 include/crypto/hash.h                              |   18 +-
 include/crypto/internal/skcipher.h                 |    2 +-
 include/crypto/skcipher.h                          |   34 +
 include/linux/compiler-gcc.h                       |    1 +
 include/linux/miscdevice.h                         |    1 +
 187 files changed, 26983 insertions(+), 9598 deletions(-)

Thanks,
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply

* Re: [PATCH 1/2] crypto: vmx - Use skcipher for cbc fallback
From: Marcelo Cerri @ 2017-02-23 13:42 UTC (permalink / raw)
  To: Herbert Xu; +Cc: linux-crypto
In-Reply-To: <20170223112156.GA14038@gondor.apana.org.au>

[-- Attachment #1: Type: text/plain, Size: 778 bytes --]

It makes sense. Thanks for the clarification, Herbert.

One more question: are you planning to convert the ctr template to
skcipher?

-- 
Regards,
Marcelo

On Thu, Feb 23, 2017 at 07:21:56PM +0800, Herbert Xu wrote:
> Marcelo Cerri <marcelo.cerri@canonical.com> wrote:
> >
> > I noticed you used a similar approach in arch/s390/crypto/aes_s390.c
> > (commit 64e2680).
> > 
> > How do you ensure the skcipher operation will not be asynchronous? 
> 
> You need to set the bit CRYPTO_ALG_ASYNC in the mask field when
> allocating the algorithm to ensure that it's synchronous.
> 
> Cheers,
> -- 
> Email: Herbert Xu <herbert@gondor.apana.org.au>
> Home Page: http://gondor.apana.org.au/~herbert/
> PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply

* Re: [PATCH 00/35] treewide trivial patches converting pr_warning to pr_warn
From: Rob Herring @ 2017-02-23 15:28 UTC (permalink / raw)
  To: Joe Perches
  Cc: linux-fbdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-ia64-u79uwXL29TY76Z2rM5mHXA, SH-Linux, Alexander Shishkin,
	nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, Linux-ALSA, dri-devel,
	virtualization-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
	linux-ide-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	sparclinux-u79uwXL29TY76Z2rM5mHXA,
	drbd-dev-cunTk1MwBs8qoQakbn7OcQ,
	linux-scsi-u79uwXL29TY76Z2rM5mHXA, Richard Weinberger,
	sfi-devel-yLnuTTp1/kvcsJTPyzm5gB2eb7JE58TQ,
	amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	linux-acpi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	tboot-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
	oprofile-list-TtF/mJH4Jtrk1uMJSBkQmQ,
	linux-input-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	xen-devel-GuqFBffKawtpuQazS67q72D2FQJk+8+b,
	"linux-media@vger.k
In-Reply-To: <cover.1487314666.git.joe-6d6DIl74uiNBDgjK7y7TUQ@public.gmane.org>

On Fri, Feb 17, 2017 at 1:11 AM, Joe Perches <joe@perches.com> wrote:
> There are ~4300 uses of pr_warn and ~250 uses of the older
> pr_warning in the kernel source tree.
>
> Make the use of pr_warn consistent across all kernel files.
>
> This excludes all files in tools/ as there is a separate
> define pr_warning for that directory tree and pr_warn is
> not used in tools/.
>
> Done with 'sed s/\bpr_warning\b/pr_warn/' and some emacsing.
>
> Miscellanea:
>
> o Coalesce formats and realign arguments
>
> Some files not compiled - no cross-compilers
>
> Joe Perches (35):
>   alpha: Convert remaining uses of pr_warning to pr_warn
>   ARM: ep93xx: Convert remaining uses of pr_warning to pr_warn
>   arm64: Convert remaining uses of pr_warning to pr_warn
>   arch/blackfin: Convert remaining uses of pr_warning to pr_warn
>   ia64: Convert remaining use of pr_warning to pr_warn
>   powerpc: Convert remaining uses of pr_warning to pr_warn
>   sh: Convert remaining uses of pr_warning to pr_warn
>   sparc: Convert remaining use of pr_warning to pr_warn
>   x86: Convert remaining uses of pr_warning to pr_warn
>   drivers/acpi: Convert remaining uses of pr_warning to pr_warn
>   block/drbd: Convert remaining uses of pr_warning to pr_warn
>   gdrom: Convert remaining uses of pr_warning to pr_warn
>   drivers/char: Convert remaining use of pr_warning to pr_warn
>   clocksource: Convert remaining use of pr_warning to pr_warn
>   drivers/crypto: Convert remaining uses of pr_warning to pr_warn
>   fmc: Convert remaining use of pr_warning to pr_warn
>   drivers/gpu: Convert remaining uses of pr_warning to pr_warn
>   drivers/ide: Convert remaining uses of pr_warning to pr_warn
>   drivers/input: Convert remaining uses of pr_warning to pr_warn
>   drivers/isdn: Convert remaining uses of pr_warning to pr_warn
>   drivers/macintosh: Convert remaining uses of pr_warning to pr_warn
>   drivers/media: Convert remaining use of pr_warning to pr_warn
>   drivers/mfd: Convert remaining uses of pr_warning to pr_warn
>   drivers/mtd: Convert remaining uses of pr_warning to pr_warn
>   drivers/of: Convert remaining uses of pr_warning to pr_warn
>   drivers/oprofile: Convert remaining uses of pr_warning to pr_warn
>   drivers/platform: Convert remaining uses of pr_warning to pr_warn
>   drivers/rapidio: Convert remaining use of pr_warning to pr_warn
>   drivers/scsi: Convert remaining use of pr_warning to pr_warn
>   drivers/sh: Convert remaining use of pr_warning to pr_warn
>   drivers/tty: Convert remaining uses of pr_warning to pr_warn
>   drivers/video: Convert remaining uses of pr_warning to pr_warn
>   kernel/trace: Convert remaining uses of pr_warning to pr_warn
>   lib: Convert remaining uses of pr_warning to pr_warn
>   sound/soc: Convert remaining uses of pr_warning to pr_warn

Where's the removal of pr_warning so we don't have more sneak in?

Rob
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply

* Re: crypto: hang in crypto_larval_lookup
From: Harald Freudenberger @ 2017-02-23 16:02 UTC (permalink / raw)
  To: Herbert Xu; +Cc: linux-crypto, schwidefsky
In-Reply-To: <20170223113909.GA14090@gondor.apana.org.au>

On 02/23/2017 12:39 PM, Herbert Xu wrote:
> On Thu, Feb 23, 2017 at 07:19:57PM +0800, Herbert Xu wrote:
>> Harald Freudenberger <freude@linux.vnet.ibm.com> wrote:
>>> Hello all
>>>
>>> I am currently following a hang at modprobe aes_s390 where
>>> crypto_register_alg() does not come back for the xts(aes) algorithm.
>>>
>>> The registration is waiting forever in algapi.c crypto_wait_for_test() but
>>> the completion never occurs. The cryptomgr is triggering a test via
>>> kthread_run to invoce cryptomgr_probe and this thread is calling the
>>> create() function of the xts template (file xts.c). Following this thread
>>> it comes down to api.c crypto_larval_lookup(name="aes") which is first
>>> requesting the module "crypto-aes" via request_module() successful and then
>>> blocking forever in requesting the module "crypto-aes-all".
>>>
>>> The xts(aes) has at registration CRYPTO_ALG_NEED_FALLBACK flag on.
>>>
>>> This problem is seen since about 6 weeks now, first only on the linux next
>>> kernel. Now it appers on the 4.10-rc kernels as well. And I still have no
>>> idea on how this could be fixed or what's wrong with just the xts
>>> registration (ecb, cbc, ctr work fine).
>>>
>>> Any ideas or hints?
>> Sorry, my fault.  I should've converted all the fallback users of
>> the old blkcipher interface over to skcipher before converting the
>> core algorithms to skcipher.
>>
>> I'll send a patch.
> Hmm, actually looks like I did convert this one :)
>
> Do you have ECB enabled in your configuration? XTS doesn't work
> without it.  Currently the Kconfig is missing a select on ECB so
> it could stop the generic XTS from loading.
>
> However, you seem to be stuck on straight AES which quite strange.
> The reason is that s390 crypto registers AES as the first thing so
> it should already be available.
>
> The fact that it hangs is expected because it's trying to find
> an acceptable AES implementation and in doing so it's loading
> s390-aes again.
>
> So we need to get to the bottom of why there is no acceptable
> "aes" registered.  Can you check /proc/crypto to see if the simple
> aes cipher is correctly registered (passing the selftest) after
> it hangs?
>
> You could also print out the type/mask in crypto_larval_lookup
> to see if perhaps the caller is asking for something unreasonable.
>
> Thanks,
Thanks for your help, here is cat /proc/crypto:
name         : xts(aes)
driver       :
module       : kernel
priority     : -1
refcnt       : 3
selftest     : passed
internal     : no
type         : larval
flags        : 0x415

name         : xts(aes)
driver       : xts-aes-s390
module       : kernel
priority     : 400
refcnt       : 1
selftest     : passed
internal     : no
type         : larval
flags        : 0x514

name         : xts(aes)
driver       : xts-aes-s390
module       : aes_s390
priority     : 400
refcnt       : 4
selftest     : unknown
internal     : no
type         : blkcipher
blocksize    : 16
min keysize  : 32
max keysize  : 64
ivsize       : 16
geniv        : <default>

...

name         : ecb(aes)
driver       : ecb(aes-s390)
module       : kernel
priority     : 300
refcnt       : 1
selftest     : passed
internal     : no
type         : blkcipher
blocksize    : 16
min keysize  : 16
max keysize  : 32
ivsize       : 0
geniv        : <default>

name         : ecb(aes)
driver       : ecb-aes-s390
module       : aes_s390
priority     : 400
refcnt       : 1
selftest     : passed
internal     : no
type         : blkcipher
blocksize    : 16
min keysize  : 16
max keysize  : 32
ivsize       : 0
geniv        : <default>

name         : aes
driver       : aes-s390
module       : aes_s390
priority     : 300
refcnt       : 1
selftest     : passed
internal     : no
type         : cipher
blocksize    : 16
min keysize  : 16
max keysize  : 32
...

at the time where the modprobe hangs.

And here is some syslog output (I added some printks for debugging) maybe
it may give you some hints about whats going on during the modprobe:
Feb 23 16:52:08 r35lp49 kernel:   crypto_larval_lookup calling crypto_alg_lookup()
Feb 23 16:52:08 r35lp49 kernel: ->__crypto_alg_lookup(name=aes)
Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_get(alg.cra_name=aes) alg=0000000000f2dd68 alg.cra_refcnt=2
Feb 23 16:52:08 r35lp49 kernel:   crypto_mod_get(alg.cra_name=aes alg=0000000000f2dd68 alg.cra_driver_name=aes-generic alg.cra_module.name=(null))
Feb 23 16:52:08 r35lp49 kernel: <-__crypto_alg_lookup(name=aes) alg=0000000000f2dd68
Feb 23 16:52:08 r35lp49 kernel: <-crypto_larval_lookup(name=aes) alg=0000000000f2dd68
Feb 23 16:52:08 r35lp49 kernel:   crypto_mod_put(alg.cra_name=aes alg=0000000000f2dd68 alg.cra_driver_name=aes-generic, alg.cra_module.name=(null))
Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_put(alg.cra_name=aes alg=0000000000f2dd68 alg.cra_refcnt=2)
Feb 23 16:52:08 r35lp49 kernel:   crypto_mod_put(alg.cra_name=aes alg=000003ff80178480 alg.cra_driver_name=aes-s390, alg.cra_module.name=aes_s390)
Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_put(alg.cra_name=aes alg=000003ff80178480 alg.cra_refcnt=2)
Feb 23 16:52:08 r35lp49 kernel:   crypto_mod_put(alg.cra_name=cbc(aes) alg=00000000b92d3548 alg.cra_driver_name=cbc(aes-s390), alg.cra_module.name=(null))
Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_put(alg.cra_name=cbc(aes) alg=00000000b92d3548 alg.cra_refcnt=4)
Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_get(alg.cra_name=cbc(aes)) alg=00000000b92d3548 alg.cra_refcnt=4
Feb 23 16:52:08 r35lp49 kernel:   crypto_mod_get(alg.cra_name=cbc(aes) alg=00000000b92d3548 alg.cra_driver_name=cbc(aes-s390) alg.cra_module.name=(null))
Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_put(alg.cra_name=cbc(aes) alg=00000000b92d4598 alg.cra_refcnt=1)
Feb 23 16:52:08 r35lp49 kernel:   crypto_mod_put(alg.cra_name=cbc(aes) alg=00000000b92d3548 alg.cra_driver_name=cbc(aes-s390), alg.cra_module.name=(null))
Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_put(alg.cra_name=cbc(aes) alg=00000000b92d3548 alg.cra_refcnt=4)
Feb 23 16:52:08 r35lp49 kernel:   crypto_mod_put(alg.cra_name=cbc(aes) alg=00000000b92d3548 alg.cra_driver_name=cbc(aes-s390), alg.cra_module.name=(null))
Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_put(alg.cra_name=cbc(aes) alg=00000000b92d3548 alg.cra_refcnt=3)
Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_put(alg.cra_name=cbc(aes) alg=00000000b92d3858 alg.cra_refcnt=3)
Feb 23 16:52:08 r35lp49 kernel: <-cryptomgr_probe(data=00000000b8b5d698)
Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_get(alg.cra_name=cbc(aes)) alg=00000000b92d3548 alg.cra_refcnt=3
Feb 23 16:52:08 r35lp49 kernel:   crypto_mod_get(alg.cra_name=cbc(aes) alg=00000000b92d3548 alg.cra_driver_name=cbc(aes-s390) alg.cra_module.name=(null))
Feb 23 16:52:08 r35lp49 kernel:   crypto_mod_put(alg.cra_name=cbc(aes) alg=00000000b92d3858 alg.cra_driver_name=, alg.cra_module.name=(null))
Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_put(alg.cra_name=cbc(aes) alg=00000000b92d3858 alg.cra_refcnt=2)
Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_put(alg.cra_name=cbc(aes) alg=00000000b92d3858 alg.cra_refcnt=1)
Feb 23 16:52:08 r35lp49 kernel:   crypto_mod_put(alg.cra_name=cbc(aes) alg=00000000b92d3548 alg.cra_driver_name=cbc(aes-s390), alg.cra_module.name=(null))
Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_put(alg.cra_name=cbc(aes) alg=00000000b92d3548 alg.cra_refcnt=3)
Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_get(alg.cra_name=aes) alg=000003ff80178480 alg.cra_refcnt=2
Feb 23 16:52:08 r35lp49 kernel:   crypto_mod_get(alg.cra_name=aes alg=000003ff80178480 alg.cra_driver_name=aes-s390 alg.cra_module.name=aes_s390)
Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_mod_lookup(name=aes)
Feb 23 16:52:08 r35lp49 kernel: ->crypto_larval_lookup(name=aes)
Feb 23 16:52:08 r35lp49 kernel:   crypto_larval_lookup calling crypto_alg_lookup()
Feb 23 16:52:08 r35lp49 kernel: ->__crypto_alg_lookup(name=aes)
Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_get(alg.cra_name=aes) alg=0000000000f2dd68 alg.cra_refcnt=2
Feb 23 16:52:08 r35lp49 kernel:   crypto_mod_get(alg.cra_name=aes alg=0000000000f2dd68 alg.cra_driver_name=aes-generic alg.cra_module.name=(null))
Feb 23 16:52:08 r35lp49 kernel: <-__crypto_alg_lookup(name=aes) alg=0000000000f2dd68
Feb 23 16:52:08 r35lp49 kernel: <-crypto_larval_lookup(name=aes) alg=0000000000f2dd68
Feb 23 16:52:08 r35lp49 kernel:   crypto_mod_put(alg.cra_name=aes alg=0000000000f2dd68 alg.cra_driver_name=aes-generic, alg.cra_module.name=(null))
Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_put(alg.cra_name=aes alg=0000000000f2dd68 alg.cra_refcnt=2)
Feb 23 16:52:08 r35lp49 kernel:   crypto_mod_put(alg.cra_name=aes alg=000003ff80178480 alg.cra_driver_name=aes-s390, alg.cra_module.name=aes_s390)
Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_put(alg.cra_name=aes alg=000003ff80178480 alg.cra_refcnt=2)
Feb 23 16:52:08 r35lp49 kernel:   crypto_mod_put(alg.cra_name=cbc(aes) alg=00000000b92d3548 alg.cra_driver_name=cbc(aes-s390), alg.cra_module.name=(null))
Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_put(alg.cra_name=cbc(aes) alg=00000000b92d3548 alg.cra_refcnt=2)
Feb 23 16:52:08 r35lp49 kernel:   crypto_mod_put(alg.cra_name=cbc(aes) alg=000003ff80178240 alg.cra_driver_name=cbc-aes-s390, alg.cra_module.name=aes_s390)
Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_put(alg.cra_name=cbc(aes) alg=000003ff80178240 alg.cra_refcnt=4)
Feb 23 16:52:08 r35lp49 kernel:   crypto_mod_put(alg.cra_name=cbc(aes) alg=000003ff80178240 alg.cra_driver_name=cbc-aes-s390, alg.cra_module.name=aes_s390)
Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_put(alg.cra_name=cbc(aes) alg=000003ff80178240 alg.cra_refcnt=3)
Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_put(alg.cra_name=cbc(aes) alg=00000000b92d4248 alg.cra_refcnt=1)
Feb 23 16:52:08 r35lp49 kernel:   crypto_mod_put(alg.cra_name=cbc(aes) alg=000003ff80178240 alg.cra_driver_name=cbc-aes-s390, alg.cra_module.name=aes_s390)
Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_put(alg.cra_name=cbc(aes) alg=000003ff80178240 alg.cra_refcnt=2)
Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_get(alg.cra_name=xts(aes)) alg=000003ff80178120 alg.cra_refcnt=2
Feb 23 16:52:08 r35lp49 kernel:   crypto_mod_get(alg.cra_name=xts(aes) alg=000003ff80178120 alg.cra_driver_name=xts-aes-s390 alg.cra_module.name=aes_s390)
Feb 23 16:52:08 r35lp49 kernel:   cryptomgr_notify(data=000003ff80178120)
Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_mod_lookup(name=xts-aes-s390)
Feb 23 16:52:08 r35lp49 kernel: ->crypto_larval_lookup(name=xts-aes-s390)
Feb 23 16:52:08 r35lp49 kernel:   crypto_larval_lookup calling crypto_alg_lookup()
Feb 23 16:52:08 r35lp49 kernel: ->__crypto_alg_lookup(name=xts-aes-s390)
Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_get(alg.cra_name=xts(aes)) alg=000003ff80178120 alg.cra_refcnt=3
Feb 23 16:52:08 r35lp49 kernel:   crypto_mod_get(alg.cra_name=xts(aes) alg=000003ff80178120 alg.cra_driver_name=xts-aes-s390 alg.cra_module.name=aes_s390)
Feb 23 16:52:08 r35lp49 kernel: <-__crypto_alg_lookup(name=xts-aes-s390) alg=000003ff80178120
Feb 23 16:52:08 r35lp49 kernel: <-crypto_larval_lookup(name=xts-aes-s390) alg=000003ff80178120
Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_get(alg.cra_name=xts(aes)) alg=000003ff80178120 alg.cra_refcnt=4
Feb 23 16:52:08 r35lp49 kernel:   crypto_mod_get(alg.cra_name=xts(aes) alg=000003ff80178120 alg.cra_driver_name=xts-aes-s390 alg.cra_module.name=aes_s390)
Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_mod_lookup(name=xts(aes))
Feb 23 16:52:08 r35lp49 kernel: ->crypto_larval_lookup(name=xts(aes))
Feb 23 16:52:08 r35lp49 kernel:   crypto_larval_lookup calling crypto_alg_lookup()
Feb 23 16:52:08 r35lp49 kernel: ->__crypto_alg_lookup(name=xts(aes))
Feb 23 16:52:08 r35lp49 kernel: <-__crypto_alg_lookup(name=xts(aes)) alg=          (null)
Feb 23 16:52:08 r35lp49 kernel:   crypto_larval_lookup calling request_module(crypto-xts(aes))
Feb 23 16:52:08 r35lp49 kernel:   crypto_larval_lookup calling crypto_alg_lookup(xts(aes))
Feb 23 16:52:08 r35lp49 kernel: ->__crypto_alg_lookup(name=xts(aes))
Feb 23 16:52:08 r35lp49 kernel: <-__crypto_alg_lookup(name=xts(aes)) alg=          (null)
Feb 23 16:52:08 r35lp49 kernel:   crypto_larval_lookup calling crypto_larval_add(xts(aes))
Feb 23 16:52:08 r35lp49 kernel: ->__crypto_alg_lookup(name=xts(aes))
Feb 23 16:52:08 r35lp49 kernel: <-__crypto_alg_lookup(name=xts(aes)) alg=          (null)
Feb 23 16:52:08 r35lp49 kernel: <-crypto_larval_lookup(name=xts(aes)) alg=00000000b92d48e8
Feb 23 16:52:08 r35lp49 kernel:   cryptomgr_notify(data=00000000b92d48e8)
Feb 23 16:52:08 r35lp49 kernel:   cryptomgr_schedule_probe(larval=00000000b92d48e8 larval.alg=00000000b92d48e8)
Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_get(alg.cra_name=xts(aes)) alg=00000000b92d48e8 alg.cra_refcnt=3
Feb 23 16:52:08 r35lp49 kernel: ->cryptomgr_probe(data=00000000b8b5d698 param.larval=00000000b92d48e8 param.larval.alg=00000000b92d48e8)
Feb 23 16:52:08 r35lp49 kernel: ->__crypto_lookup_template(xts)
Feb 23 16:52:08 r35lp49 kernel: <-__crypto_lookup_template() tmpl=0000000000f2dc00
Feb 23 16:52:08 r35lp49 kernel:   cryptomgr_probe(data=00000000b8b5d698) tmpl=0000000000f2dc00 tmpl.create=00000000006e00b8 err=-11
Feb 23 16:52:08 r35lp49 kernel: ->create(tmpl.name=xts)
Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_mod_lookup(name=aes)
Feb 23 16:52:08 r35lp49 kernel: ->crypto_larval_lookup(name=aes)
Feb 23 16:52:08 r35lp49 kernel:   crypto_larval_lookup calling crypto_alg_lookup()
Feb 23 16:52:08 r35lp49 kernel: ->__crypto_alg_lookup(name=aes)
Feb 23 16:52:08 r35lp49 kernel: <-__crypto_alg_lookup(name=aes) alg=          (null)
Feb 23 16:52:08 r35lp49 kernel:   crypto_larval_lookup calling request_module(crypto-aes)
Feb 23 16:52:08 r35lp49 kernel:   crypto_larval_lookup calling request_module(crypto-aes-all)
--- modprobe aes_s390 hang ---

regards H.Freudenberger

^ permalink raw reply

* Re: [PATCH 00/35] treewide trivial patches converting pr_warning to pr_warn
From: Joe Perches @ 2017-02-23 17:18 UTC (permalink / raw)
  To: Rob Herring
  Cc: linux-fbdev@vger.kernel.org, linux-ia64, SH-Linux,
	Alexander Shishkin, nouveau, Linux-ALSA, dri-devel,
	virtualization, linux-ide@vger.kernel.org,
	linux-mtd@lists.infradead.org, sparclinux, drbd-dev, linux-scsi,
	Richard Weinberger, sfi-devel, amd-gfx,
	linux-acpi@vger.kernel.org, tboot-devel, oprofile-list,
	linux-input@vger.kernel.org, xen-devel, "linux-media@vger.k
In-Reply-To: <CAL_JsqLTaq-QLTqfyDO8EVJYpgeUx1e4J0Fo2NvfFWqVoiVedQ@mail.gmail.com>

On Thu, 2017-02-23 at 09:28 -0600, Rob Herring wrote:
> On Fri, Feb 17, 2017 at 1:11 AM, Joe Perches <joe@perches.com> wrote:
> > There are ~4300 uses of pr_warn and ~250 uses of the older
> > pr_warning in the kernel source tree.
> > 
> > Make the use of pr_warn consistent across all kernel files.
> > 
> > This excludes all files in tools/ as there is a separate
> > define pr_warning for that directory tree and pr_warn is
> > not used in tools/.
> > 
> > Done with 'sed s/\bpr_warning\b/pr_warn/' and some emacsing.
[]
> Where's the removal of pr_warning so we don't have more sneak in?

After all of these actually get applied,
and maybe a cycle or two later, one would
get sent.


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply

* Re: [PATCH 00/35] treewide trivial patches converting pr_warning to pr_warn
From: Emil Velikov @ 2017-02-23 17:41 UTC (permalink / raw)
  To: Joe Perches
  Cc: linux-fbdev@vger.kernel.org, linux-ia64, SH-Linux,
	Alexander Shishkin, ML nouveau, Linux-ALSA, dri-devel,
	open list:VIRTIO GPU DRIVER, linux-ide@vger.kernel.org,
	linux-mtd@lists.infradead.org, sparclinux, drbd-dev, Rob Herring,
	linux-omap, linux-scsi, Richard Weinberger, tboot-devel,
	amd-gfx mailing list, linux-acpi@vger.kernel.org, sfi-devel
In-Reply-To: <1487870304.14159.29.camel@perches.com>

On 23 February 2017 at 17:18, Joe Perches <joe@perches.com> wrote:
> On Thu, 2017-02-23 at 09:28 -0600, Rob Herring wrote:
>> On Fri, Feb 17, 2017 at 1:11 AM, Joe Perches <joe@perches.com> wrote:
>> > There are ~4300 uses of pr_warn and ~250 uses of the older
>> > pr_warning in the kernel source tree.
>> >
>> > Make the use of pr_warn consistent across all kernel files.
>> >
>> > This excludes all files in tools/ as there is a separate
>> > define pr_warning for that directory tree and pr_warn is
>> > not used in tools/.
>> >
>> > Done with 'sed s/\bpr_warning\b/pr_warn/' and some emacsing.
> []
>> Where's the removal of pr_warning so we don't have more sneak in?
>
> After all of these actually get applied,
> and maybe a cycle or two later, one would
> get sent.
>
By which point you'll get a few reincarnation of it. So you'll have to
do the same exercise again :-(

I guess the question is - are you expecting to get the series merged
all together/via one tree ? If not, your plan is perfectly reasonable.
Fwiw in the DRM subsystem, similar cleanups does purge the respective
macros/other with the final commit. But there one can pull the lot in
one go.

Regards,
Emil

^ permalink raw reply

* Re: [PATCH 00/35] treewide trivial patches converting pr_warning to pr_warn
From: Joe Perches @ 2017-02-23 17:53 UTC (permalink / raw)
  To: Emil Velikov
  Cc: linux-fbdev@vger.kernel.org, linux-ia64, SH-Linux,
	Alexander Shishkin, ML nouveau, Linux-ALSA, dri-devel,
	open list:VIRTIO GPU DRIVER, linux-ide@vger.kernel.org,
	linux-mtd@lists.infradead.org, sparclinux, drbd-dev, Rob Herring,
	linux-omap, linux-scsi, Richard Weinberger, tboot-devel,
	amd-gfx mailing list, linux-acpi@vger.kernel.org, sfi-devel
In-Reply-To: <CACvgo50LUm5VSn_F=Dh8kL5zCPpCQDoCyUEL=Z+=1+6hJpfTaw@mail.gmail.com>

On Thu, 2017-02-23 at 17:41 +0000, Emil Velikov wrote:
> On 23 February 2017 at 17:18, Joe Perches <joe@perches.com> wrote:
> > On Thu, 2017-02-23 at 09:28 -0600, Rob Herring wrote:
> > > On Fri, Feb 17, 2017 at 1:11 AM, Joe Perches <joe@perches.com> wrote:
> > > > There are ~4300 uses of pr_warn and ~250 uses of the older
> > > > pr_warning in the kernel source tree.
> > > > 
> > > > Make the use of pr_warn consistent across all kernel files.
> > > > 
> > > > This excludes all files in tools/ as there is a separate
> > > > define pr_warning for that directory tree and pr_warn is
> > > > not used in tools/.
> > > > 
> > > > Done with 'sed s/\bpr_warning\b/pr_warn/' and some emacsing.
> > 
> > []
> > > Where's the removal of pr_warning so we don't have more sneak in?
> > 
> > After all of these actually get applied,
> > and maybe a cycle or two later, one would
> > get sent.
> > 
> 
> By which point you'll get a few reincarnation of it. So you'll have to
> do the same exercise again :-(

Maybe to one or two files.  Not a big deal.

> I guess the question is - are you expecting to get the series merged
> all together/via one tree ?

No.  The only person that could do that effectively is Linus.

> If not, your plan is perfectly reasonable.

^ permalink raw reply

* RE:
From: Qin's Yanjun @ 2017-02-23 15:09 UTC (permalink / raw)



How are you today and your family? I require your attention and honest
co-operation about some issues which i will really want to discuss with you
which.  Looking forward to read from you soon.  

Qin's


______________________________

Sky Silk, http://aknet.kz

^ permalink raw reply

* Re: crypto: hang in crypto_larval_lookup
From: Harald Freudenberger @ 2017-02-24  8:42 UTC (permalink / raw)
  To: Herbert Xu; +Cc: linux-crypto, schwidefsky
In-Reply-To: <d7cc7cd8-3632-2508-9931-a5e0875a54cd@linux.vnet.ibm.com>

On 02/23/2017 05:02 PM, Harald Freudenberger wrote:
> On 02/23/2017 12:39 PM, Herbert Xu wrote:
>> On Thu, Feb 23, 2017 at 07:19:57PM +0800, Herbert Xu wrote:
>>> Harald Freudenberger <freude@linux.vnet.ibm.com> wrote:
>>>> Hello all
>>>>
>>>> I am currently following a hang at modprobe aes_s390 where
>>>> crypto_register_alg() does not come back for the xts(aes) algorithm.
>>>>
>>>> The registration is waiting forever in algapi.c crypto_wait_for_test() but
>>>> the completion never occurs. The cryptomgr is triggering a test via
>>>> kthread_run to invoce cryptomgr_probe and this thread is calling the
>>>> create() function of the xts template (file xts.c). Following this thread
>>>> it comes down to api.c crypto_larval_lookup(name="aes") which is first
>>>> requesting the module "crypto-aes" via request_module() successful and then
>>>> blocking forever in requesting the module "crypto-aes-all".
>>>>
>>>> The xts(aes) has at registration CRYPTO_ALG_NEED_FALLBACK flag on.
>>>>
>>>> This problem is seen since about 6 weeks now, first only on the linux next
>>>> kernel. Now it appers on the 4.10-rc kernels as well. And I still have no
>>>> idea on how this could be fixed or what's wrong with just the xts
>>>> registration (ecb, cbc, ctr work fine).
>>>>
>>>> Any ideas or hints?
>>> Sorry, my fault.  I should've converted all the fallback users of
>>> the old blkcipher interface over to skcipher before converting the
>>> core algorithms to skcipher.
>>>
>>> I'll send a patch.
>> Hmm, actually looks like I did convert this one :)
>>
>> Do you have ECB enabled in your configuration? XTS doesn't work
>> without it.  Currently the Kconfig is missing a select on ECB so
>> it could stop the generic XTS from loading.
>>
>> However, you seem to be stuck on straight AES which quite strange.
>> The reason is that s390 crypto registers AES as the first thing so
>> it should already be available.
>>
>> The fact that it hangs is expected because it's trying to find
>> an acceptable AES implementation and in doing so it's loading
>> s390-aes again.
>>
>> So we need to get to the bottom of why there is no acceptable
>> "aes" registered.  Can you check /proc/crypto to see if the simple
>> aes cipher is correctly registered (passing the selftest) after
>> it hangs?
>>
>> You could also print out the type/mask in crypto_larval_lookup
>> to see if perhaps the caller is asking for something unreasonable.
>>
>> Thanks,
> Thanks for your help, here is cat /proc/crypto:
> name         : xts(aes)
> driver       :
> module       : kernel
> priority     : -1
> refcnt       : 3
> selftest     : passed
> internal     : no
> type         : larval
> flags        : 0x415
>
> name         : xts(aes)
> driver       : xts-aes-s390
> module       : kernel
> priority     : 400
> refcnt       : 1
> selftest     : passed
> internal     : no
> type         : larval
> flags        : 0x514
>
> name         : xts(aes)
> driver       : xts-aes-s390
> module       : aes_s390
> priority     : 400
> refcnt       : 4
> selftest     : unknown
> internal     : no
> type         : blkcipher
> blocksize    : 16
> min keysize  : 32
> max keysize  : 64
> ivsize       : 16
> geniv        : <default>
>
> ...
>
> name         : ecb(aes)
> driver       : ecb(aes-s390)
> module       : kernel
> priority     : 300
> refcnt       : 1
> selftest     : passed
> internal     : no
> type         : blkcipher
> blocksize    : 16
> min keysize  : 16
> max keysize  : 32
> ivsize       : 0
> geniv        : <default>
>
> name         : ecb(aes)
> driver       : ecb-aes-s390
> module       : aes_s390
> priority     : 400
> refcnt       : 1
> selftest     : passed
> internal     : no
> type         : blkcipher
> blocksize    : 16
> min keysize  : 16
> max keysize  : 32
> ivsize       : 0
> geniv        : <default>
>
> name         : aes
> driver       : aes-s390
> module       : aes_s390
> priority     : 300
> refcnt       : 1
> selftest     : passed
> internal     : no
> type         : cipher
> blocksize    : 16
> min keysize  : 16
> max keysize  : 32
> ...
>
> at the time where the modprobe hangs.
>
> And here is some syslog output (I added some printks for debugging) maybe
> it may give you some hints about whats going on during the modprobe:
> Feb 23 16:52:08 r35lp49 kernel:   crypto_larval_lookup calling crypto_alg_lookup()
> Feb 23 16:52:08 r35lp49 kernel: ->__crypto_alg_lookup(name=aes)
> Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_get(alg.cra_name=aes) alg=0000000000f2dd68 alg.cra_refcnt=2
> Feb 23 16:52:08 r35lp49 kernel:   crypto_mod_get(alg.cra_name=aes alg=0000000000f2dd68 alg.cra_driver_name=aes-generic alg.cra_module.name=(null))
> Feb 23 16:52:08 r35lp49 kernel: <-__crypto_alg_lookup(name=aes) alg=0000000000f2dd68
> Feb 23 16:52:08 r35lp49 kernel: <-crypto_larval_lookup(name=aes) alg=0000000000f2dd68
> Feb 23 16:52:08 r35lp49 kernel:   crypto_mod_put(alg.cra_name=aes alg=0000000000f2dd68 alg.cra_driver_name=aes-generic, alg.cra_module.name=(null))
> Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_put(alg.cra_name=aes alg=0000000000f2dd68 alg.cra_refcnt=2)
> Feb 23 16:52:08 r35lp49 kernel:   crypto_mod_put(alg.cra_name=aes alg=000003ff80178480 alg.cra_driver_name=aes-s390, alg.cra_module.name=aes_s390)
> Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_put(alg.cra_name=aes alg=000003ff80178480 alg.cra_refcnt=2)
> Feb 23 16:52:08 r35lp49 kernel:   crypto_mod_put(alg.cra_name=cbc(aes) alg=00000000b92d3548 alg.cra_driver_name=cbc(aes-s390), alg.cra_module.name=(null))
> Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_put(alg.cra_name=cbc(aes) alg=00000000b92d3548 alg.cra_refcnt=4)
> Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_get(alg.cra_name=cbc(aes)) alg=00000000b92d3548 alg.cra_refcnt=4
> Feb 23 16:52:08 r35lp49 kernel:   crypto_mod_get(alg.cra_name=cbc(aes) alg=00000000b92d3548 alg.cra_driver_name=cbc(aes-s390) alg.cra_module.name=(null))
> Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_put(alg.cra_name=cbc(aes) alg=00000000b92d4598 alg.cra_refcnt=1)
> Feb 23 16:52:08 r35lp49 kernel:   crypto_mod_put(alg.cra_name=cbc(aes) alg=00000000b92d3548 alg.cra_driver_name=cbc(aes-s390), alg.cra_module.name=(null))
> Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_put(alg.cra_name=cbc(aes) alg=00000000b92d3548 alg.cra_refcnt=4)
> Feb 23 16:52:08 r35lp49 kernel:   crypto_mod_put(alg.cra_name=cbc(aes) alg=00000000b92d3548 alg.cra_driver_name=cbc(aes-s390), alg.cra_module.name=(null))
> Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_put(alg.cra_name=cbc(aes) alg=00000000b92d3548 alg.cra_refcnt=3)
> Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_put(alg.cra_name=cbc(aes) alg=00000000b92d3858 alg.cra_refcnt=3)
> Feb 23 16:52:08 r35lp49 kernel: <-cryptomgr_probe(data=00000000b8b5d698)
> Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_get(alg.cra_name=cbc(aes)) alg=00000000b92d3548 alg.cra_refcnt=3
> Feb 23 16:52:08 r35lp49 kernel:   crypto_mod_get(alg.cra_name=cbc(aes) alg=00000000b92d3548 alg.cra_driver_name=cbc(aes-s390) alg.cra_module.name=(null))
> Feb 23 16:52:08 r35lp49 kernel:   crypto_mod_put(alg.cra_name=cbc(aes) alg=00000000b92d3858 alg.cra_driver_name=, alg.cra_module.name=(null))
> Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_put(alg.cra_name=cbc(aes) alg=00000000b92d3858 alg.cra_refcnt=2)
> Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_put(alg.cra_name=cbc(aes) alg=00000000b92d3858 alg.cra_refcnt=1)
> Feb 23 16:52:08 r35lp49 kernel:   crypto_mod_put(alg.cra_name=cbc(aes) alg=00000000b92d3548 alg.cra_driver_name=cbc(aes-s390), alg.cra_module.name=(null))
> Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_put(alg.cra_name=cbc(aes) alg=00000000b92d3548 alg.cra_refcnt=3)
> Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_get(alg.cra_name=aes) alg=000003ff80178480 alg.cra_refcnt=2
> Feb 23 16:52:08 r35lp49 kernel:   crypto_mod_get(alg.cra_name=aes alg=000003ff80178480 alg.cra_driver_name=aes-s390 alg.cra_module.name=aes_s390)
> Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_mod_lookup(name=aes)
> Feb 23 16:52:08 r35lp49 kernel: ->crypto_larval_lookup(name=aes)
> Feb 23 16:52:08 r35lp49 kernel:   crypto_larval_lookup calling crypto_alg_lookup()
> Feb 23 16:52:08 r35lp49 kernel: ->__crypto_alg_lookup(name=aes)
> Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_get(alg.cra_name=aes) alg=0000000000f2dd68 alg.cra_refcnt=2
> Feb 23 16:52:08 r35lp49 kernel:   crypto_mod_get(alg.cra_name=aes alg=0000000000f2dd68 alg.cra_driver_name=aes-generic alg.cra_module.name=(null))
> Feb 23 16:52:08 r35lp49 kernel: <-__crypto_alg_lookup(name=aes) alg=0000000000f2dd68
> Feb 23 16:52:08 r35lp49 kernel: <-crypto_larval_lookup(name=aes) alg=0000000000f2dd68
> Feb 23 16:52:08 r35lp49 kernel:   crypto_mod_put(alg.cra_name=aes alg=0000000000f2dd68 alg.cra_driver_name=aes-generic, alg.cra_module.name=(null))
> Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_put(alg.cra_name=aes alg=0000000000f2dd68 alg.cra_refcnt=2)
> Feb 23 16:52:08 r35lp49 kernel:   crypto_mod_put(alg.cra_name=aes alg=000003ff80178480 alg.cra_driver_name=aes-s390, alg.cra_module.name=aes_s390)
> Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_put(alg.cra_name=aes alg=000003ff80178480 alg.cra_refcnt=2)
> Feb 23 16:52:08 r35lp49 kernel:   crypto_mod_put(alg.cra_name=cbc(aes) alg=00000000b92d3548 alg.cra_driver_name=cbc(aes-s390), alg.cra_module.name=(null))
> Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_put(alg.cra_name=cbc(aes) alg=00000000b92d3548 alg.cra_refcnt=2)
> Feb 23 16:52:08 r35lp49 kernel:   crypto_mod_put(alg.cra_name=cbc(aes) alg=000003ff80178240 alg.cra_driver_name=cbc-aes-s390, alg.cra_module.name=aes_s390)
> Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_put(alg.cra_name=cbc(aes) alg=000003ff80178240 alg.cra_refcnt=4)
> Feb 23 16:52:08 r35lp49 kernel:   crypto_mod_put(alg.cra_name=cbc(aes) alg=000003ff80178240 alg.cra_driver_name=cbc-aes-s390, alg.cra_module.name=aes_s390)
> Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_put(alg.cra_name=cbc(aes) alg=000003ff80178240 alg.cra_refcnt=3)
> Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_put(alg.cra_name=cbc(aes) alg=00000000b92d4248 alg.cra_refcnt=1)
> Feb 23 16:52:08 r35lp49 kernel:   crypto_mod_put(alg.cra_name=cbc(aes) alg=000003ff80178240 alg.cra_driver_name=cbc-aes-s390, alg.cra_module.name=aes_s390)
> Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_put(alg.cra_name=cbc(aes) alg=000003ff80178240 alg.cra_refcnt=2)
> Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_get(alg.cra_name=xts(aes)) alg=000003ff80178120 alg.cra_refcnt=2
> Feb 23 16:52:08 r35lp49 kernel:   crypto_mod_get(alg.cra_name=xts(aes) alg=000003ff80178120 alg.cra_driver_name=xts-aes-s390 alg.cra_module.name=aes_s390)
> Feb 23 16:52:08 r35lp49 kernel:   cryptomgr_notify(data=000003ff80178120)
> Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_mod_lookup(name=xts-aes-s390)
> Feb 23 16:52:08 r35lp49 kernel: ->crypto_larval_lookup(name=xts-aes-s390)
> Feb 23 16:52:08 r35lp49 kernel:   crypto_larval_lookup calling crypto_alg_lookup()
> Feb 23 16:52:08 r35lp49 kernel: ->__crypto_alg_lookup(name=xts-aes-s390)
> Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_get(alg.cra_name=xts(aes)) alg=000003ff80178120 alg.cra_refcnt=3
> Feb 23 16:52:08 r35lp49 kernel:   crypto_mod_get(alg.cra_name=xts(aes) alg=000003ff80178120 alg.cra_driver_name=xts-aes-s390 alg.cra_module.name=aes_s390)
> Feb 23 16:52:08 r35lp49 kernel: <-__crypto_alg_lookup(name=xts-aes-s390) alg=000003ff80178120
> Feb 23 16:52:08 r35lp49 kernel: <-crypto_larval_lookup(name=xts-aes-s390) alg=000003ff80178120
> Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_get(alg.cra_name=xts(aes)) alg=000003ff80178120 alg.cra_refcnt=4
> Feb 23 16:52:08 r35lp49 kernel:   crypto_mod_get(alg.cra_name=xts(aes) alg=000003ff80178120 alg.cra_driver_name=xts-aes-s390 alg.cra_module.name=aes_s390)
> Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_mod_lookup(name=xts(aes))
> Feb 23 16:52:08 r35lp49 kernel: ->crypto_larval_lookup(name=xts(aes))
> Feb 23 16:52:08 r35lp49 kernel:   crypto_larval_lookup calling crypto_alg_lookup()
> Feb 23 16:52:08 r35lp49 kernel: ->__crypto_alg_lookup(name=xts(aes))
> Feb 23 16:52:08 r35lp49 kernel: <-__crypto_alg_lookup(name=xts(aes)) alg=          (null)
> Feb 23 16:52:08 r35lp49 kernel:   crypto_larval_lookup calling request_module(crypto-xts(aes))
> Feb 23 16:52:08 r35lp49 kernel:   crypto_larval_lookup calling crypto_alg_lookup(xts(aes))
> Feb 23 16:52:08 r35lp49 kernel: ->__crypto_alg_lookup(name=xts(aes))
> Feb 23 16:52:08 r35lp49 kernel: <-__crypto_alg_lookup(name=xts(aes)) alg=          (null)
> Feb 23 16:52:08 r35lp49 kernel:   crypto_larval_lookup calling crypto_larval_add(xts(aes))
> Feb 23 16:52:08 r35lp49 kernel: ->__crypto_alg_lookup(name=xts(aes))
> Feb 23 16:52:08 r35lp49 kernel: <-__crypto_alg_lookup(name=xts(aes)) alg=          (null)
> Feb 23 16:52:08 r35lp49 kernel: <-crypto_larval_lookup(name=xts(aes)) alg=00000000b92d48e8
> Feb 23 16:52:08 r35lp49 kernel:   cryptomgr_notify(data=00000000b92d48e8)
> Feb 23 16:52:08 r35lp49 kernel:   cryptomgr_schedule_probe(larval=00000000b92d48e8 larval.alg=00000000b92d48e8)
> Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_get(alg.cra_name=xts(aes)) alg=00000000b92d48e8 alg.cra_refcnt=3
> Feb 23 16:52:08 r35lp49 kernel: ->cryptomgr_probe(data=00000000b8b5d698 param.larval=00000000b92d48e8 param.larval.alg=00000000b92d48e8)
> Feb 23 16:52:08 r35lp49 kernel: ->__crypto_lookup_template(xts)
> Feb 23 16:52:08 r35lp49 kernel: <-__crypto_lookup_template() tmpl=0000000000f2dc00
> Feb 23 16:52:08 r35lp49 kernel:   cryptomgr_probe(data=00000000b8b5d698) tmpl=0000000000f2dc00 tmpl.create=00000000006e00b8 err=-11
> Feb 23 16:52:08 r35lp49 kernel: ->create(tmpl.name=xts)
> Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_mod_lookup(name=aes)
> Feb 23 16:52:08 r35lp49 kernel: ->crypto_larval_lookup(name=aes)
> Feb 23 16:52:08 r35lp49 kernel:   crypto_larval_lookup calling crypto_alg_lookup()
> Feb 23 16:52:08 r35lp49 kernel: ->__crypto_alg_lookup(name=aes)
> Feb 23 16:52:08 r35lp49 kernel: <-__crypto_alg_lookup(name=aes) alg=          (null)
> Feb 23 16:52:08 r35lp49 kernel:   crypto_larval_lookup calling request_module(crypto-aes)
> Feb 23 16:52:08 r35lp49 kernel:   crypto_larval_lookup calling request_module(crypto-aes-all)
> --- modprobe aes_s390 hang ---
>
> regards H.Freudenberger
>
Here are the type and mask values:

...
Feb 24 09:28:10 r35lp49 kernel: ->crypto_larval_lookup(name=aes,type=0x00000405,mask=0x0000248c)
Feb 24 09:28:10 r35lp49 kernel:   crypto_larval_lookup calling crypto_alg_lookup(aes,0x00000405,0x0000248c)
Feb 24 09:28:10 r35lp49 kernel: ->__crypto_alg_lookup(name=aes)
Feb 24 09:28:10 r35lp49 kernel: <-__crypto_alg_lookup(name=aes) alg=          (null)
Feb 24 09:28:10 r35lp49 kernel:   crypto_larval_lookup calling request_module(crypto-aes)
Feb 24 09:28:10 r35lp49 kernel:   crypto_larval_lookup calling request_module(crypto-aes-all)

type=0x00000405 = CRYPTO_ALG_TESTED, CRYPTO_ALG_TYPE_SKCIPHER
mask=0x0000248c = CRYPTO_ALG_INTERNAL, CRYPTO_ALG_TESTED, CRYPTO_ALG_ASYNC, CRYPTO_ALG_TYPE_BLKCIPHER_MASK

^ permalink raw reply

* [PATCH 1/2] crypto: CRYPTO_DEV_ATMEL_TDES and CRYPTO_DEV_ATMEL_SHA should depend on HAS_DMA
From: Geert Uytterhoeven @ 2017-02-24 10:27 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller
  Cc: Arnd Bergmann, Matthias Brugger, linux-crypto, linux-kernel,
	Geert Uytterhoeven

If NO_DMA=y:

    ERROR: "bad_dma_ops" [drivers/crypto/atmel-tdes.ko] undefined!
    ERROR: "bad_dma_ops" [drivers/crypto/atmel-sha.ko] undefined!

Add dependencies on HAS_DMA to fix this.

Fixes: ceb4afb3086ab08f ("crypto: atmel - refine Kconfig dependencies")
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
 drivers/crypto/Kconfig | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/crypto/Kconfig b/drivers/crypto/Kconfig
index 2cac445b02fde0f6..69f7fc0dc84dc3b9 100644
--- a/drivers/crypto/Kconfig
+++ b/drivers/crypto/Kconfig
@@ -445,6 +445,7 @@ config CRYPTO_DEV_ATMEL_AES
 
 config CRYPTO_DEV_ATMEL_TDES
 	tristate "Support for Atmel DES/TDES hw accelerator"
+	depends on HAS_DMA
 	depends on ARCH_AT91 || COMPILE_TEST
 	select CRYPTO_DES
 	select CRYPTO_BLKCIPHER
@@ -458,6 +459,7 @@ config CRYPTO_DEV_ATMEL_TDES
 
 config CRYPTO_DEV_ATMEL_SHA
 	tristate "Support for Atmel SHA hw accelerator"
+	depends on HAS_DMA
 	depends on ARCH_AT91 || COMPILE_TEST
 	select CRYPTO_HASH
 	help
-- 
2.7.4

^ permalink raw reply related

* [PATCH 2/2] crypto: CRYPTO_DEV_MEDIATEK should depend on HAS_DMA
From: Geert Uytterhoeven @ 2017-02-24 10:27 UTC (permalink / raw)
  To: Herbert Xu, David S . Miller
  Cc: Arnd Bergmann, Matthias Brugger, linux-crypto, linux-kernel,
	Geert Uytterhoeven
In-Reply-To: <1487932059-31522-1-git-send-email-geert@linux-m68k.org>

If NO_DMA=y:

    ERROR: "bad_dma_ops" [drivers/crypto/mediatek/mtk-crypto.ko] undefined!

Add a dependency on HAS_DMA to fix this.

Fixes: 7dee9f618790d0b7 ("crypto: mediatek - remove ARM dependencies")
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
 drivers/crypto/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/crypto/Kconfig b/drivers/crypto/Kconfig
index 69f7fc0dc84dc3b9..a7ff6e5d0ba92cb7 100644
--- a/drivers/crypto/Kconfig
+++ b/drivers/crypto/Kconfig
@@ -571,6 +571,7 @@ config CRYPTO_DEV_ROCKCHIP
 
 config CRYPTO_DEV_MEDIATEK
 	tristate "MediaTek's EIP97 Cryptographic Engine driver"
+	depends on HAS_DMA
 	depends on (ARM && ARCH_MEDIATEK) || COMPILE_TEST
 	select CRYPTO_AES
 	select CRYPTO_AEAD
-- 
2.7.4

^ permalink raw reply related

* Re: crypto: hang in crypto_larval_lookup
From: Harald Freudenberger @ 2017-02-24 10:32 UTC (permalink / raw)
  To: Herbert Xu; +Cc: linux-crypto, schwidefsky
In-Reply-To: <5e3fb7fe-2229-d098-139a-7d749de8ff73@linux.vnet.ibm.com>

On 02/24/2017 09:42 AM, Harald Freudenberger wrote:
> On 02/23/2017 05:02 PM, Harald Freudenberger wrote:
>> On 02/23/2017 12:39 PM, Herbert Xu wrote:
>>> On Thu, Feb 23, 2017 at 07:19:57PM +0800, Herbert Xu wrote:
>>>> Harald Freudenberger <freude@linux.vnet.ibm.com> wrote:
>>>>> Hello all
>>>>>
>>>>> I am currently following a hang at modprobe aes_s390 where
>>>>> crypto_register_alg() does not come back for the xts(aes) algorithm.
>>>>>
>>>>> The registration is waiting forever in algapi.c crypto_wait_for_test() but
>>>>> the completion never occurs. The cryptomgr is triggering a test via
>>>>> kthread_run to invoce cryptomgr_probe and this thread is calling the
>>>>> create() function of the xts template (file xts.c). Following this thread
>>>>> it comes down to api.c crypto_larval_lookup(name="aes") which is first
>>>>> requesting the module "crypto-aes" via request_module() successful and then
>>>>> blocking forever in requesting the module "crypto-aes-all".
>>>>>
>>>>> The xts(aes) has at registration CRYPTO_ALG_NEED_FALLBACK flag on.
>>>>>
>>>>> This problem is seen since about 6 weeks now, first only on the linux next
>>>>> kernel. Now it appers on the 4.10-rc kernels as well. And I still have no
>>>>> idea on how this could be fixed or what's wrong with just the xts
>>>>> registration (ecb, cbc, ctr work fine).
>>>>>
>>>>> Any ideas or hints?
>>>> Sorry, my fault.  I should've converted all the fallback users of
>>>> the old blkcipher interface over to skcipher before converting the
>>>> core algorithms to skcipher.
>>>>
>>>> I'll send a patch.
>>> Hmm, actually looks like I did convert this one :)
>>>
>>> Do you have ECB enabled in your configuration? XTS doesn't work
>>> without it.  Currently the Kconfig is missing a select on ECB so
>>> it could stop the generic XTS from loading.
>>>
>>> However, you seem to be stuck on straight AES which quite strange.
>>> The reason is that s390 crypto registers AES as the first thing so
>>> it should already be available.
>>>
>>> The fact that it hangs is expected because it's trying to find
>>> an acceptable AES implementation and in doing so it's loading
>>> s390-aes again.
>>>
>>> So we need to get to the bottom of why there is no acceptable
>>> "aes" registered.  Can you check /proc/crypto to see if the simple
>>> aes cipher is correctly registered (passing the selftest) after
>>> it hangs?
>>>
>>> You could also print out the type/mask in crypto_larval_lookup
>>> to see if perhaps the caller is asking for something unreasonable.
>>>
>>> Thanks,
>> Thanks for your help, here is cat /proc/crypto:
>> name         : xts(aes)
>> driver       :
>> module       : kernel
>> priority     : -1
>> refcnt       : 3
>> selftest     : passed
>> internal     : no
>> type         : larval
>> flags        : 0x415
>>
>> name         : xts(aes)
>> driver       : xts-aes-s390
>> module       : kernel
>> priority     : 400
>> refcnt       : 1
>> selftest     : passed
>> internal     : no
>> type         : larval
>> flags        : 0x514
>>
>> name         : xts(aes)
>> driver       : xts-aes-s390
>> module       : aes_s390
>> priority     : 400
>> refcnt       : 4
>> selftest     : unknown
>> internal     : no
>> type         : blkcipher
>> blocksize    : 16
>> min keysize  : 32
>> max keysize  : 64
>> ivsize       : 16
>> geniv        : <default>
>>
>> ...
>>
>> name         : ecb(aes)
>> driver       : ecb(aes-s390)
>> module       : kernel
>> priority     : 300
>> refcnt       : 1
>> selftest     : passed
>> internal     : no
>> type         : blkcipher
>> blocksize    : 16
>> min keysize  : 16
>> max keysize  : 32
>> ivsize       : 0
>> geniv        : <default>
>>
>> name         : ecb(aes)
>> driver       : ecb-aes-s390
>> module       : aes_s390
>> priority     : 400
>> refcnt       : 1
>> selftest     : passed
>> internal     : no
>> type         : blkcipher
>> blocksize    : 16
>> min keysize  : 16
>> max keysize  : 32
>> ivsize       : 0
>> geniv        : <default>
>>
>> name         : aes
>> driver       : aes-s390
>> module       : aes_s390
>> priority     : 300
>> refcnt       : 1
>> selftest     : passed
>> internal     : no
>> type         : cipher
>> blocksize    : 16
>> min keysize  : 16
>> max keysize  : 32
>> ...
>>
>> at the time where the modprobe hangs.
>>
>> And here is some syslog output (I added some printks for debugging) maybe
>> it may give you some hints about whats going on during the modprobe:
>> Feb 23 16:52:08 r35lp49 kernel:   crypto_larval_lookup calling crypto_alg_lookup()
>> Feb 23 16:52:08 r35lp49 kernel: ->__crypto_alg_lookup(name=aes)
>> Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_get(alg.cra_name=aes) alg=0000000000f2dd68 alg.cra_refcnt=2
>> Feb 23 16:52:08 r35lp49 kernel:   crypto_mod_get(alg.cra_name=aes alg=0000000000f2dd68 alg.cra_driver_name=aes-generic alg.cra_module.name=(null))
>> Feb 23 16:52:08 r35lp49 kernel: <-__crypto_alg_lookup(name=aes) alg=0000000000f2dd68
>> Feb 23 16:52:08 r35lp49 kernel: <-crypto_larval_lookup(name=aes) alg=0000000000f2dd68
>> Feb 23 16:52:08 r35lp49 kernel:   crypto_mod_put(alg.cra_name=aes alg=0000000000f2dd68 alg.cra_driver_name=aes-generic, alg.cra_module.name=(null))
>> Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_put(alg.cra_name=aes alg=0000000000f2dd68 alg.cra_refcnt=2)
>> Feb 23 16:52:08 r35lp49 kernel:   crypto_mod_put(alg.cra_name=aes alg=000003ff80178480 alg.cra_driver_name=aes-s390, alg.cra_module.name=aes_s390)
>> Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_put(alg.cra_name=aes alg=000003ff80178480 alg.cra_refcnt=2)
>> Feb 23 16:52:08 r35lp49 kernel:   crypto_mod_put(alg.cra_name=cbc(aes) alg=00000000b92d3548 alg.cra_driver_name=cbc(aes-s390), alg.cra_module.name=(null))
>> Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_put(alg.cra_name=cbc(aes) alg=00000000b92d3548 alg.cra_refcnt=4)
>> Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_get(alg.cra_name=cbc(aes)) alg=00000000b92d3548 alg.cra_refcnt=4
>> Feb 23 16:52:08 r35lp49 kernel:   crypto_mod_get(alg.cra_name=cbc(aes) alg=00000000b92d3548 alg.cra_driver_name=cbc(aes-s390) alg.cra_module.name=(null))
>> Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_put(alg.cra_name=cbc(aes) alg=00000000b92d4598 alg.cra_refcnt=1)
>> Feb 23 16:52:08 r35lp49 kernel:   crypto_mod_put(alg.cra_name=cbc(aes) alg=00000000b92d3548 alg.cra_driver_name=cbc(aes-s390), alg.cra_module.name=(null))
>> Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_put(alg.cra_name=cbc(aes) alg=00000000b92d3548 alg.cra_refcnt=4)
>> Feb 23 16:52:08 r35lp49 kernel:   crypto_mod_put(alg.cra_name=cbc(aes) alg=00000000b92d3548 alg.cra_driver_name=cbc(aes-s390), alg.cra_module.name=(null))
>> Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_put(alg.cra_name=cbc(aes) alg=00000000b92d3548 alg.cra_refcnt=3)
>> Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_put(alg.cra_name=cbc(aes) alg=00000000b92d3858 alg.cra_refcnt=3)
>> Feb 23 16:52:08 r35lp49 kernel: <-cryptomgr_probe(data=00000000b8b5d698)
>> Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_get(alg.cra_name=cbc(aes)) alg=00000000b92d3548 alg.cra_refcnt=3
>> Feb 23 16:52:08 r35lp49 kernel:   crypto_mod_get(alg.cra_name=cbc(aes) alg=00000000b92d3548 alg.cra_driver_name=cbc(aes-s390) alg.cra_module.name=(null))
>> Feb 23 16:52:08 r35lp49 kernel:   crypto_mod_put(alg.cra_name=cbc(aes) alg=00000000b92d3858 alg.cra_driver_name=, alg.cra_module.name=(null))
>> Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_put(alg.cra_name=cbc(aes) alg=00000000b92d3858 alg.cra_refcnt=2)
>> Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_put(alg.cra_name=cbc(aes) alg=00000000b92d3858 alg.cra_refcnt=1)
>> Feb 23 16:52:08 r35lp49 kernel:   crypto_mod_put(alg.cra_name=cbc(aes) alg=00000000b92d3548 alg.cra_driver_name=cbc(aes-s390), alg.cra_module.name=(null))
>> Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_put(alg.cra_name=cbc(aes) alg=00000000b92d3548 alg.cra_refcnt=3)
>> Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_get(alg.cra_name=aes) alg=000003ff80178480 alg.cra_refcnt=2
>> Feb 23 16:52:08 r35lp49 kernel:   crypto_mod_get(alg.cra_name=aes alg=000003ff80178480 alg.cra_driver_name=aes-s390 alg.cra_module.name=aes_s390)
>> Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_mod_lookup(name=aes)
>> Feb 23 16:52:08 r35lp49 kernel: ->crypto_larval_lookup(name=aes)
>> Feb 23 16:52:08 r35lp49 kernel:   crypto_larval_lookup calling crypto_alg_lookup()
>> Feb 23 16:52:08 r35lp49 kernel: ->__crypto_alg_lookup(name=aes)
>> Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_get(alg.cra_name=aes) alg=0000000000f2dd68 alg.cra_refcnt=2
>> Feb 23 16:52:08 r35lp49 kernel:   crypto_mod_get(alg.cra_name=aes alg=0000000000f2dd68 alg.cra_driver_name=aes-generic alg.cra_module.name=(null))
>> Feb 23 16:52:08 r35lp49 kernel: <-__crypto_alg_lookup(name=aes) alg=0000000000f2dd68
>> Feb 23 16:52:08 r35lp49 kernel: <-crypto_larval_lookup(name=aes) alg=0000000000f2dd68
>> Feb 23 16:52:08 r35lp49 kernel:   crypto_mod_put(alg.cra_name=aes alg=0000000000f2dd68 alg.cra_driver_name=aes-generic, alg.cra_module.name=(null))
>> Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_put(alg.cra_name=aes alg=0000000000f2dd68 alg.cra_refcnt=2)
>> Feb 23 16:52:08 r35lp49 kernel:   crypto_mod_put(alg.cra_name=aes alg=000003ff80178480 alg.cra_driver_name=aes-s390, alg.cra_module.name=aes_s390)
>> Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_put(alg.cra_name=aes alg=000003ff80178480 alg.cra_refcnt=2)
>> Feb 23 16:52:08 r35lp49 kernel:   crypto_mod_put(alg.cra_name=cbc(aes) alg=00000000b92d3548 alg.cra_driver_name=cbc(aes-s390), alg.cra_module.name=(null))
>> Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_put(alg.cra_name=cbc(aes) alg=00000000b92d3548 alg.cra_refcnt=2)
>> Feb 23 16:52:08 r35lp49 kernel:   crypto_mod_put(alg.cra_name=cbc(aes) alg=000003ff80178240 alg.cra_driver_name=cbc-aes-s390, alg.cra_module.name=aes_s390)
>> Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_put(alg.cra_name=cbc(aes) alg=000003ff80178240 alg.cra_refcnt=4)
>> Feb 23 16:52:08 r35lp49 kernel:   crypto_mod_put(alg.cra_name=cbc(aes) alg=000003ff80178240 alg.cra_driver_name=cbc-aes-s390, alg.cra_module.name=aes_s390)
>> Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_put(alg.cra_name=cbc(aes) alg=000003ff80178240 alg.cra_refcnt=3)
>> Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_put(alg.cra_name=cbc(aes) alg=00000000b92d4248 alg.cra_refcnt=1)
>> Feb 23 16:52:08 r35lp49 kernel:   crypto_mod_put(alg.cra_name=cbc(aes) alg=000003ff80178240 alg.cra_driver_name=cbc-aes-s390, alg.cra_module.name=aes_s390)
>> Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_put(alg.cra_name=cbc(aes) alg=000003ff80178240 alg.cra_refcnt=2)
>> Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_get(alg.cra_name=xts(aes)) alg=000003ff80178120 alg.cra_refcnt=2
>> Feb 23 16:52:08 r35lp49 kernel:   crypto_mod_get(alg.cra_name=xts(aes) alg=000003ff80178120 alg.cra_driver_name=xts-aes-s390 alg.cra_module.name=aes_s390)
>> Feb 23 16:52:08 r35lp49 kernel:   cryptomgr_notify(data=000003ff80178120)
>> Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_mod_lookup(name=xts-aes-s390)
>> Feb 23 16:52:08 r35lp49 kernel: ->crypto_larval_lookup(name=xts-aes-s390)
>> Feb 23 16:52:08 r35lp49 kernel:   crypto_larval_lookup calling crypto_alg_lookup()
>> Feb 23 16:52:08 r35lp49 kernel: ->__crypto_alg_lookup(name=xts-aes-s390)
>> Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_get(alg.cra_name=xts(aes)) alg=000003ff80178120 alg.cra_refcnt=3
>> Feb 23 16:52:08 r35lp49 kernel:   crypto_mod_get(alg.cra_name=xts(aes) alg=000003ff80178120 alg.cra_driver_name=xts-aes-s390 alg.cra_module.name=aes_s390)
>> Feb 23 16:52:08 r35lp49 kernel: <-__crypto_alg_lookup(name=xts-aes-s390) alg=000003ff80178120
>> Feb 23 16:52:08 r35lp49 kernel: <-crypto_larval_lookup(name=xts-aes-s390) alg=000003ff80178120
>> Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_get(alg.cra_name=xts(aes)) alg=000003ff80178120 alg.cra_refcnt=4
>> Feb 23 16:52:08 r35lp49 kernel:   crypto_mod_get(alg.cra_name=xts(aes) alg=000003ff80178120 alg.cra_driver_name=xts-aes-s390 alg.cra_module.name=aes_s390)
>> Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_mod_lookup(name=xts(aes))
>> Feb 23 16:52:08 r35lp49 kernel: ->crypto_larval_lookup(name=xts(aes))
>> Feb 23 16:52:08 r35lp49 kernel:   crypto_larval_lookup calling crypto_alg_lookup()
>> Feb 23 16:52:08 r35lp49 kernel: ->__crypto_alg_lookup(name=xts(aes))
>> Feb 23 16:52:08 r35lp49 kernel: <-__crypto_alg_lookup(name=xts(aes)) alg=          (null)
>> Feb 23 16:52:08 r35lp49 kernel:   crypto_larval_lookup calling request_module(crypto-xts(aes))
>> Feb 23 16:52:08 r35lp49 kernel:   crypto_larval_lookup calling crypto_alg_lookup(xts(aes))
>> Feb 23 16:52:08 r35lp49 kernel: ->__crypto_alg_lookup(name=xts(aes))
>> Feb 23 16:52:08 r35lp49 kernel: <-__crypto_alg_lookup(name=xts(aes)) alg=          (null)
>> Feb 23 16:52:08 r35lp49 kernel:   crypto_larval_lookup calling crypto_larval_add(xts(aes))
>> Feb 23 16:52:08 r35lp49 kernel: ->__crypto_alg_lookup(name=xts(aes))
>> Feb 23 16:52:08 r35lp49 kernel: <-__crypto_alg_lookup(name=xts(aes)) alg=          (null)
>> Feb 23 16:52:08 r35lp49 kernel: <-crypto_larval_lookup(name=xts(aes)) alg=00000000b92d48e8
>> Feb 23 16:52:08 r35lp49 kernel:   cryptomgr_notify(data=00000000b92d48e8)
>> Feb 23 16:52:08 r35lp49 kernel:   cryptomgr_schedule_probe(larval=00000000b92d48e8 larval.alg=00000000b92d48e8)
>> Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_get(alg.cra_name=xts(aes)) alg=00000000b92d48e8 alg.cra_refcnt=3
>> Feb 23 16:52:08 r35lp49 kernel: ->cryptomgr_probe(data=00000000b8b5d698 param.larval=00000000b92d48e8 param.larval.alg=00000000b92d48e8)
>> Feb 23 16:52:08 r35lp49 kernel: ->__crypto_lookup_template(xts)
>> Feb 23 16:52:08 r35lp49 kernel: <-__crypto_lookup_template() tmpl=0000000000f2dc00
>> Feb 23 16:52:08 r35lp49 kernel:   cryptomgr_probe(data=00000000b8b5d698) tmpl=0000000000f2dc00 tmpl.create=00000000006e00b8 err=-11
>> Feb 23 16:52:08 r35lp49 kernel: ->create(tmpl.name=xts)
>> Feb 23 16:52:08 r35lp49 kernel:   crypto_alg_mod_lookup(name=aes)
>> Feb 23 16:52:08 r35lp49 kernel: ->crypto_larval_lookup(name=aes)
>> Feb 23 16:52:08 r35lp49 kernel:   crypto_larval_lookup calling crypto_alg_lookup()
>> Feb 23 16:52:08 r35lp49 kernel: ->__crypto_alg_lookup(name=aes)
>> Feb 23 16:52:08 r35lp49 kernel: <-__crypto_alg_lookup(name=aes) alg=          (null)
>> Feb 23 16:52:08 r35lp49 kernel:   crypto_larval_lookup calling request_module(crypto-aes)
>> Feb 23 16:52:08 r35lp49 kernel:   crypto_larval_lookup calling request_module(crypto-aes-all)
>> --- modprobe aes_s390 hang ---
>>
>> regards H.Freudenberger
>>
> Here are the type and mask values:
>
> ...
> Feb 24 09:28:10 r35lp49 kernel: ->crypto_larval_lookup(name=aes,type=0x00000405,mask=0x0000248c)
> Feb 24 09:28:10 r35lp49 kernel:   crypto_larval_lookup calling crypto_alg_lookup(aes,0x00000405,0x0000248c)
> Feb 24 09:28:10 r35lp49 kernel: ->__crypto_alg_lookup(name=aes)
> Feb 24 09:28:10 r35lp49 kernel: <-__crypto_alg_lookup(name=aes) alg=          (null)
> Feb 24 09:28:10 r35lp49 kernel:   crypto_larval_lookup calling request_module(crypto-aes)
> Feb 24 09:28:10 r35lp49 kernel:   crypto_larval_lookup calling request_module(crypto-aes-all)
>
> type=0x00000405 = CRYPTO_ALG_TESTED, CRYPTO_ALG_TYPE_SKCIPHER
> mask=0x0000248c = CRYPTO_ALG_INTERNAL, CRYPTO_ALG_TESTED, CRYPTO_ALG_ASYNC, CRYPTO_ALG_TYPE_BLKCIPHER_MASK
>
I catched it: Thanks Herbert for your hint. The aes algorith registers with:
  .cra_flags = CRYPTO_ALG_TYPE_CIPHER |CRYPTO_ALG_NEED_FALLBACK
so later at __crypto_alg_lookup(aes, 0x0405, 0x248c)
this alg is not choosen because the check
  if ((q->cra_flags ^ type) & mask)
is true q->cra_flags = 0x0501 ^ 0x0405 & 0x248x => 0x0004

@Martin, I'll commit a patch asap.

Thanks for your help :-)

regards, H.Freudenberger

^ permalink raw reply

* Re: crypto: hang in crypto_larval_lookup
From: Harald Freudenberger @ 2017-02-24 11:21 UTC (permalink / raw)
  To: Herbert Xu; +Cc: linux-crypto, schwidefsky
In-Reply-To: <66fa483d-9961-728a-b147-46036bd6557b@linux.vnet.ibm.com>

On 02/24/2017 11:32 AM, Harald Freudenberger wrote:
> On 02/24/2017 09:42 AM, Harald Freudenberger wrote:
...
>> ...
>> Feb 24 09:28:10 r35lp49 kernel: ->crypto_larval_lookup(name=aes,type=0x00000405,mask=0x0000248c)
>> Feb 24 09:28:10 r35lp49 kernel:   crypto_larval_lookup calling crypto_alg_lookup(aes,0x00000405,0x0000248c)
>> Feb 24 09:28:10 r35lp49 kernel: ->__crypto_alg_lookup(name=aes)
>> Feb 24 09:28:10 r35lp49 kernel: <-__crypto_alg_lookup(name=aes) alg=          (null)
>> Feb 24 09:28:10 r35lp49 kernel:   crypto_larval_lookup calling request_module(crypto-aes)
>> Feb 24 09:28:10 r35lp49 kernel:   crypto_larval_lookup calling request_module(crypto-aes-all)
>>
>> type=0x00000405 = CRYPTO_ALG_TESTED, CRYPTO_ALG_TYPE_SKCIPHER
>> mask=0x0000248c = CRYPTO_ALG_INTERNAL, CRYPTO_ALG_TESTED, CRYPTO_ALG_ASYNC, CRYPTO_ALG_TYPE_BLKCIPHER_MASK
>>
> I catched it: Thanks Herbert for your hint. The aes algorith registers with:
>   .cra_flags = CRYPTO_ALG_TYPE_CIPHER |CRYPTO_ALG_NEED_FALLBACK
> so later at __crypto_alg_lookup(aes, 0x0405, 0x248c)
> this alg is not choosen because the check
>   if ((q->cra_flags ^ type) & mask)
> is true q->cra_flags = 0x0501 ^ 0x0405 & 0x248x => 0x0004
>
> @Martin, I'll commit a patch asap.
>
> Thanks for your help :-)
>
> regards, H.Freudenberger
>
rollback. Changing the cra_flag CRYPTO_ALG_TYPE_SKCIPHER in the crypto_alg
registration struct is not the right way.
continuing evaluation ...

^ permalink raw reply

* Re: [PATCH] crypto: brcm: fix spelling mistake: "genereate" -> "generate"
From: Steve Lin @ 2017-02-24 12:57 UTC (permalink / raw)
  To: Colin King
  Cc: Herbert Xu, David S . Miller, Rob Rice, linux-crypto,
	linux-kernel
In-Reply-To: <20170222235138.8531-1-colin.king@canonical.com>

Looks good, thanks!

Acked-by: Steve Lin <steven.lin1@broadcom.com>

On Wed, Feb 22, 2017 at 6:51 PM, Colin King <colin.king@canonical.com> wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> trivial fix to spelling mistake in pr_err message
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  drivers/crypto/bcm/util.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/crypto/bcm/util.c b/drivers/crypto/bcm/util.c
> index 0502f46..430c557 100644
> --- a/drivers/crypto/bcm/util.c
> +++ b/drivers/crypto/bcm/util.c
> @@ -312,7 +312,7 @@ int do_shash(unsigned char *name, unsigned char *result,
>         }
>         rc = crypto_shash_final(&sdesc->shash, result);
>         if (rc)
> -               pr_err("%s: Could not genereate %s hash", __func__, name);
> +               pr_err("%s: Could not generate %s hash", __func__, name);
>
>  do_shash_err:
>         crypto_free_shash(hash);
> --
> 2.10.2
>

^ permalink raw reply

* [RFC] how to handle AAD copy operation for algif_aead
From: Stephan Müller @ 2017-02-24 13:24 UTC (permalink / raw)
  To: herbert, linux-crypto

[-- Attachment #1: Type: text/plain, Size: 985 bytes --]

Hi Herbert et al,

attached are two patches where each patch has a different approach to copy the 
AAD in the algif_aead operation. I would like to hear your opinion which 
approach should be taken.

The patch 0001-crypto-algif_aead-copy-AAD-from-src-to-dst_separate.patch 
simply copies the AAD over from TX SGL to RX SGL. The pro is that the patch is 
small. The con is that this approach does *not* provide an in-place crypto 
operation.

The patch 0001-crypto-algif_aead-copy-AAD-from-src-to-dst_inplace.patch copies 
the AAD and the PT/CT from TX SGL into the RX SGL. In addition, this patch 
chains the SGL with the tag value part present in the TX SGL to the RX SGL in 
case of decryption. This implies that we have an in-place cipher operation 
operating in the RX SGL. Though, the patch is significantly larger.

(note: the patches are NOT meant for inclusion, but only for discussion -- yet 
both code parts are fully tested with by test framework in libkcapi).

Ciao
Stephan

[-- Attachment #2: 0001-crypto-algif_aead-copy-AAD-from-src-to-dst_inplace.patch --]
[-- Type: text/x-patch, Size: 7625 bytes --]

>From 2135854799e3c8b2b6ea395941a21a6ab6b72823 Mon Sep 17 00:00:00 2001
From: Stephan Mueller <smueller@chronox.de>
Date: Fri, 24 Feb 2017 14:09:47 +0100
Subject: [PATCH] crypto: algif_aead - copy AAD from src to dst

Use the NULL cipher to copy the AAD and PT/CT from the TX SGL
to the RX SGL. This allows an in-place crypto operation on the
RX SGL for encryption, because the TX data is always smaller or
equal to the RX data (the RX data will hold the tag).

For decryption, a per-request TX SGL is created which will only hold
the tag value. As the RX SGL will have no space for the tag value and
an in-place operation will not write the tag buffer, the TX SGL with the
tag value is chained to the RX SGL. This now allows an in-place
crypto operation.

Signed-off-by: Stephan Mueller <smueller@chronox.de>
---
 crypto/Kconfig      |   2 +
 crypto/algif_aead.c | 106 ++++++++++++++++++++++++++++++++++++++++++----------
 2 files changed, 88 insertions(+), 20 deletions(-)

diff --git a/crypto/Kconfig b/crypto/Kconfig
index 5a51b87..bfa531d 100644
--- a/crypto/Kconfig
+++ b/crypto/Kconfig
@@ -1735,6 +1735,8 @@ config CRYPTO_USER_API_AEAD
 	tristate "User-space interface for AEAD cipher algorithms"
 	depends on NET
 	select CRYPTO_AEAD
+	select CRYPTO_BLKCIPHER
+	select CRYPTO_NULL
 	select CRYPTO_USER_API
 	help
 	  This option enables the user-spaces interface for AEAD
diff --git a/crypto/algif_aead.c b/crypto/algif_aead.c
index 050a866..cdf7c10 100644
--- a/crypto/algif_aead.c
+++ b/crypto/algif_aead.c
@@ -30,6 +30,8 @@
 #include <crypto/internal/aead.h>
 #include <crypto/scatterwalk.h>
 #include <crypto/if_alg.h>
+#include <crypto/skcipher.h>
+#include <crypto/null.h>
 #include <linux/init.h>
 #include <linux/list.h>
 #include <linux/kernel.h>
@@ -82,6 +84,7 @@ struct aead_ctx {
 
 	unsigned int len;	/* Length of allocated memory for this struct */
 	struct crypto_aead *aead_tfm;
+	struct crypto_skcipher *null;
 };
 
 static DECLARE_WAIT_QUEUE_HEAD(aead_aio_finish_wait);
@@ -171,7 +174,7 @@ static unsigned int aead_count_tsgl(struct sock *sk, size_t bytes)
 }
 
 static void aead_pull_tsgl(struct sock *sk, size_t used,
-			   struct scatterlist *dst)
+			   struct scatterlist *dst, size_t dst_offset)
 {
 	struct alg_sock *ask = alg_sk(sk);
 	struct aead_ctx *ctx = ask->private;
@@ -195,8 +198,16 @@ static void aead_pull_tsgl(struct sock *sk, size_t used,
 			 * Assumption: caller created aead_count_tsgl(len)
 			 * SG entries in dst.
 			 */
-			if (dst)
-				sg_set_page(dst + i, page, plen, sg[i].offset);
+			if (dst) {
+				if (dst_offset > plen)
+					dst_offset -= plen;
+				else {
+					sg_set_page(dst + i, page,
+						    plen - dst_offset,
+						    sg[i].offset + dst_offset);
+					dst_offset = 0;
+				}
+			}
 
 			sg[i].length -= plen;
 			sg[i].offset += plen;
@@ -207,7 +218,7 @@ static void aead_pull_tsgl(struct sock *sk, size_t used,
 			if (sg[i].length)
 				return;
 
-			if (!dst)
+			if (!dst || dst_offset)
 				put_page(page);
 			sg_assign_page(sg + i, NULL);
 		}
@@ -559,6 +570,20 @@ static void aead_async_cb(struct crypto_async_request *_req, int err)
 	wake_up_interruptible(&aead_aio_finish_wait);
 }
 
+static int crypto_aead_copy_sgl(struct crypto_skcipher *null,
+				struct scatterlist *src,
+				struct scatterlist *dst, unsigned int len)
+{
+	SKCIPHER_REQUEST_ON_STACK(skreq, null);
+
+	skcipher_request_set_tfm(skreq, null);
+	skcipher_request_set_callback(skreq, CRYPTO_TFM_REQ_MAY_BACKLOG,
+				      NULL, NULL);
+	skcipher_request_set_crypt(skreq, src, dst, len, NULL);
+
+	return crypto_skcipher_encrypt(skreq);
+}
+
 static int aead_recvmsg(struct socket *sock, struct msghdr *msg, size_t ignored,
 			int flags)
 {
@@ -571,6 +596,7 @@ static int aead_recvmsg(struct socket *sock, struct msghdr *msg, size_t ignored,
 		sizeof(struct aead_async_req) + crypto_aead_reqsize(tfm);
 	struct aead_async_req *areq;
 	struct aead_rsgl *last_rsgl = NULL;
+	struct aead_tsgl *tsgl;
 	int err = -EINVAL;
 	size_t used = 0;		/* [in]  TX bufs to be en/decrypted */
 	size_t outlen = 0;		/* [out] RX bufs produced by kernel */
@@ -687,25 +713,55 @@ static int aead_recvmsg(struct socket *sock, struct msghdr *msg, size_t ignored,
 		outlen -= less;
 	}
 
-	/*
-	 * Create a per request TX SGL for this request which tracks the
-	 * SG entries from the global TX SGL.
-	 */
 	processed = used + ctx->aead_assoclen;
-	areq->tsgl_entries = aead_count_tsgl(sk, processed);
-	if (!areq->tsgl_entries)
-		areq->tsgl_entries = 1;
-	areq->tsgl = sock_kmalloc(sk, sizeof(*areq->tsgl) * areq->tsgl_entries,
-				  GFP_KERNEL);
-	if (!areq->tsgl) {
-		err = -ENOMEM;
-		goto free;
+	tsgl = list_first_entry(&ctx->tsgl_list, struct aead_tsgl, list);
+	if (ctx->enc) {
+		/* Copy AAD || PT to RX SGL buffer for in-place operation. */
+		err = crypto_aead_copy_sgl(ctx->null, tsgl->sg,
+					   areq->first_rsgl.sgl.sg, processed);
+		if (err)
+			goto free;
+		aead_pull_tsgl(sk, processed, NULL, 0);
+	} else {
+		/* Copy AAD || CT to RX SGL buffer for in-place operation. */
+		err = crypto_aead_copy_sgl(ctx->null, tsgl->sg,
+					   areq->first_rsgl.sgl.sg, outlen);
+		if (err)
+			goto free;
+
+		/* Create TX SGL for tag and chain it to RX SGL. */
+		areq->tsgl_entries = aead_count_tsgl(sk, processed);
+		if (!areq->tsgl_entries)
+			areq->tsgl_entries = 1;
+		areq->tsgl = sock_kmalloc(sk, sizeof(*areq->tsgl) *
+					      areq->tsgl_entries,
+					  GFP_KERNEL);
+		if (!areq->tsgl) {
+			err = -ENOMEM;
+			goto free;
+		}
+		sg_init_table(areq->tsgl, areq->tsgl_entries);
+
+		/* Release TX SGL, except for tag data. */
+		aead_pull_tsgl(sk, processed, areq->tsgl, processed - as);
+
+		/* chain the areq TX SGL holding the tag with RX SGL */
+		if (!last_rsgl) {
+			/* no RX SGL present (e.g. only authentication) */
+			sg_init_table(areq->first_rsgl.sgl.sg, 2);
+			sg_chain(areq->first_rsgl.sgl.sg, 2, areq->tsgl);
+		} else {
+			/* RX SGL present */
+			struct af_alg_sgl *sgl_prev = &last_rsgl->sgl;
+
+			sg_unmark_end(sgl_prev->sg + sgl_prev->npages - 1);
+			sg_chain(sgl_prev->sg, sgl_prev->npages + 1, areq->tsgl);
+		}
 	}
-	sg_init_table(areq->tsgl, areq->tsgl_entries);
-	aead_pull_tsgl(sk, processed, areq->tsgl);
+
 
 	/* Initialize the crypto operation */
-	aead_request_set_crypt(&areq->aead_req, areq->tsgl,
+	aead_request_set_crypt(&areq->aead_req, areq->first_rsgl.sgl.sg,
 			       areq->first_rsgl.sgl.sg, used, ctx->iv);
 	aead_request_set_ad(&areq->aead_req, ctx->aead_assoclen);
 	aead_request_set_tfm(&areq->aead_req, tfm);
@@ -824,7 +880,8 @@ static void aead_sock_destruct(struct sock *sk)
 	/* Suspend caller if AIO operations are in flight. */
 	wait_event_interruptible(aead_aio_finish_wait, (ctx->inflight == 0));
 
-	aead_pull_tsgl(sk, ctx->used, NULL);
+	aead_pull_tsgl(sk, ctx->used, NULL, 0);
+	crypto_put_default_null_skcipher2();
 	sock_kzfree_s(sk, ctx->iv, ivlen);
 	sock_kfree_s(sk, ctx, ctx->len);
 	af_alg_release_parent(sk);
@@ -836,6 +893,7 @@ static int aead_accept_parent(void *private, struct sock *sk)
 	struct alg_sock *ask = alg_sk(sk);
 	unsigned int len = sizeof(*ctx);
 	unsigned int ivlen = crypto_aead_ivsize(private);
+	struct crypto_skcipher *null;
 
 	ctx = sock_kmalloc(sk, len, GFP_KERNEL);
 	if (!ctx)
@@ -849,6 +907,14 @@ static int aead_accept_parent(void *private, struct sock *sk)
 	}
 	memset(ctx->iv, 0, ivlen);
 
+	null = crypto_get_default_null_skcipher2();
+	if (IS_ERR(null)) {
+		sock_kfree_s(sk, ctx->iv, ivlen);
+		sock_kfree_s(sk, ctx, len);
+		return PTR_ERR(null);
+	}
+	ctx->null = null;
+
 	INIT_LIST_HEAD(&ctx->tsgl_list);
 	ctx->len = len;
 	ctx->used = 0;
-- 
2.9.3


[-- Attachment #3: 0001-crypto-algif_aead-copy-AAD-from-src-to-dst_separate.patch --]
[-- Type: text/x-patch, Size: 3813 bytes --]

>From cbd8a171c56008ce4932de9f0a54926279c6061d Mon Sep 17 00:00:00 2001
From: Stephan Mueller <smueller@chronox.de>
Date: Wed, 22 Feb 2017 17:22:02 +0100
Subject: [PATCH] crypto: algif_aead - copy AAD from src to dst

Use the NULL cipher to copy the AAD from the TX SGL to the RX SGL.

The required null cipher is allocated when allocating other components
used by algif_aead and released when those components are deallocated.

Signed-off-by: Stephan Mueller <smueller@chronox.de>
---
 crypto/Kconfig      |  2 ++
 crypto/algif_aead.c | 33 +++++++++++++++++++++++++++++++++
 2 files changed, 35 insertions(+)

diff --git a/crypto/Kconfig b/crypto/Kconfig
index 5a51b87..bfa531d 100644
--- a/crypto/Kconfig
+++ b/crypto/Kconfig
@@ -1735,6 +1735,8 @@ config CRYPTO_USER_API_AEAD
 	tristate "User-space interface for AEAD cipher algorithms"
 	depends on NET
 	select CRYPTO_AEAD
+	select CRYPTO_BLKCIPHER
+	select CRYPTO_NULL
 	select CRYPTO_USER_API
 	help
 	  This option enables the user-spaces interface for AEAD
diff --git a/crypto/algif_aead.c b/crypto/algif_aead.c
index 050a866..98c988b 100644
--- a/crypto/algif_aead.c
+++ b/crypto/algif_aead.c
@@ -30,6 +30,8 @@
 #include <crypto/internal/aead.h>
 #include <crypto/scatterwalk.h>
 #include <crypto/if_alg.h>
+#include <crypto/skcipher.h>
+#include <crypto/null.h>
 #include <linux/init.h>
 #include <linux/list.h>
 #include <linux/kernel.h>
@@ -82,6 +84,7 @@ struct aead_ctx {
 
 	unsigned int len;	/* Length of allocated memory for this struct */
 	struct crypto_aead *aead_tfm;
+	struct crypto_skcipher *null;
 };
 
 static DECLARE_WAIT_QUEUE_HEAD(aead_aio_finish_wait);
@@ -559,6 +562,20 @@ static void aead_async_cb(struct crypto_async_request *_req, int err)
 	wake_up_interruptible(&aead_aio_finish_wait);
 }
 
+static int crypto_aead_copy_sgl(struct crypto_skcipher *null,
+				struct scatterlist *src,
+				struct scatterlist *dst, unsigned int len)
+{
+	SKCIPHER_REQUEST_ON_STACK(skreq, null);
+
+	skcipher_request_set_tfm(skreq, null);
+	skcipher_request_set_callback(skreq, CRYPTO_TFM_REQ_MAY_BACKLOG,
+				      NULL, NULL);
+	skcipher_request_set_crypt(skreq, src, dst, len, NULL);
+
+	return crypto_skcipher_encrypt(skreq);
+}
+
 static int aead_recvmsg(struct socket *sock, struct msghdr *msg, size_t ignored,
 			int flags)
 {
@@ -704,6 +721,12 @@ static int aead_recvmsg(struct socket *sock, struct msghdr *msg, size_t ignored,
 	sg_init_table(areq->tsgl, areq->tsgl_entries);
 	aead_pull_tsgl(sk, processed, areq->tsgl);
 
+	/* copy AAD from src to dst */
+	err = crypto_aead_copy_sgl(ctx->null, areq->tsgl,
+				   areq->first_rsgl.sgl.sg, ctx->aead_assoclen);
+	if (err)
+		goto free;
+
 	/* Initialize the crypto operation */
 	aead_request_set_crypt(&areq->aead_req, areq->tsgl,
 			       areq->first_rsgl.sgl.sg, used, ctx->iv);
@@ -825,6 +848,7 @@ static void aead_sock_destruct(struct sock *sk)
 	wait_event_interruptible(aead_aio_finish_wait, (ctx->inflight == 0));
 
 	aead_pull_tsgl(sk, ctx->used, NULL);
+	crypto_put_default_null_skcipher2();
 	sock_kzfree_s(sk, ctx->iv, ivlen);
 	sock_kfree_s(sk, ctx, ctx->len);
 	af_alg_release_parent(sk);
@@ -836,6 +860,7 @@ static int aead_accept_parent(void *private, struct sock *sk)
 	struct alg_sock *ask = alg_sk(sk);
 	unsigned int len = sizeof(*ctx);
 	unsigned int ivlen = crypto_aead_ivsize(private);
+	struct crypto_skcipher *null;
 
 	ctx = sock_kmalloc(sk, len, GFP_KERNEL);
 	if (!ctx)
@@ -849,6 +874,14 @@ static int aead_accept_parent(void *private, struct sock *sk)
 	}
 	memset(ctx->iv, 0, ivlen);
 
+	null = crypto_get_default_null_skcipher2();
+	if (IS_ERR(null)) {
+		sock_kfree_s(sk, ctx->iv, ivlen);
+		sock_kfree_s(sk, ctx, len);
+		return PTR_ERR(null);
+	}
+	ctx->null = null;
+
 	INIT_LIST_HEAD(&ctx->tsgl_list);
 	ctx->len = len;
 	ctx->used = 0;
-- 
2.9.3


^ permalink raw reply related

* [PATCH v2 1/2] crypto: vmx - Use skcipher for cbc fallback
From: Paulo Flabiano Smorigo @ 2017-02-24 14:23 UTC (permalink / raw)
  To: linux-kernel
  Cc: herbert, paulus, linux-crypto, Paulo Flabiano Smorigo,
	linuxppc-dev, davem
In-Reply-To: <20170223112052.GA14019@gondor.apana.org.au>

Signed-off-by: Paulo Flabiano Smorigo <pfsmorigo@linux.vnet.ibm.com>
---
 drivers/crypto/vmx/aes_cbc.c | 44 ++++++++++++++++++++++----------------------
 1 file changed, 22 insertions(+), 22 deletions(-)

diff --git a/drivers/crypto/vmx/aes_cbc.c b/drivers/crypto/vmx/aes_cbc.c
index 94ad5c0..2bb5910 100644
--- a/drivers/crypto/vmx/aes_cbc.c
+++ b/drivers/crypto/vmx/aes_cbc.c
@@ -27,11 +27,12 @@
 #include <asm/switch_to.h>
 #include <crypto/aes.h>
 #include <crypto/scatterwalk.h>
+#include <crypto/skcipher.h>
 
 #include "aesp8-ppc.h"
 
 struct p8_aes_cbc_ctx {
-	struct crypto_blkcipher *fallback;
+	struct crypto_skcipher *fallback;
 	struct aes_key enc_key;
 	struct aes_key dec_key;
 };
@@ -39,7 +40,7 @@ struct p8_aes_cbc_ctx {
 static int p8_aes_cbc_init(struct crypto_tfm *tfm)
 {
 	const char *alg;
-	struct crypto_blkcipher *fallback;
+	struct crypto_skcipher *fallback;
 	struct p8_aes_cbc_ctx *ctx = crypto_tfm_ctx(tfm);
 
 	if (!(alg = crypto_tfm_alg_name(tfm))) {
@@ -47,8 +48,9 @@ static int p8_aes_cbc_init(struct crypto_tfm *tfm)
 		return -ENOENT;
 	}
 
-	fallback =
-	    crypto_alloc_blkcipher(alg, 0, CRYPTO_ALG_NEED_FALLBACK);
+	fallback = crypto_alloc_skcipher(alg, 0,
+			CRYPTO_ALG_ASYNC | CRYPTO_ALG_NEED_FALLBACK);
+
 	if (IS_ERR(fallback)) {
 		printk(KERN_ERR
 		       "Failed to allocate transformation for '%s': %ld\n",
@@ -58,9 +60,9 @@ static int p8_aes_cbc_init(struct crypto_tfm *tfm)
 	printk(KERN_INFO "Using '%s' as fallback implementation.\n",
 	       crypto_tfm_alg_driver_name((struct crypto_tfm *) fallback));
 
-	crypto_blkcipher_set_flags(
+	crypto_skcipher_set_flags(
 		fallback,
-		crypto_blkcipher_get_flags((struct crypto_blkcipher *)tfm));
+		crypto_skcipher_get_flags((struct crypto_skcipher *)tfm));
 	ctx->fallback = fallback;
 
 	return 0;
@@ -71,7 +73,7 @@ static void p8_aes_cbc_exit(struct crypto_tfm *tfm)
 	struct p8_aes_cbc_ctx *ctx = crypto_tfm_ctx(tfm);
 
 	if (ctx->fallback) {
-		crypto_free_blkcipher(ctx->fallback);
+		crypto_free_skcipher(ctx->fallback);
 		ctx->fallback = NULL;
 	}
 }
@@ -91,7 +93,7 @@ static int p8_aes_cbc_setkey(struct crypto_tfm *tfm, const u8 *key,
 	pagefault_enable();
 	preempt_enable();
 
-	ret += crypto_blkcipher_setkey(ctx->fallback, key, keylen);
+	ret += crypto_skcipher_setkey(ctx->fallback, key, keylen);
 	return ret;
 }
 
@@ -103,15 +105,14 @@ static int p8_aes_cbc_encrypt(struct blkcipher_desc *desc,
 	struct blkcipher_walk walk;
 	struct p8_aes_cbc_ctx *ctx =
 		crypto_tfm_ctx(crypto_blkcipher_tfm(desc->tfm));
-	struct blkcipher_desc fallback_desc = {
-		.tfm = ctx->fallback,
-		.info = desc->info,
-		.flags = desc->flags
-	};
 
 	if (in_interrupt()) {
-		ret = crypto_blkcipher_encrypt(&fallback_desc, dst, src,
-					       nbytes);
+		SKCIPHER_REQUEST_ON_STACK(req, ctx->fallback);
+		skcipher_request_set_tfm(req, ctx->fallback);
+		skcipher_request_set_callback(req, desc->flags, NULL, NULL);
+		skcipher_request_set_crypt(req, src, dst, nbytes, desc->info);
+		ret = crypto_skcipher_encrypt(req);
+		skcipher_request_zero(req);
 	} else {
 		preempt_disable();
 		pagefault_disable();
@@ -144,15 +145,14 @@ static int p8_aes_cbc_decrypt(struct blkcipher_desc *desc,
 	struct blkcipher_walk walk;
 	struct p8_aes_cbc_ctx *ctx =
 		crypto_tfm_ctx(crypto_blkcipher_tfm(desc->tfm));
-	struct blkcipher_desc fallback_desc = {
-		.tfm = ctx->fallback,
-		.info = desc->info,
-		.flags = desc->flags
-	};
 
 	if (in_interrupt()) {
-		ret = crypto_blkcipher_decrypt(&fallback_desc, dst, src,
-					       nbytes);
+		SKCIPHER_REQUEST_ON_STACK(req, ctx->fallback);
+		skcipher_request_set_tfm(req, ctx->fallback);
+		skcipher_request_set_callback(req, desc->flags, NULL, NULL);
+		skcipher_request_set_crypt(req, src, dst, nbytes, desc->info);
+		ret = crypto_skcipher_decrypt(req);
+		skcipher_request_zero(req);
 	} else {
 		preempt_disable();
 		pagefault_disable();
-- 
2.7.4

^ permalink raw reply related


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox