From: Stefan Berger <stefanb@linux.ibm.com>
To: Colin Walters <walters@verbum.org>, 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: Tue, 27 Apr 2021 13:47:01 -0400 [thread overview]
Message-ID: <1add81aa-85e6-68b1-4a48-b19ad33683c6@linux.ibm.com> (raw)
In-Reply-To: <4a4d068b-569c-4ffd-ba32-8656f761a3b5@www.fastmail.com>
On 4/26/21 8:02 PM, Colin Walters wrote:
>
> On Tue, Apr 20, 2021, at 2:30 PM, Stefan Berger wrote:
>
>> + fd = open(filename, O_RDONLY);
> Missing O_CLOEXEC.
Will do.
>
>> +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.
We could do this with a callback where the user implements the callback
function and providers buffer, size of buffer, and eof indicator, and
gets called for providing the data to hash. That would maybe be even
more flexible..
>
>> + 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.
I think using a callback would allow for the streaming as well...
Stefan
next prev parent reply other threads:[~2021-04-27 17:47 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
2021-04-27 17:47 ` Stefan Berger [this message]
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=1add81aa-85e6-68b1-4a48-b19ad33683c6@linux.ibm.com \
--to=stefanb@linux.ibm.com \
--cc=dmitry.kasatkin@gmail.com \
--cc=linux-integrity@vger.kernel.org \
--cc=walters@verbum.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).