From: "Colin Walters" <walters@verbum.org>
To: "Stefan Berger" <stefanb@linux.ibm.com>, linux-integrity@vger.kernel.org
Cc: zohar@linux.ibm.com, "Dmitry Kasatkin" <dmitry.kasatkin@gmail.com>
Subject: Re: [PATCH 1/3] libimaevm: Implement imaevm_create_ima_signature
Date: Mon, 26 Apr 2021 20:02:59 -0400 [thread overview]
Message-ID: <4a4d068b-569c-4ffd-ba32-8656f761a3b5@www.fastmail.com> (raw)
In-Reply-To: <20210420183015.861644-2-stefanb@linux.ibm.com>
On Tue, Apr 20, 2021, at 2:30 PM, Stefan Berger wrote:
> + fd = open(filename, O_RDONLY);
Missing O_CLOEXEC.
> +int imaevm_create_ima_signature(const char *filename, EVP_PKEY *pkey,
It'd maximize flexibility for the caller to pass a file descriptor, and not a file name.
> + if (statbuf.st_size > 0) {
> + addr = mmap(NULL, statbuf.st_size, PROT_READ, MAP_SHARED, fd, 0);
> + if (addr == MAP_FAILED) {
> + asprintf(error, "Failed to mmap file: %s", strerror(errno));
> + goto err_close;
> + }
> + }
Tangentially related to this, I think we should consider doing the same optimization here:
https://github.com/ostreedev/ostree/blob/36693f064c63dad550ebcfed33bf9b95806ddef9/src/libotutil/ot-fs-utils.c#L171
Or alternatively, just have the caller provide a (mmap'd or copied-via-read()) buffer?
Though clearly the most flexible is a streaming API. But eh, I am not really concerned about that level of performance.
next prev parent reply other threads:[~2021-04-27 0:03 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-20 18:30 [PATCH 0/3] ima-evm-utils: Implement function to only create IMA signature Stefan Berger
2021-04-20 18:30 ` [PATCH 1/3] libimaevm: Implement imaevm_create_ima_signature Stefan Berger
2021-04-27 0:02 ` Colin Walters [this message]
2021-04-27 17:47 ` Stefan Berger
2021-04-27 19:13 ` Stefan Berger
2021-04-20 18:30 ` [PATCH 2/3] tests: Add program to create IMA signature with new API call Stefan Berger
2021-04-20 18:30 ` [PATCH 3/3] libimaevm: Have sign_hash_v2 call sign_hash_v2_pkey after reading key file Stefan Berger
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=4a4d068b-569c-4ffd-ba32-8656f761a3b5@www.fastmail.com \
--to=walters@verbum.org \
--cc=dmitry.kasatkin@gmail.com \
--cc=linux-integrity@vger.kernel.org \
--cc=stefanb@linux.ibm.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).