Revert "crypto/ecc: Remove stack VLA usage"
Subsystems (2)
PATCH 1/1 Revert "crypto/ecc: Remove stack VLA usage"
This reverts commit 14de52112ee70ca289fa77bf2d9cbc79fd2c811f.
The solution was incomplete and inefficient. This will be fixed correctly in the next patch.
--- crypto/ecc.c | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-)
crypto/ecc.c +6 -17
@@ -1025,7 +1025,9 @@ int crypto_ecdh_shared_secret(unsigned int curve_id, unsigned int ndigits, {int ret =0 ;struct ecc_point *product, *pk; -u64 *priv, *rand_z; +u64 priv[ndigits]; +u64 rand_z[ndigits]; +unsigned int nbytes;const struct ecc_curve *curve =ecc_get_curve (curve_id);if (!private_key || !public_key || !curve) {
@@ -1033,22 +1035,14 @@ int crypto_ecdh_shared_secret(unsigned int curve_id, unsigned int ndigits, goto out; } - priv =kmalloc_array (ndigits,sizeof (*priv),GFP_KERNEL ); -if (!priv) { - ret = -ENOMEM ; - goto out; - } + nbytes = ndigits <<ECC_DIGITS_TO_BYTES_SHIFT ; - rand_z =kmalloc_array (ndigits,sizeof (*rand_z),GFP_KERNEL ); -if (!rand_z) { - ret = -ENOMEM ; - goto kfree_out; - } +get_random_bytes (rand_z, nbytes); pk =ecc_alloc_point (ndigits);if (!pk) { ret = -ENOMEM ; - goto kfree_out; + goto out; } product =ecc_alloc_point (ndigits);
@@ -1057,8 +1051,6 @@ int crypto_ecdh_shared_secret(unsigned int curve_id, unsigned int ndigits, goto err_alloc_product; } -get_random_bytes (rand_z, ndigits <<ECC_DIGITS_TO_BYTES_SHIFT ); -ecc_swap_digits (public_key, pk->x, ndigits);ecc_swap_digits (&public_key[ndigits], pk->y, ndigits);ecc_swap_digits (private_key, priv, ndigits);
@@ -1073,9 +1065,6 @@ int crypto_ecdh_shared_secret(unsigned int curve_id, unsigned int ndigits,ecc_free_point (product); err_alloc_product:ecc_free_point (pk); -kfree_out: -kzfree (priv); -kzfree (rand_z); out:return ret; }
Signature · 6 lines
2.7.4 -- Kees Cook Pixel Security
Herbert Xu
maintainerQuoted 6 lines · Kees Cook
This reverts commit
14de52112ee70ca289fa77bf2d9cbc79fd2c811f.The solution was incomplete and inefficient. This will be fixed correctly in the next patch.
Signed-off-by Kees Cook <[email protected]>
Hmm you didn't post this to linux-crypto so it's not in patchwork.
Anyway, I'd prefer if you just squashed this together with the subsequent patch. It's not that complex to require a revert and a new patch to be readable.
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 6 lines · Herbert Xu
Quoted 5 lines · Kees Cook
This reverts commit
14de52112ee70ca289fa77bf2d9cbc79fd2c811f.The solution was incomplete and inefficient. This will be fixed correctly in the next patch.
Quoted 7 lines
Quoted 1 line
Signed-off-by Kees Cook <[email protected]>Hmm you didn't post this to linux-crypto so it's not in patchwork.
Anyway, I'd prefer if you just squashed this together with the subsequent patch. It's not that complex to require a revert and a new patch to be readable.
Sounds good, thanks!
-Kees
Signature · 2 lines
Kees Cook Pixel Security