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