Skip to content

Commit 891163a

Browse files
GUO Zihuamimizohar
authored andcommitted
ima: remove the IMA_TEMPLATE Kconfig option
The original 'ima' measurement list template contains a hash, defined as 20 bytes, and a null terminated pathname, limited to 255 characters. Other measurement list templates permit both larger hashes and longer pathnames. When the "ima" template is configured as the default, a new measurement list template (ima_template=) must be specified before specifying a larger hash algorithm (ima_hash=) on the boot command line. To avoid this boot command line ordering issue, remove the legacy "ima" template configuration option, allowing it to still be specified on the boot command line. The root cause of this issue is that during the processing of ima_hash, we would try to check whether the hash algorithm is compatible with the template. If the template is not set at the moment we do the check, we check the algorithm against the configured default template. If the default template is "ima", then we reject any hash algorithm other than sha1 and md5. For example, if the compiled default template is "ima", and the default algorithm is sha1 (which is the current default). In the cmdline, we put in "ima_hash=sha256 ima_template=ima-ng". The expected behavior would be that ima starts with ima-ng as the template and sha256 as the hash algorithm. However, during the processing of "ima_hash=", "ima_template=" has not been processed yet, and hash_setup would check the configured hash algorithm against the compiled default: ima, and reject sha256. So at the end, the hash algorithm that is actually used will be sha1. With template "ima" removed from the configured default, we ensure that the default tempalte would at least be "ima-ng" which allows for basically any hash algorithm. This change would not break the algorithm compatibility checks for IMA. Fixes: 4286587 ("ima: add Kconfig default measurement list template") Signed-off-by: GUO Zihua <guozihua@huawei.com> Cc: <Stable@vger.kernel.org> Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
1 parent 29d1c2b commit 891163a

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

security/integrity/ima/Kconfig

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,9 @@ choice
6969
hash, defined as 20 bytes, and a null terminated pathname,
7070
limited to 255 characters. The 'ima-ng' measurement list
7171
template permits both larger hash digests and longer
72-
pathnames.
72+
pathnames. The configured default template can be replaced
73+
by specifying "ima_template=" on the boot command line.
7374

74-
config IMA_TEMPLATE
75-
bool "ima"
7675
config IMA_NG_TEMPLATE
7776
bool "ima-ng (default)"
7877
config IMA_SIG_TEMPLATE
@@ -82,7 +81,6 @@ endchoice
8281
config IMA_DEFAULT_TEMPLATE
8382
string
8483
depends on IMA
85-
default "ima" if IMA_TEMPLATE
8684
default "ima-ng" if IMA_NG_TEMPLATE
8785
default "ima-sig" if IMA_SIG_TEMPLATE
8886

@@ -102,19 +100,19 @@ choice
102100

103101
config IMA_DEFAULT_HASH_SHA256
104102
bool "SHA256"
105-
depends on CRYPTO_SHA256=y && !IMA_TEMPLATE
103+
depends on CRYPTO_SHA256=y
106104

107105
config IMA_DEFAULT_HASH_SHA512
108106
bool "SHA512"
109-
depends on CRYPTO_SHA512=y && !IMA_TEMPLATE
107+
depends on CRYPTO_SHA512=y
110108

111109
config IMA_DEFAULT_HASH_WP512
112110
bool "WP512"
113-
depends on CRYPTO_WP512=y && !IMA_TEMPLATE
111+
depends on CRYPTO_WP512=y
114112

115113
config IMA_DEFAULT_HASH_SM3
116114
bool "SM3"
117-
depends on CRYPTO_SM3=y && !IMA_TEMPLATE
115+
depends on CRYPTO_SM3=y
118116
endchoice
119117

120118
config IMA_DEFAULT_HASH

0 commit comments

Comments
 (0)