crypto: hisilicon/hpre - rsa key should not be empty
PATCH 1/1 crypto: hisilicon/hpre - rsa key should not be empty
We should ensure key is not empty before we set key.
--- drivers/crypto/hisilicon/hpre/hpre_crypto.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/crypto/hisilicon/hpre/hpre_crypto.c +6 -0
@@ -1093,6 +1093,9 @@ static int hpre_rsa_setpubkey(struct crypto_akcipher *tfm, const void *key,struct hpre_ctx *ctx =akcipher_tfm_ctx (tfm);int ret; +if (!key || !keylen) +return -EINVAL ; + ret =crypto_akcipher_set_pub_key (ctx->rsa.soft_tfm, key, keylen);if (ret)return ret;
@@ -1106,6 +1109,9 @@ static int hpre_rsa_setprivkey(struct crypto_akcipher *tfm, const void *key,struct hpre_ctx *ctx =akcipher_tfm_ctx (tfm);int ret; +if (!key || !keylen) +return -EINVAL ; + ret =crypto_akcipher_set_priv_key (ctx->rsa.soft_tfm, key, keylen);if (ret)return ret;
Signature · 1 line
2.8.1
Herbert Xu
maintainerQuoted 12 lines · Meng Yu
We should ensure key is not empty before we set key.
Signed-off-by Meng Yu <[email protected]>--- drivers/crypto/hisilicon/hpre/hpre_crypto.c | 6 ++++++ 1 file changed, 6 insertions(+)drivers/crypto/hisilicon/hpre/hpre_crypto.c +0
-0
drivers/crypto/hisilicon/hpre/hpre_crypto.c static int hpre_rsa_setpubkey(struct crypto_akcipher *tfm, const void *key, · line 1099
Quoted 7 lines
drivers/crypto/hisilicon/hpre/hpre_crypto.c +3
-0@@ -1093,6 +1093,9 @@ static int hpre_rsa_setpubkey(struct crypto_akcipher *tfm, const void *key,struct hpre_ctx *ctx =akcipher_tfm_ctx (tfm);int ret; +if (!key || !keylen) +return -EINVAL ; + ret =crypto_akcipher_set_pub_key (ctx->rsa.soft_tfm, key, keylen);
Does this fix a real bug? Wouldn't the soft fallback setkey catch this anyhow?
Thanks,
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Quoted 16 lines · Herbert Xu
Quoted 15 lines · Meng Yu
We should ensure key is not empty before we set key.
Signed-off-by Meng Yu <[email protected]>--- drivers/crypto/hisilicon/hpre/hpre_crypto.c | 6 ++++++ 1 file changed, 6 insertions(+)drivers/crypto/hisilicon/hpre/hpre_crypto.c +0
-0@@ -1093,6 +1093,9 @@ static int hpre_rsa_setpubkey(struct crypto_akcipher *tfm, const void *key,struct hpre_ctx *ctx =akcipher_tfm_ctx (tfm);int ret;
Quoted 8 lines
drivers/crypto/hisilicon/hpre/hpre_crypto.c static int hpre_rsa_setpubkey(struct crypto_akcipher *tfm, const void *key, · line 1099
Quoted 4 lines
drivers/crypto/hisilicon/hpre/hpre_crypto.c +3
-0+if (!key || !keylen) +return -EINVAL ; + ret =crypto_akcipher_set_pub_key (ctx->rsa.soft_tfm, key, keylen);Does this fix a real bug? Wouldn't the soft fallback setkey catch this anyhow?
I think it is not a real bug, and soft fallback setkey can always catch the error. But our original intention was to make it don't go to 'xxx_set_pub_key' when the key is null, and it can return an error earlier.
But maybe it is not good.
Herbert Xu
maintainerQuoted 6 lines · yumeng
I think it is not a real bug, and soft fallback setkey can always catch the error.
But our original intention was to make it don't go to 'xxx_set_pub_key' when the key is null, and it can return an error earlier.
But maybe it is not good.
It might make sense to check them twice if you were touching them directly, e.g., poking inside the key. However, it appears that your driver simply palms off the key to rsa_helper.c which should check the key/keylen too so I think there is no need for this patch for now.
Thanks,
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Quoted 8 lines · Herbert Xu
Quoted 6 lines · yumeng
I think it is not a real bug, and soft fallback setkey can always catch the error.
But our original intention was to make it don't go to 'xxx_set_pub_key' when the key is null, and it can return an error earlier.
But maybe it is not good.
Quoted 8 lines
It might make sense to check them twice if you were touching them directly, e.g., poking inside the key. However, it appears that your driver simply palms off the key to
rsa_helper.cwhich should check the key/keylen too so I think there is no need for this patch for now.Thanks,
OK, thank you.