From: Ard Biesheuvel <ardb@kernel.org> To: "Horia Geantă" <horia.geanta@nxp.com> Cc: Herbert Xu <herbert@gondor.apana.org.au>, "David S. Miller" <davem@davemloft.net>, Russell King <linux@armlinux.org.uk>, Linux Crypto Mailing List <linux-crypto@vger.kernel.org>, Linux ARM <linux-arm-kernel@lists.infradead.org>, NXP Linux Team <linux-imx@nxp.com>, Linux Kernel Mailing List <linux-kernel@vger.kernel.org> Subject: Re: [PATCH] crypto: arm/aes-neonbs - fix usage of cbc(aes) fallback Date: Wed, 28 Oct 2020 10:06:58 +0100 [thread overview] Message-ID: <CAMj1kXGfwuY_uEGT83QpoUZwy9X=6k7zaxHs2kFrdsArKpVpOw@mail.gmail.com> (raw) In-Reply-To: <20201028090320.4222-1-horia.geanta@nxp.com> On Wed, 28 Oct 2020 at 10:03, Horia Geantă <horia.geanta@nxp.com> wrote: > > Loading the module deadlocks since: > -local cbc(aes) implementation needs a fallback and > -crypto API tries to find one but the request_module() resolves back to > the same module > > Fix this by changing the module alias for cbc(aes) and > using the NEED_FALLBACK flag when requesting for a fallback algorithm. > > Fixes: 00b99ad2bac2 ("crypto: arm/aes-neonbs - Use generic cbc encryption path") > Signed-off-by: Horia Geantă <horia.geanta@nxp.com> Not sure what is happening here: IIRC the intention was to rely on the fact that only the sync cbc(aes) implementation needs the fallback, and therefore, allocating a sync skcipher explicitly would avoid this recursion. Herbert? > --- > arch/arm/crypto/aes-neonbs-glue.c | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) > > diff --git a/arch/arm/crypto/aes-neonbs-glue.c b/arch/arm/crypto/aes-neonbs-glue.c > index bda8bf17631e..f70af1d0514b 100644 > --- a/arch/arm/crypto/aes-neonbs-glue.c > +++ b/arch/arm/crypto/aes-neonbs-glue.c > @@ -19,7 +19,7 @@ MODULE_AUTHOR("Ard Biesheuvel <ard.biesheuvel@linaro.org>"); > MODULE_LICENSE("GPL v2"); > > MODULE_ALIAS_CRYPTO("ecb(aes)"); > -MODULE_ALIAS_CRYPTO("cbc(aes)"); > +MODULE_ALIAS_CRYPTO("cbc(aes)-all"); > MODULE_ALIAS_CRYPTO("ctr(aes)"); > MODULE_ALIAS_CRYPTO("xts(aes)"); > > @@ -191,7 +191,8 @@ static int cbc_init(struct crypto_skcipher *tfm) > struct aesbs_cbc_ctx *ctx = crypto_skcipher_ctx(tfm); > unsigned int reqsize; > > - ctx->enc_tfm = crypto_alloc_skcipher("cbc(aes)", 0, CRYPTO_ALG_ASYNC); > + ctx->enc_tfm = crypto_alloc_skcipher("cbc(aes)", 0, CRYPTO_ALG_ASYNC | > + CRYPTO_ALG_NEED_FALLBACK); > if (IS_ERR(ctx->enc_tfm)) > return PTR_ERR(ctx->enc_tfm); > > @@ -441,7 +442,8 @@ static struct skcipher_alg aes_algs[] = { { > .base.cra_blocksize = AES_BLOCK_SIZE, > .base.cra_ctxsize = sizeof(struct aesbs_cbc_ctx), > .base.cra_module = THIS_MODULE, > - .base.cra_flags = CRYPTO_ALG_INTERNAL, > + .base.cra_flags = CRYPTO_ALG_INTERNAL | > + CRYPTO_ALG_NEED_FALLBACK, > > .min_keysize = AES_MIN_KEY_SIZE, > .max_keysize = AES_MAX_KEY_SIZE, > -- > 2.17.1 >
WARNING: multiple messages have this Message-ID (diff)
From: Ard Biesheuvel <ardb@kernel.org> To: "Horia Geantă" <horia.geanta@nxp.com> Cc: Herbert Xu <herbert@gondor.apana.org.au>, Russell King <linux@armlinux.org.uk>, Linux Kernel Mailing List <linux-kernel@vger.kernel.org>, Linux Crypto Mailing List <linux-crypto@vger.kernel.org>, "David S. Miller" <davem@davemloft.net>, Linux ARM <linux-arm-kernel@lists.infradead.org>, NXP Linux Team <linux-imx@nxp.com> Subject: Re: [PATCH] crypto: arm/aes-neonbs - fix usage of cbc(aes) fallback Date: Wed, 28 Oct 2020 10:06:58 +0100 [thread overview] Message-ID: <CAMj1kXGfwuY_uEGT83QpoUZwy9X=6k7zaxHs2kFrdsArKpVpOw@mail.gmail.com> (raw) In-Reply-To: <20201028090320.4222-1-horia.geanta@nxp.com> On Wed, 28 Oct 2020 at 10:03, Horia Geantă <horia.geanta@nxp.com> wrote: > > Loading the module deadlocks since: > -local cbc(aes) implementation needs a fallback and > -crypto API tries to find one but the request_module() resolves back to > the same module > > Fix this by changing the module alias for cbc(aes) and > using the NEED_FALLBACK flag when requesting for a fallback algorithm. > > Fixes: 00b99ad2bac2 ("crypto: arm/aes-neonbs - Use generic cbc encryption path") > Signed-off-by: Horia Geantă <horia.geanta@nxp.com> Not sure what is happening here: IIRC the intention was to rely on the fact that only the sync cbc(aes) implementation needs the fallback, and therefore, allocating a sync skcipher explicitly would avoid this recursion. Herbert? > --- > arch/arm/crypto/aes-neonbs-glue.c | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) > > diff --git a/arch/arm/crypto/aes-neonbs-glue.c b/arch/arm/crypto/aes-neonbs-glue.c > index bda8bf17631e..f70af1d0514b 100644 > --- a/arch/arm/crypto/aes-neonbs-glue.c > +++ b/arch/arm/crypto/aes-neonbs-glue.c > @@ -19,7 +19,7 @@ MODULE_AUTHOR("Ard Biesheuvel <ard.biesheuvel@linaro.org>"); > MODULE_LICENSE("GPL v2"); > > MODULE_ALIAS_CRYPTO("ecb(aes)"); > -MODULE_ALIAS_CRYPTO("cbc(aes)"); > +MODULE_ALIAS_CRYPTO("cbc(aes)-all"); > MODULE_ALIAS_CRYPTO("ctr(aes)"); > MODULE_ALIAS_CRYPTO("xts(aes)"); > > @@ -191,7 +191,8 @@ static int cbc_init(struct crypto_skcipher *tfm) > struct aesbs_cbc_ctx *ctx = crypto_skcipher_ctx(tfm); > unsigned int reqsize; > > - ctx->enc_tfm = crypto_alloc_skcipher("cbc(aes)", 0, CRYPTO_ALG_ASYNC); > + ctx->enc_tfm = crypto_alloc_skcipher("cbc(aes)", 0, CRYPTO_ALG_ASYNC | > + CRYPTO_ALG_NEED_FALLBACK); > if (IS_ERR(ctx->enc_tfm)) > return PTR_ERR(ctx->enc_tfm); > > @@ -441,7 +442,8 @@ static struct skcipher_alg aes_algs[] = { { > .base.cra_blocksize = AES_BLOCK_SIZE, > .base.cra_ctxsize = sizeof(struct aesbs_cbc_ctx), > .base.cra_module = THIS_MODULE, > - .base.cra_flags = CRYPTO_ALG_INTERNAL, > + .base.cra_flags = CRYPTO_ALG_INTERNAL | > + CRYPTO_ALG_NEED_FALLBACK, > > .min_keysize = AES_MIN_KEY_SIZE, > .max_keysize = AES_MAX_KEY_SIZE, > -- > 2.17.1 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2020-10-29 0:53 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-10-28 9:03 [PATCH] crypto: arm/aes-neonbs - fix usage of cbc(aes) fallback Horia Geantă 2020-10-28 9:03 ` Horia Geantă 2020-10-28 9:06 ` Ard Biesheuvel [this message] 2020-10-28 9:06 ` Ard Biesheuvel 2020-10-28 9:43 ` Horia Geantă 2020-10-28 9:43 ` Horia Geantă 2020-10-29 6:49 ` Herbert Xu 2020-10-29 6:49 ` Herbert Xu 2020-11-06 7:02 ` Herbert Xu 2020-11-06 7:02 ` Herbert Xu
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to='CAMj1kXGfwuY_uEGT83QpoUZwy9X=6k7zaxHs2kFrdsArKpVpOw@mail.gmail.com' \ --to=ardb@kernel.org \ --cc=davem@davemloft.net \ --cc=herbert@gondor.apana.org.au \ --cc=horia.geanta@nxp.com \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-crypto@vger.kernel.org \ --cc=linux-imx@nxp.com \ --cc=linux-kernel@vger.kernel.org \ --cc=linux@armlinux.org.uk \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.