From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 31814C76186 for ; Tue, 23 Jul 2019 19:31:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 108432064C for ; Tue, 23 Jul 2019 19:31:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730188AbfGWTbS (ORCPT ); Tue, 23 Jul 2019 15:31:18 -0400 Received: from vmicros1.altlinux.org ([194.107.17.57]:48084 "EHLO vmicros1.altlinux.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726308AbfGWTbS (ORCPT ); Tue, 23 Jul 2019 15:31:18 -0400 Received: from imap.altlinux.org (imap.altlinux.org [194.107.17.38]) by vmicros1.altlinux.org (Postfix) with ESMTP id 1D65A72CCDE; Tue, 23 Jul 2019 22:31:15 +0300 (MSK) Received: from altlinux.org (sole.flsd.net [185.75.180.6]) by imap.altlinux.org (Postfix) with ESMTPSA id 04B7C4A4AE8; Tue, 23 Jul 2019 22:31:15 +0300 (MSK) Date: Tue, 23 Jul 2019 22:31:14 +0300 From: Vitaly Chikunov To: Mimi Zohar Cc: "Bruno E. O. Meneguele" , linux-integrity@vger.kernel.org, Petr Vorel , Dmitry Eremin-Solenikov Subject: Re: [PATCH v2] ima-evm-utils: use tsspcrread to read the TPM 2.0 PCRs Message-ID: <20190723193114.vqwuiu6lcxdjyvhv@altlinux.org> Mail-Followup-To: Mimi Zohar , "Bruno E. O. Meneguele" , linux-integrity@vger.kernel.org, Petr Vorel , Dmitry Eremin-Solenikov References: <1563893743-4586-1-git-send-email-zohar@linux.ibm.com> <20190723154759.GB16649@glitch> <1563897190.14396.144.camel@linux.ibm.com> <20190723164144.ewrcvrod7m6rahkg@altlinux.org> <1563906293.14396.163.camel@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=koi8-r Content-Disposition: inline In-Reply-To: <1563906293.14396.163.camel@linux.ibm.com> User-Agent: NeoMutt/20171215-106-ac61c7 Sender: linux-integrity-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-integrity@vger.kernel.org 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. Thanks,