All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Guozihua (Scott)" <guozihua@huawei.com>
To: Mimi Zohar <zohar@linux.ibm.com>, <linux-integrity@vger.kernel.org>
Cc: <dmitry.kasatkin@gmail.com>, <roberto.sassu@huawei.com>,
	<linux-security-module@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>, <xiujianfeng@huawei.com>,
	<wangweiyang2@huawei.com>
Subject: Re: [PATCH] ima: remove template "ima" as the compiled default
Date: Wed, 6 Apr 2022 09:48:19 +0800	[thread overview]
Message-ID: <84ba6fb8-45e1-461b-1aa3-c97f065cbe60@huawei.com> (raw)
In-Reply-To: <5c3565f5a46f5728873c9aedd634699ba171fe98.camel@linux.ibm.com>

On 2022/4/5 4:22, Mimi Zohar wrote:
> Hi Guo,
> 
> The Subject line above sounds like the default template is currently
> "ima", which it isn't.   Perhaps "ima: remove the IMA_TEMPLATE Kconfig
> option" is more accurate.
> 
> On Mon, 2022-03-21 at 15:47 +0800, GUO Zihua wrote:
>> Template "ima" is a legacy template which limits the hash algorithm to
>> either sha1 or md5. None of them should be considered "strong" these
>> days. Besides, allowing template "ima" as the compiled default would
>> also cause the following issue: the cmdline option "ima_hash=" must be
>> behind "ima_template=", otherwise "ima_hash=" might be rejected.
>>
> 
> True "ima" is a legacy template, but the purpose of removing the
> IMA_TEMPLATE from the Kconfig is to address the remaining boot command
> line ordering issue not previously addressed.  This is reasonable
> because the "ima" template is limited to SHA1 and MD5.  If someone
> still needs to use the "ima" template, "ima_template=ima" could 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 compiled default template. If the
>> complied 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 compiled 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 checking for
>> IMA.
>>
>> Fixes: 4286587dccd43 ("ima: add Kconfig default measurement list template")
>> Signed-off-by: GUO Zihua <guozihua@huawei.com>
>> ---
>>   security/integrity/ima/Kconfig | 14 +++++---------
>>   1 file changed, 5 insertions(+), 9 deletions(-)
>>
>> diff --git a/security/integrity/ima/Kconfig b/security/integrity/ima/Kconfig
>> index f3a9cc201c8c..9513df2ac19e 100644
>> --- a/security/integrity/ima/Kconfig
>> +++ b/security/integrity/ima/Kconfig
>> @@ -65,14 +65,11 @@ choice
>>   	help
>>   	  Select the default IMA measurement template.
>>   
>> -	  The original 'ima' measurement list template contains a
>> -	  hash, defined as 20 bytes, and a null terminated pathname,
>> -	  limited to 255 characters.  The 'ima-ng' measurement list
>> -	  template permits both larger hash digests and longer
>> -	  pathnames.
>> -
>> -	config IMA_TEMPLATE
>> -		bool "ima"
>> +	  The 'ima-ng' measurement list template permits various hash
>> +	  digests and long pathnames. The compiled default template
>> +	  can be overwritten using the kernel command line
>> +	  'ima_template=' option.
>> +
>>   	config IMA_NG_TEMPLATE
>>   		bool "ima-ng (default)"
>>   	config IMA_SIG_TEMPLATE
>> @@ -82,7 +79,6 @@ endchoice
>>   config IMA_DEFAULT_TEMPLATE
>>   	string
>>   	depends on IMA
>> -	default "ima" if IMA_TEMPLATE
>>   	default "ima-ng" if IMA_NG_TEMPLATE
>>   	default "ima-sig" if IMA_SIG_TEMPLATE
>>   
> 
> The IMA_TEMPLATE definition is removed, but leaves a few references to
> it.

Thank you very much for the detailed review Mimi! I'll fix these right now.

-- 
Best
GUO Zihua

      reply	other threads:[~2022-04-06 16:29 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-21  7:47 [PATCH] ima: remove template "ima" as the compiled default GUO Zihua
2022-03-24  1:20 ` Guozihua (Scott)
2022-04-04 20:22 ` Mimi Zohar
2022-04-06  1:48   ` Guozihua (Scott) [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=84ba6fb8-45e1-461b-1aa3-c97f065cbe60@huawei.com \
    --to=guozihua@huawei.com \
    --cc=dmitry.kasatkin@gmail.com \
    --cc=linux-integrity@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=roberto.sassu@huawei.com \
    --cc=wangweiyang2@huawei.com \
    --cc=xiujianfeng@huawei.com \
    --cc=zohar@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.