Re: [PATCH v2] ima-evm-utils: use tsspcrread to read the TPM 2.0 PCRs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Mimi,

On Tue, Jul 23, 2019 at 03:37:28PM -0400, Mimi Zohar wrote:
> On Tue, 2019-07-23 at 22:31 +0300, Vitaly Chikunov wrote:
> > 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.

I thought you will post new version anyway with `strdup(pcr)` fix so why
not add `asprintf` in the same time. If you don't want I can post change
after release.

Currently, I try to make `make check` tests. (Don't want you to wait
for them before release too.)

Thanks,




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux Kernel]     [Linux Kernel Hardening]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux