From: Mimi Zohar <zohar@linux.ibm.com>
To: Vitaly Chikunov <vt@altlinux.org>
Cc: linux-integrity@vger.kernel.org, Petr Vorel <pvorel@suse.cz>,
Stefan Berger <stefanb@linux.ibm.com>
Subject: Re: [PATCH ima-evm-utils v3 06/15] Add missing EVP_MD_CTX_free() call in calc_evm_hash()
Date: Fri, 16 Sep 2022 09:07:51 -0400 [thread overview]
Message-ID: <17a92cfa3e8af21bb057abc374ff250c5c8b942b.camel@linux.ibm.com> (raw)
In-Reply-To: <20220915153659.dtykhzitxdrlpasq@altlinux.org>
On Thu, 2022-09-15 at 18:36 +0300, Vitaly Chikunov wrote:
> On Thu, Sep 15, 2022 at 07:58:51AM -0400, Mimi Zohar wrote:
> > Hi Vitaly,
> >
> > Thank you for this and the other reviews. They'll be addressed in the
> > next version.
> >
> > On Wed, 2022-09-14 at 17:51 +0300, Vitaly Chikunov wrote:
> > > > @@ -350,12 +356,11 @@ static int calc_evm_hash(const char *file, unsigned char *hash)
> > > > #if OPENSSL_VERSION_NUMBER < 0x10100000
> > > > EVP_MD_CTX ctx;
> > > > pctx = &ctx;
> > > > -#else
> > > > - pctx = EVP_MD_CTX_new();
> > > > #endif
> > > >
> > > > if (lstat(file, &st)) {
> > > > log_err("Failed to stat: %s\n", file);
> > > > + errno = 0;
> > >
> > > Why it clears errno (here and below)?
> > >
> > > errno(3) says "The value of errno is never set to zero by any system
> > > call or library function."
> >
> > evmctl, itself, is not a system call or a library function.
>
> Ah, I wasn't attentive this is only evmctl. [But there's similar commit
> acb19d1 ("Reset 'errno' after failure to open or access a file")
> changing libimaevm.c which is wrong.]
>
> Perhaps it should be noted in commit message that errno is cleared
> because it's error message is already printed to avoid double printing
> at exit of cmd handler.
>
> > Is this a
> > generic statement or here in particular as to how evmctl should handle
> > failed system calls? Another example is reading the keyfile. The
> > existence of which is not required.
>
> log_err("Failed to stat: %s\n", file);
>
> This does not even output errno code, but it could be very informative
> to user. I think it's better to print (at least errno or) strerror for
> users there (and on other syscall errors log_err instances.
>
> Maybe to add special log function (like log_strerr) just for evmctl
> which will print (non "\n"-terminated) error message (similar to
> warn(3)) with strerror output appended (and commented in the code why
> it) clears errno (so that later handlers do not print it again).
>
> ps. About libimaevm.c--I think errno should not be touched there as this
> breaks what coders expect from libraries. If this affects exit of evmctl
> then it should be handled in evmctl, not in the library. (Of course it's
> better to add strerror(errno) to log_err there too, but not by the
> proposed above function.)
Thank you for the suggestions. log_errno() is already defined. Not
sure how I missed that. So use log_errno() in libimaevm.c. For
evmctl.c, define a wrapper named log_and_reset_errno(), with your
suggested patch description.
Since none of the changes in next-testing have been released, they can
still be fixed/squashed as needed.
thanks!
Mimi
next prev parent reply other threads:[~2022-09-16 13:13 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-14 2:29 [PATCH ima-evm-utils v3 00/15] address deprecated warnings Mimi Zohar
2022-09-14 2:29 ` [PATCH ima-evm-utils v3 01/15] travis: update dist=focal Mimi Zohar
2022-09-14 2:29 ` [PATCH ima-evm-utils v3 02/15] Update configure.ac to address a couple of obsolete warnings Mimi Zohar
2022-09-14 2:29 ` [PATCH ima-evm-utils v3 03/15] Deprecate IMA signature version 1 Mimi Zohar
2022-09-14 2:29 ` [PATCH ima-evm-utils v3 04/15] Replace the low level SHA1 calls when calculating the TPM 1.2 PCRs Mimi Zohar
2022-09-14 2:29 ` [PATCH ima-evm-utils v3 05/15] Replace the low level HMAC calls when calculating the EVM HMAC Mimi Zohar
2022-09-14 2:29 ` [PATCH ima-evm-utils v3 06/15] Add missing EVP_MD_CTX_free() call in calc_evm_hash() Mimi Zohar
2022-09-14 14:51 ` Vitaly Chikunov
2022-09-15 11:58 ` Mimi Zohar
2022-09-15 15:36 ` Vitaly Chikunov
2022-09-16 13:07 ` Mimi Zohar [this message]
2022-09-14 2:29 ` [PATCH ima-evm-utils v3 07/15] Disable use of OpenSSL "engine" support Mimi Zohar
2022-09-14 16:38 ` Vitaly Chikunov
2022-09-14 2:29 ` [PATCH ima-evm-utils v3 08/15] Fix potential use after free in read_tpm_banks() Mimi Zohar
2022-09-14 2:29 ` [PATCH ima-evm-utils v3 09/15] Limit the file hash algorithm name length Mimi Zohar
2022-09-14 2:29 ` [PATCH ima-evm-utils v3 10/15] Missing template data size lower bounds checking Mimi Zohar
2022-09-14 2:29 ` [PATCH ima-evm-utils v3 11/15] Limit configuring OpenSSL engine support Mimi Zohar
2022-09-14 14:59 ` Vitaly Chikunov
2022-09-14 2:29 ` [PATCH ima-evm-utils v3 12/15] Base sm2/sm3 test on openssl version installed Mimi Zohar
2022-09-14 2:29 ` [PATCH ima-evm-utils v3 13/15] Compile a newer version of OpenSSL Mimi Zohar
2022-09-14 2:29 ` [PATCH ima-evm-utils v3 14/15] Build OpenSSL without engine support Mimi Zohar
2022-09-14 2:29 ` [PATCH ima-evm-utils v3 15/15] Fix d2i_x509_fp failure 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=17a92cfa3e8af21bb057abc374ff250c5c8b942b.camel@linux.ibm.com \
--to=zohar@linux.ibm.com \
--cc=linux-integrity@vger.kernel.org \
--cc=pvorel@suse.cz \
--cc=stefanb@linux.ibm.com \
--cc=vt@altlinux.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