linux-security-module.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Roberto Sassu <roberto.sassu@huaweicloud.com>
To: zohar@linux.ibm.com, dmitry.kasatkin@gmail.com,
	paul@paul-moore.com, jmorris@namei.org, serge@hallyn.com
Cc: linux-kernel@vger.kernel.org, linux-integrity@vger.kernel.org,
	linux-security-module@vger.kernel.org, bpf@vger.kernel.org,
	jarkko@kernel.org, pbrobinson@gmail.com, zbyszek@in.waw.pl,
	hch@lst.de, mjg59@srcf.ucam.org,
	Roberto Sassu <roberto.sassu@huawei.com>,
	Panu Matilainen <pmatilai@redhat.com>
Subject: Re: [RFC][PATCH 00/12] integrity: Introduce a digest cache
Date: Thu, 03 Aug 2023 18:20:47 +0200	[thread overview]
Message-ID: <5a938ee2f56f9ccf7df82f233fcf9c7ff310b4cb.camel@huaweicloud.com> (raw)
In-Reply-To: <20230721163326.4106089-1-roberto.sassu@huaweicloud.com>

On Fri, 2023-07-21 at 18:33 +0200, Roberto Sassu wrote:
> From: Roberto Sassu <roberto.sassu@huawei.com>

[...]

> The last part I wanted to talk about is about the digest list parsers. This
> was a long debate. In the original proposal, Matthew Garrett and Christoph
> Hellwig said that adding parsers in the kernel is not scalable and not a
> good idea in general. While I do agree with them, I'm also thinking what
> benefits we get if we relax a bit this requirement. If we merge this patch

I tried to mitigate the risk of adding unsafe code to the kernel by
verifying the parsers with a formal verification tool, Frama-C.

The verified code can be accessed here, and contains all the necessary
dependencies (so that the kernel is not involved):

https://github.com/robertosassu/rpm-formal

I added some assertions, to ensure that for any given input, the parser
does not try to reference memory outside the assigned memory area.

I also tried to enforce finite termination by making the number of
loops dependent on the passed data length.

The output I get is the following:

[eva:summary] ====== ANALYSIS SUMMARY ======
  ----------------------------------------------------------------------------
  13 functions analyzed (out of 13): 100% coverage.
  In these functions, 232 statements reached (out of 251): 92% coverage.
  ----------------------------------------------------------------------------
  Some errors and warnings have been raised during the analysis:
    by the Eva analyzer:      0 errors    2 warnings
    by the Frama-C kernel:    0 errors    0 warnings
  ----------------------------------------------------------------------------
  0 alarms generated by the analysis.
  ----------------------------------------------------------------------------
  Evaluation of the logical properties reached by the analysis:
    Assertions        5 valid     0 unknown     0 invalid      5 total
    Preconditions    25 valid     0 unknown     0 invalid     25 total
  100% of the logical properties reached have been proven.
  ----------------------------------------------------------------------------

The warnings are:

[eva] validate_tlv.c:353: Warning: 
  this partitioning parameter cannot be evaluated safely on all states

[eva] validate_tlv.c:381: Warning: 
  this partitioning parameter cannot be evaluated safely on all states

Not sure how I can make them go away. Anyway, the assertions are
successful.

I verified the parsers with both deterministic (random but valid) and
non-deterministic (random and possibly invalid) data. For deterministic
data, I also verified that bytes at a specific location have the
expected value.

Due to the increasing complexity, the analysis was not done on
arbitrary lengths and value ranges (it would probably require a
different type of analysis).

Thanks

Roberto


      parent reply	other threads:[~2023-08-03 16:21 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-21 16:33 [RFC][PATCH 00/12] integrity: Introduce a digest cache Roberto Sassu
2023-07-21 16:33 ` [RFC][PATCH 01/12] ima: Introduce hook DIGEST_LIST_CHECK Roberto Sassu
2023-07-21 16:33 ` [RFC][PATCH 02/12] integrity: Introduce a digest cache Roberto Sassu
2023-07-21 16:33 ` [RFC][PATCH 03/12] integrity/digest_cache: Add functions to populate and search Roberto Sassu
2023-07-21 16:33 ` [RFC][PATCH 04/12] integrity/digest_cache: Iterate over digest lists in same dir Roberto Sassu
2023-07-21 16:33 ` [RFC][PATCH 05/12] integrity/digest_cache: Parse tlv digest lists Roberto Sassu
2023-07-21 16:33 ` [RFC][PATCH 06/12] integrity/digest_cache: Parse rpm " Roberto Sassu
2023-07-21 16:33 ` [RFC][PATCH 07/12] ima: Add digest_cache policy keyword Roberto Sassu
2023-07-21 16:33 ` [RFC][PATCH 08/12] ima: Use digest cache for measurement Roberto Sassu
2023-07-21 16:33 ` [RFC][PATCH 09/12] ima: Use digest cache for appraisal Roberto Sassu
2023-07-21 16:33 ` [RFC][PATCH 10/12] tools: Add tool to manage digest lists Roberto Sassu
2023-07-21 16:33 ` [RFC][PATCH 11/12] tools/digest-lists: Add tlv digest list generator and parser Roberto Sassu
2023-07-21 16:33 ` [RFC][PATCH 12/12] tools/digest-lists: Add rpm " Roberto Sassu
2023-08-03 16:20 ` Roberto Sassu [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=5a938ee2f56f9ccf7df82f233fcf9c7ff310b4cb.camel@huaweicloud.com \
    --to=roberto.sassu@huaweicloud.com \
    --cc=bpf@vger.kernel.org \
    --cc=dmitry.kasatkin@gmail.com \
    --cc=hch@lst.de \
    --cc=jarkko@kernel.org \
    --cc=jmorris@namei.org \
    --cc=linux-integrity@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=mjg59@srcf.ucam.org \
    --cc=paul@paul-moore.com \
    --cc=pbrobinson@gmail.com \
    --cc=pmatilai@redhat.com \
    --cc=roberto.sassu@huawei.com \
    --cc=serge@hallyn.com \
    --cc=zbyszek@in.waw.pl \
    --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).