From: Mimi Zohar <zohar@linux.ibm.com>
To: Vitaly Chikunov <vt@altlinux.org>
Cc: "Bruno E. O. Meneguele" <bmeneg@redhat.com>,
linux-integrity@vger.kernel.org, Petr Vorel <pvorel@suse.cz>,
Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Subject: Re: [PATCH v2] ima-evm-utils: use tsspcrread to read the TPM 2.0 PCRs
Date: Tue, 23 Jul 2019 15:37:28 -0400 [thread overview]
Message-ID: <1563910648.4294.2.camel@linux.ibm.com> (raw)
In-Reply-To: <20190723193114.vqwuiu6lcxdjyvhv@altlinux.org>
On Tue, 2019-07-23 at 22:31 +0300, Vitaly Chikunov wrote:
> Mimi,
>
> On Tue, Jul 23, 2019 at 02:24:53PM -0400, Mimi Zohar wrote:
> > On Tue, 2019-07-23 at 19:41 +0300, Vitaly Chikunov wrote:
> > > On Tue, Jul 23, 2019 at 11:53:10AM -0400, Mimi Zohar wrote:
> > > > On Tue, 2019-07-23 at 12:47 -0300, Bruno E. O. Meneguele wrote:
> > > >
> > > > > > @@ -1402,6 +1400,41 @@ static int tpm_pcr_read(int idx, uint8_t *pcr, int len)
> > > > > > return result;
> > > > > > }
> > > > > >
> > > > > > +#ifdef HAVE_TSSPCRREAD
> > > > > > +static int tpm2_pcr_read(int idx, uint8_t *hwpcr, int len, char **errmsg)
> > > > > > +{
> > > > > > + FILE *fp;
> > > > > > + char pcr[100]; /* may contain an error */
> > > > > > + char cmd[50];
> > > > > > + int ret;
> > > > > > +
> > > > > > + sprintf(cmd, "tsspcrread -halg sha1 -ha %d -ns 2> /dev/null", idx);
> > > > > > + fp = popen(cmd, "r");
> > > > > > + if (!fp) {
> > > > > > + snprintf(pcr, sizeof(pcr), "popen failed: %s", strerror(errno));
> > > > > > + *errmsg = strdup("popen failed:");
> > > > >
> > > > > Should it have been
> > > > >
> > > > > *errmsg = strdup(pcr);
> > > > >
> > > > Yes, of course.
> > >
> > > Or better to use asprintf(3).
> >
> > That's even better, assuming that we want to include
> > AC_USE_SYSTEM_EXTENSIONS in configure.ac?
>
> Yes.
>
> > Did you want to make this change as a separate patch, or should I fold
> > it into this one?
>
> Probably you, since you are first to add snprintf+strdup.
I didn't mean instead of this patch, but in addition to, on top of
this patch with the "strdup(pcr)" correction.
Mimi
next prev parent reply other threads:[~2019-07-23 19:38 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-23 14:55 [PATCH v2] ima-evm-utils: use tsspcrread to read the TPM 2.0 PCRs Mimi Zohar
2019-07-23 15:47 ` Bruno E. O. Meneguele
2019-07-23 15:53 ` Mimi Zohar
2019-07-23 16:41 ` Vitaly Chikunov
2019-07-23 18:24 ` Mimi Zohar
2019-07-23 19:31 ` Vitaly Chikunov
2019-07-23 19:37 ` Mimi Zohar [this message]
2019-07-23 19:41 ` Vitaly Chikunov
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=1563910648.4294.2.camel@linux.ibm.com \
--to=zohar@linux.ibm.com \
--cc=bmeneg@redhat.com \
--cc=dbaryshkov@gmail.com \
--cc=linux-integrity@vger.kernel.org \
--cc=pvorel@suse.cz \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.