History

ima: fix hash algorithm initialization

The hash_setup function always sets the hash_setup_done flag, even when the hash algorithm is invalid. This prevents the default hash algorithm defined as CONFIG_IMA_DEFAULT_HASH from being used. This patch sets hash_setup_done flag only for valid hash algorithms.

Boshi Wang committed 9 years ago

Commit ebe7c0a1 parent 0485d061 file · +4 −0Browse files

Unified · Split

security/integrity/ima/ima_main.c+4−0
@@ -51,6 +51,8 @@ static int __init hash_setup(char *str) · 50 unmodified lines
5151 ima_hash_algo = HASH_ALGO_SHA1;
5252 else if (strncmp(str, "md5", 3) == 0)
5353 ima_hash_algo = HASH_ALGO_MD5;
54+ else
55+ return 1;
5456 goto out;
5557 }
5658
@@ -60,6 +62,8 @@ static int __init hash_setup(char *str) · 3 unmodified lines
6062 break;
6163 }
6264 }
65+ if (i == HASH_ALGO__LAST)
66+ return 1;
6367 out:
6468 hash_setup_done = 1;
6569 return 1;