linux-security-module.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mimi Zohar <zohar@linux.ibm.com>
To: Roberto Sassu <roberto.sassu@huawei.com>,
	shuah@kernel.org, ast@kernel.org, daniel@iogearbox.net,
	andrii@kernel.org, kpsingh@kernel.org,
	Florent Revest <revest@chromium.org>
Cc: linux-integrity@vger.kernel.org,
	linux-security-module@vger.kernel.org,
	linux-kselftest@vger.kernel.org, netdev@vger.kernel.org,
	bpf@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ima: Calculate digest in ima_inode_hash() if not available
Date: Sun, 13 Feb 2022 08:06:01 -0500	[thread overview]
Message-ID: <537635732d9cbcc42bcf7be5ed932d284b03d39f.camel@linux.ibm.com> (raw)
In-Reply-To: <20220211104828.4061334-1-roberto.sassu@huawei.com>

Hi Roberto,

On Fri, 2022-02-11 at 11:48 +0100, Roberto Sassu wrote:
> __ima_inode_hash() checks if a digest has been already calculated by
> looking for the integrity_iint_cache structure associated to the passed
> inode.
> 
> Users of ima_file_hash() and ima_inode_hash() (e.g. eBPF) might be
> interested in obtaining the information without having to setup an IMA
> policy so that the digest is always available at the time they call one of
> those functions.
> 
> Open a new file descriptor in __ima_inode_hash(), so that this function
> could invoke ima_collect_measurement() to calculate the digest if it is not
> available. Still return -EOPNOTSUPP if the calculation failed.
> 
> Instead of opening a new file descriptor, the one from ima_file_hash()
> could have been used. However, since ima_inode_hash() was created to obtain
> the digest when the file descriptor is not available, it could benefit from
> this change too. Also, the opened file descriptor might be not suitable for
> use (file descriptor opened not for reading).
> 
> This change does not cause memory usage increase, due to using a temporary
> integrity_iint_cache structure for the digest calculation, and due to
> freeing the ima_digest_data structure inside integrity_iint_cache before
> exiting from __ima_inode_hash().
> 
> Finally, update the test by removing ima_setup.sh (it is not necessary
> anymore to set an IMA policy) and by directly executing /bin/true.
> 
> Signed-off-by: Roberto Sassu <roberto.sassu@huawei.com>

Although this patch doesn't directly modify either ima_file_hash() or
ima_inode_hash(),  this change affects both functions.  ima_file_hash()
was introduced to be used with eBPF.  Based on Florent's post, changing
the ima_file_hash() behavor seems fine.  Since I have no idea whether
anyone is still using ima_inode_hash(), perhaps it would be safer to
limit this behavior change to just ima_file_hash().

Please update the ima_file_hash() doc.  While touching this area, I'd
appreciate your fixing the first doc line in both ima_file_hash() and
ima_inode_hash() cases, which wraps spanning two lines.

Please split the IMA from the eBPF changes.

-- 
thanks,

Mimi


  parent reply	other threads:[~2022-02-13 13:06 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-11 10:48 [PATCH] ima: Calculate digest in ima_inode_hash() if not available Roberto Sassu
2022-02-11 12:40 ` Mimi Zohar
2022-02-11 12:57   ` Roberto Sassu
2022-02-11 13:11     ` Florent Revest
2022-02-13 13:06 ` Mimi Zohar [this message]
2022-02-14 17:05   ` Roberto Sassu
2022-02-14 22:32     ` Mimi Zohar
2022-02-15  8:00       ` Roberto Sassu
2022-02-15 11:16         ` Mimi Zohar

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=537635732d9cbcc42bcf7be5ed932d284b03d39f.camel@linux.ibm.com \
    --to=zohar@linux.ibm.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=kpsingh@kernel.org \
    --cc=linux-integrity@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=revest@chromium.org \
    --cc=roberto.sassu@huawei.com \
    --cc=shuah@kernel.org \
    /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).