security/keys: rewrite all of big_key crypto
Subsystems (3)
PATCH v3 1/1 security/keys: rewrite all of big_key crypto
This started out as just replacing the use of crypto/rng with get_random_bytes, so that we wouldn't use bad randomness at boot time. But, upon looking further, it appears that there were even deeper underlying cryptographic problems, and that this seems to have been committed with very little crypto review. So, I rewrote the whole thing, trying to keep to the conventions introduced by the previous author, to fix these cryptographic flaws.
Since this sensitive material is being stored untrusted, using ECB and no authentication is simply not okay at all. I find it surprising that this code even made it past basic crypto review, though perhaps there's something I'm missing. This patch moves from using AES-ECB to using AES-GCM. Since keys are uniquely generated each time, we can set the nonce to zero. There was also a race condition in which the same key would be reused at the same time in different threads. A mutex fixes this issue now. And, some error paths forgot to zero out sensitive material, so this patch changes a kfree into a kzfree.
So, to summarize, this commit fixes the following vulnerabilities:
* Unauthenticated encryption, allowing an attacker to modify the cipher text in particular ways in order to manipulate the plaintext, which is is even more frightening considering the next point.
* Use of ECB mode, allowing an attacker to trivially swap blocks or compare identical plaintext blocks.
* Key re-use.
* Faulty memory zeroing.
---
Changes v2->v3:
- Do AEAD operations on heap rather than stack.
- Various cleanups.
security/keys/Kconfig | 4 +- security/keys/big_key.c | 139 ++++++++++++++++++++++-------------------------- 2 files changed, 65 insertions(+), 78 deletions(-)
security/keys/Kconfig +1 -3
@@ -41,10 +41,8 @@ config BIG_KEYS bool "Large payload keys" depends on KEYS depends on TMPFS - depends on (CRYPTO_ANSI_CPRNG = y || CRYPTO_DRBG = y) select CRYPTO_AES - select CRYPTO_ECB - select CRYPTO_RNG + select CRYPTO_GCM help This option provides support for holding large keys within the kernel (for example Kerberos ticket caches). The data may be stored out to
security/keys/big_key.c +64 -75
262 lines not on this page · raw message
Signature · 1 line
2.13.0