Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp818842pxb; Tue, 9 Feb 2021 13:22:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJyvYeptD2S4C1KfFTavDsJDpr5caaNlYsDtc37U14bNTRunFN5BaJ0Fi/f6ZFDT/feH6+qK X-Received: by 2002:a50:bf42:: with SMTP id g2mr25309675edk.101.1612905736686; Tue, 09 Feb 2021 13:22:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612905736; cv=none; d=google.com; s=arc-20160816; b=XTZRv4g35rQ5bOs0kMn5c5dVHYJSmVHM1U4UyZfY3aoSSoTfeKKX+FqAo2kCqk6HBz nd/uusCMcFN3/zxJ/hVqstzDcHzPuQ+FUBDFSRtKinR+T+m0NHmvrqLH4mWgTcxCnK0y CTKV7Ad3MQKEsSEN+PHCPir6nezg9g0+sWXdldsgAAulSojW3RssvejLnWgrUoFv5Jy8 AmxmIsSLkVWQbD39EqrN3bUHJ5Iya0sADJQqphpGHYz+iAtC+adReB6MWYB15c8GFB/E nVVdTHxS5LVs+mWLns6MxbmfX4/vkNFW4IeWlu94biuI/g41yimtUJXN37I2v0D9XmCZ T6nA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature:dkim-filter; bh=wGYdUbhWR5y9KoUnFO9IRu5Hqx5/3X+QjRRHMVd3EHI=; b=EX/e2ugjGsgoEKrhSPS4vLbcC2io6g0tItYMgKIGdTTzjEL2hVBcyB3T21XXsiGXOC OOm1pP6bI7Mzwsz8rGHxOs5poEIESwkl/AiE3vzzy1lSACmksaRJLH7hXc65ha8iKUKG sBgcdn7W05OGhxxYimy/NCZvUykYG6NtMR4ub3tIlZYS65bfJNzHjF8OQHgUmu1L2Eao LZAW57xyxR6zp35NCLYqd9JPE3BGwGU1g05EfgSBZXi6hUc5FzUFqxd0V2V0Jb75KbGd mLwiA4APm1PHxocKj1qFv8ri2ASN5KE9ChuaFkOUEWoZZsR11Ai0pjOHm6FOd9Q4/hwr bOmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=bBpT7yfH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h28si5210122edj.387.2021.02.09.13.21.52; Tue, 09 Feb 2021 13:22:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=bBpT7yfH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233736AbhBIVRF (ORCPT + 99 others); Tue, 9 Feb 2021 16:17:05 -0500 Received: from linux.microsoft.com ([13.77.154.182]:33958 "EHLO linux.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233441AbhBIS45 (ORCPT ); Tue, 9 Feb 2021 13:56:57 -0500 Received: from [192.168.86.31] (c-71-197-163-6.hsd1.wa.comcast.net [71.197.163.6]) by linux.microsoft.com (Postfix) with ESMTPSA id 7089D2020E9E; Tue, 9 Feb 2021 10:31:44 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 7089D2020E9E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1612895504; bh=wGYdUbhWR5y9KoUnFO9IRu5Hqx5/3X+QjRRHMVd3EHI=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=bBpT7yfHfMpytdV83pn28BmzOiyTLc1T0B+pzDQ3hBh0YKIATeBHVdzevnaRWHOp/ 4LayizfSQ7VyW1d6V5S37JjCejSjQ3iyaz9oFGbNChIRMrz8ypKLiVYkU7rg7psdXs 8iHk8gRVIzPt36YlYxG/oGKbbj08xHP7pLqS6fl4= Subject: Re: [PATCH 3/3] IMA: add support to measure duplicate buffer for critical data hook To: Mimi Zohar , 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 References: <20210130004519.25106-1-tusharsu@linux.microsoft.com> <20210130004519.25106-4-tusharsu@linux.microsoft.com> <158dc2d3398316edefbafdb1cfea5eca840a06e6.camel@linux.ibm.com> From: Tushar Sugandhi Message-ID: <8af5bf67-54d3-f358-6cb6-34733fc72df2@linux.microsoft.com> Date: Tue, 9 Feb 2021 10:31:43 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <158dc2d3398316edefbafdb1cfea5eca840a06e6.camel@linux.ibm.com> Content-Type: text/plain; charset=iso-8859-15; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 >