From: Roberto Sassu <roberto.sassu@huawei.com>
To: Mimi Zohar <zohar@linux.ibm.com>,
"shuah@kernel.org" <shuah@kernel.org>,
"ast@kernel.org" <ast@kernel.org>,
"daniel@iogearbox.net" <daniel@iogearbox.net>,
"andrii@kernel.org" <andrii@kernel.org>,
"kpsingh@kernel.org" <kpsingh@kernel.org>,
Florent Revest <revest@chromium.org>
Cc: "linux-integrity@vger.kernel.org"
<linux-integrity@vger.kernel.org>,
"linux-security-module@vger.kernel.org"
<linux-security-module@vger.kernel.org>,
"linux-kselftest@vger.kernel.org"
<linux-kselftest@vger.kernel.org>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"bpf@vger.kernel.org" <bpf@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH] ima: Calculate digest in ima_inode_hash() if not available
Date: Mon, 14 Feb 2022 17:05:57 +0000 [thread overview]
Message-ID: <cc6bcb7742dc432ba990ee38b5909496@huawei.com> (raw)
In-Reply-To: <537635732d9cbcc42bcf7be5ed932d284b03d39f.camel@linux.ibm.com>
> From: Mimi Zohar [mailto:zohar@linux.ibm.com]
> Sent: Sunday, February 13, 2022 2:06 PM
> 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().
Hi Mimi
ok.
I found that just checking that iint->ima_hash is not NULL is not enough
(ima_inode_hash() might still return the old digest after a file write).
Should I replace that check with !(iint->flags & IMA_COLLECTED)?
Or should I do only for ima_file_hash() and recalculate the digest
if necessary?
> 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.
Did you mean to make the description shorter or to have everything
in one line? According to the kernel documentation (kernel-doc.rst),
having the brief description in multiple lines should be fine.
> Please split the IMA from the eBPF changes.
Ok.
Thanks
Roberto
HUAWEI TECHNOLOGIES Duesseldorf GmbH, HRB 56063
Managing Director: Li Peng, Zhong Ronghua
> --
> thanks,
>
> Mimi
next prev parent reply other threads:[~2022-02-14 17: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
2022-02-14 17:05 ` Roberto Sassu [this message]
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=cc6bcb7742dc432ba990ee38b5909496@huawei.com \
--to=roberto.sassu@huawei.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=shuah@kernel.org \
--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).