linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tushar Sugandhi <tusharsu@linux.microsoft.com>
To: Mimi Zohar <zohar@linux.ibm.com>,
	stephen.smalley.work@gmail.com, casey@schaufler-ca.com,
	agk@redhat.com, snitzer@redhat.com, gmazyland@gmail.com,
	paul@paul-moore.com
Cc: tyhicks@linux.microsoft.com, sashal@kernel.org,
	jmorris@namei.org, nramas@linux.microsoft.com,
	linux-integrity@vger.kernel.org, selinux@vger.kernel.org,
	linux-security-module@vger.kernel.org,
	linux-kernel@vger.kernel.org, dm-devel@redhat.com
Subject: Re: [PATCH 3/3] IMA: add support to measure duplicate buffer for critical data hook
Date: Tue, 9 Feb 2021 10:31:43 -0800	[thread overview]
Message-ID: <8af5bf67-54d3-f358-6cb6-34733fc72df2@linux.microsoft.com> (raw)
In-Reply-To: <158dc2d3398316edefbafdb1cfea5eca840a06e6.camel@linux.ibm.com>



On 2021-02-08 12:24 p.m., Mimi Zohar wrote:
> Hi Tushar,
> 
> On Fri, 2021-01-29 at 16:45 -0800, Tushar Sugandhi wrote:
> 
>> diff --git a/security/integrity/ima/ima_queue.c b/security/integrity/ima/ima_queue.c
>>
>> index c096ef8945c7..fbf359495fa8 100644
>> --- a/security/integrity/ima/ima_queue.c
>> +++ b/security/integrity/ima/ima_queue.c
>> @@ -158,7 +158,7 @@ static int ima_pcr_extend(struct tpm_digest *digests_arg, int pcr)
>>    */
>>   int ima_add_template_entry(struct ima_template_entry *entry, int violation,
>>   			   const char *op, struct inode *inode,
>> -			   const unsigned char *filename)
>> +			   const unsigned char *filename, bool allow_dup)
>>   {
>>   	u8 *digest = entry->digests[ima_hash_algo_idx].digest;
>>
>   	struct tpm_digestate_entry(struct ima_template_entry *entry, int violation,
Not sure I understand this.  Maybe a typo?  Could you please explain?

>>   
>>   	mutex_lock(&ima_extend_list_mutex);
>>   	if (!violation) {
>> -		if (ima_lookup_digest_entry(digest, entry->pcr)) {
>> +		if (!allow_dup &&
>> +		    ima_lookup_digest_entry(digest, entry->pcr)) {
> 
> Can't this change be simplified to "if (!violation && !allow_dup)"?
> 
Sure.  Will do.

Earlier I wasn't sure if 'violation' would touch any other use-cases 
inadvertently.  That's why I localized the change as above.

But now since we are supporting other scenarios as well,
I believe "if (!violation && !allow_dup)" would be cleaner.

> Also perhaps instead of passing another variable "allow_dup" to each of
> these functions, pass a mask containing violation and allow_dup.
> 
There were examples of both approaches in ima_match_policy().
  - int *pcr/ima_template_desc **template_desc as an out-param;
  - and various actions as flags in return int.

Earlier I couldn't decide one way or the other, so I picked the 
out-param approach.

But since allow_dup is just a single bit info, returning it as a bit in 
the action flag is a cleaner solution.
Will implement it with flag in the next iteration.

Thanks again for reviewing the series.  Really appreciate it.

Thanks,
Tushar

>>   			audit_cause = "hash_exists";
>>   			result = -EEXIST;
>>   			goto out;
> 
> thanks,
> 
> Mimi
> 

  reply	other threads:[~2021-02-09 21:21 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-30  0:45 [PATCH 0/3] support for duplicate measurement of integrity critical data Tushar Sugandhi
2021-01-30  0:45 ` [PATCH 1/3] IMA: add policy condition to measure duplicate " Tushar Sugandhi
2021-02-08 20:45   ` Mimi Zohar
2021-02-09 18:26     ` Tushar Sugandhi
2021-01-30  0:45 ` [PATCH 2/3] IMA: update functions to read allow_dup policy condition Tushar Sugandhi
2021-01-30  0:45 ` [PATCH 3/3] IMA: add support to measure duplicate buffer for critical data hook Tushar Sugandhi
2021-02-08 20:24   ` Mimi Zohar
2021-02-09 18:31     ` Tushar Sugandhi [this message]
2021-02-08 20:22 ` [PATCH 0/3] support for duplicate measurement of integrity critical data Mimi Zohar
2021-02-08 21:10   ` Mimi Zohar
2021-02-09 18:23     ` Tushar Sugandhi
2021-02-09 18:53       ` Mimi Zohar
2021-02-09 20:57         ` Tushar Sugandhi

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=8af5bf67-54d3-f358-6cb6-34733fc72df2@linux.microsoft.com \
    --to=tusharsu@linux.microsoft.com \
    --cc=agk@redhat.com \
    --cc=casey@schaufler-ca.com \
    --cc=dm-devel@redhat.com \
    --cc=gmazyland@gmail.com \
    --cc=jmorris@namei.org \
    --cc=linux-integrity@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=nramas@linux.microsoft.com \
    --cc=paul@paul-moore.com \
    --cc=sashal@kernel.org \
    --cc=selinux@vger.kernel.org \
    --cc=snitzer@redhat.com \
    --cc=stephen.smalley.work@gmail.com \
    --cc=tyhicks@linux.microsoft.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).