diff options
| author | Herbert Xu <herbert@gondor.apana.org.au> | 2025-05-15 16:34:04 +0800 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2025-06-19 15:28:03 +0200 |
| commit | 04a39a3c7d3788874f8d6b52884f7a53b564ba5d (patch) | |
| tree | a9077c012dd6518f92bdd1f91fa69cb2a0258100 /crypto | |
| parent | ba2af6855c4dde0f5bbafb1e3346c1626341b69f (diff) | |
| download | linux-04a39a3c7d3788874f8d6b52884f7a53b564ba5d.tar.gz linux-04a39a3c7d3788874f8d6b52884f7a53b564ba5d.tar.bz2 linux-04a39a3c7d3788874f8d6b52884f7a53b564ba5d.zip | |
crypto: xts - Only add ecb if it is not already there
[ Upstream commit 270b6f13454cb7f2f7058c50df64df409c5dcf55 ]
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: f1c131b45410 ("crypto: xts - Convert to skcipher")
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/xts.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/crypto/xts.c b/crypto/xts.c index 038f60dd512d..97fd0fb8757c 100644 --- a/crypto/xts.c +++ b/crypto/xts.c @@ -363,7 +363,7 @@ static int xts_create(struct crypto_template *tmpl, struct rtattr **tb) err = crypto_grab_skcipher(&ctx->spawn, skcipher_crypto_instance(inst), cipher_name, 0, mask); - if (err == -ENOENT) { + if (err == -ENOENT && memcmp(cipher_name, "ecb(", 4)) { err = -ENAMETOOLONG; if (snprintf(name, CRYPTO_MAX_ALG_NAME, "ecb(%s)", cipher_name) >= CRYPTO_MAX_ALG_NAME) @@ -397,7 +397,7 @@ static int xts_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(name, cipher_name + 4, sizeof(name)); |
