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
51 ima_hash_algo = HASH_ALGO_SHA1;51 ima_hash_algo = HASH_ALGO_SHA1;
52 else if (strncmp(str, "md5", 3) == 0)52 else if (strncmp(str, "md5", 3) == 0)
53 ima_hash_algo = HASH_ALGO_MD5;53 ima_hash_algo = HASH_ALGO_MD5;
54 else
55 return 1;
54 goto out;56 goto out;
55 }57 }
56 58
@@ -60,6 +62,8 @@ static int __init hash_setup(char *str) · 3 unmodified lines
60 break;62 break;
61 }63 }
62 }64 }
65 if (i == HASH_ALGO__LAST)
66 return 1;
63out:67out:
64 hash_setup_done = 1;68 hash_setup_done = 1;
65 return 1;69 return 1;