From: Herbert Xu <herbert@gondor.apana.org.au>
To: kernel test robot <oliver.sang@intel.com>
Cc: Eric Biggers <ebiggers@google.com>,
oe-lkp@lists.linux.dev, lkp@intel.com,
linux-crypto@vger.kernel.org
Subject: [PATCH] crypto: lrw - Only add ecb if it is not already there
Date: Thu, 15 May 2025 16:28:08 +0800 [thread overview]
Message-ID: <aCWlmOE6VQJoYeaJ@gondor.apana.org.au> (raw)
In-Reply-To: <202505151503.d8a6cf10-lkp@intel.com>
On Thu, May 15, 2025 at 03:41:05PM +0800, kernel test robot wrote:
>
> [ 16.077514][ T327] ------------[ cut here ]------------
> [ 16.079451][ T327] alg: self-tests for lrw(twofish) using lrw(ecb(twofish-asm)) failed (rc=-22)
The crucial line actually got cut off:
alg: skcipher: error allocating lrw(ecb(twofish-generic)) (generic impl of lrw(twofish)): -22
The bug is in lrw, which unconditionally adds ecb() around its
parameter, so we end up with ecb(ecb(twofish-generic)), which is
then correctly rejected by the ecb template when it tries to
create the inner ecb(twofish-generic) as a simple cipher.
---8<---
Only add ecb to the cipher name if it isn't already ecb.
Also use memcmp instead of strncmp since these strings are all
stored in an array of length CRYPTO_MAX_ALG_NAME.
Fixes: 700cb3f5fe75 ("crypto: lrw - Convert to skcipher")
Reported-by: kernel test robot <oliver.sang@intel.com>
Closes: https://lore.kernel.org/oe-lkp/202505151503.d8a6cf10-lkp@intel.com
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
diff --git a/crypto/lrw.c b/crypto/lrw.c
index e7f0368f8c97..dd403b800513 100644
--- a/crypto/lrw.c
+++ b/crypto/lrw.c
@@ -322,7 +322,7 @@ static int lrw_create(struct crypto_template *tmpl, struct rtattr **tb)
err = crypto_grab_skcipher(spawn, skcipher_crypto_instance(inst),
cipher_name, 0, mask);
- if (err == -ENOENT) {
+ if (err == -ENOENT && memcmp(cipher_name, "ecb(", 4)) {
err = -ENAMETOOLONG;
if (snprintf(ecb_name, CRYPTO_MAX_ALG_NAME, "ecb(%s)",
cipher_name) >= CRYPTO_MAX_ALG_NAME)
@@ -356,7 +356,7 @@ static int lrw_create(struct crypto_template *tmpl, struct rtattr **tb)
/* Alas we screwed up the naming so we have to mangle the
* cipher name.
*/
- if (!strncmp(cipher_name, "ecb(", 4)) {
+ if (!memcmp(cipher_name, "ecb(", 4)) {
int len;
len = strscpy(ecb_name, cipher_name + 4, sizeof(ecb_name));
--
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
next prev parent reply other threads:[~2025-05-15 8:28 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-15 7:41 [linux-next:master] [crypto] 698de82278: WARNING:at_crypto/testmgr.c:#alg_test kernel test robot
2025-05-15 8:28 ` Herbert Xu [this message]
2025-05-15 20:04 ` [PATCH] crypto: lrw - Only add ecb if it is not already there Eric Biggers
2025-05-16 9:15 ` Herbert Xu
2025-05-16 16:45 ` Eric Biggers
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=aCWlmOE6VQJoYeaJ@gondor.apana.org.au \
--to=herbert@gondor.apana.org.au \
--cc=ebiggers@google.com \
--cc=linux-crypto@vger.kernel.org \
--cc=lkp@intel.com \
--cc=oe-lkp@lists.linux.dev \
--cc=oliver.sang@intel.com \
/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: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox