diff options
| author | Herbert Xu <herbert@gondor.apana.org.au> | 2025-05-15 16:28:08 +0800 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2025-06-27 11:04:01 +0100 |
| commit | fee92b8dfaa1695e2d106c6c96e806fc6473a079 (patch) | |
| tree | 284c684ecee841f549da6aa7902ce20f57a7b0a6 /crypto | |
| parent | b4ee85c0745398b88d311886f8c5b65a1f495c4f (diff) | |
| download | linux-fee92b8dfaa1695e2d106c6c96e806fc6473a079.tar.gz linux-fee92b8dfaa1695e2d106c6c96e806fc6473a079.tar.bz2 linux-fee92b8dfaa1695e2d106c6c96e806fc6473a079.zip | |
crypto: lrw - Only add ecb if it is not already there
[ Upstream commit 3d73909bddc2ebb3224a8bc2e5ce00e9df70c15d ]
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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'crypto')
| -rw-r--r-- | crypto/lrw.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/crypto/lrw.c b/crypto/lrw.c index 80d9076e42e0..7adc105c12f7 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)); |
