mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-30 11:41:38 -04:00
crypto: ecc - Actually remove stack VLA usage
On the quest to remove all VLAs from the kernel[1], this avoids VLAs
by just using the maximum allocation size (4 bytes) for stack arrays.
All the VLAs in ecc were either 3 or 4 bytes (or a multiple), so just
make it 4 bytes all the time. Initialization routines are adjusted to
check that ndigits does not end up larger than the arrays.
This includes a removal of the earlier attempt at this fix from
commit a963834b4742 ("crypto/ecc: Remove stack VLA usage")
[1] https://lkml.org/lkml/2018/3/7/621
Signed-off-by: Kees Cook <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>
This commit is contained in:
parent
3a488aaec6
commit
d5c3b17898
3 changed files with 33 additions and 41 deletions
|
|
@ -30,8 +30,8 @@ static inline struct ecdh_ctx *ecdh_get_ctx(struct crypto_kpp *tfm)
|
|||
static unsigned int ecdh_supported_curve(unsigned int curve_id)
|
||||
{
|
||||
switch (curve_id) {
|
||||
case ECC_CURVE_NIST_P192: return 3;
|
||||
case ECC_CURVE_NIST_P256: return 4;
|
||||
case ECC_CURVE_NIST_P192: return ECC_CURVE_NIST_P192_DIGITS;
|
||||
case ECC_CURVE_NIST_P256: return ECC_CURVE_NIST_P256_DIGITS;
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue