diff options
| author | Dmitry Kasatkin <d.kasatkin@samsung.com> | 2014-08-15 06:28:52 -0400 |
|---|---|---|
| committer | Mimi Zohar <zohar@linux.vnet.ibm.com> | 2014-09-02 17:03:36 -0400 |
| commit | 23c19e2ca736722a9523b64b07cda7efab7b6c57 (patch) | |
| tree | cb0501321b7221aed0bafe9b3b016ba033053a3d | |
| parent | 9a8d289fbcb7dfd1fc74959e9930b406e76b2002 (diff) | |
ima: prevent buffer overflow in ima_alloc_tfm()
This patch fixes the case where the file's signature/hash xattr contains
an invalid hash algorithm. Although we can not verify the xattr, we still
need to measure the file. Use the default IMA hash algorithm.
Signed-off-by: Dmitry Kasatkin <d.kasatkin@samsung.com>
Signed-off-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
| -rw-r--r-- | security/integrity/ima/ima_crypto.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/security/integrity/ima/ima_crypto.c b/security/integrity/ima/ima_crypto.c index 2d103dc13d90..1178b307d562 100644 --- a/security/integrity/ima/ima_crypto.c +++ b/security/integrity/ima/ima_crypto.c | |||
| @@ -116,7 +116,10 @@ static struct crypto_shash *ima_alloc_tfm(enum hash_algo algo) | |||
| 116 | struct crypto_shash *tfm = ima_shash_tfm; | 116 | struct crypto_shash *tfm = ima_shash_tfm; |
| 117 | int rc; | 117 | int rc; |
| 118 | 118 | ||
| 119 | if (algo != ima_hash_algo && algo < HASH_ALGO__LAST) { | 119 | if (algo < 0 || algo >= HASH_ALGO__LAST) |
| 120 | algo = ima_hash_algo; | ||
| 121 | |||
| 122 | if (algo != ima_hash_algo) { | ||
| 120 | tfm = crypto_alloc_shash(hash_algo_name[algo], 0, 0); | 123 | tfm = crypto_alloc_shash(hash_algo_name[algo], 0, 0); |
| 121 | if (IS_ERR(tfm)) { | 124 | if (IS_ERR(tfm)) { |
| 122 | rc = PTR_ERR(tfm); | 125 | rc = PTR_ERR(tfm); |
