From patchwork Tue Jun 26 16:27:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: George Wilson X-Patchwork-Id: 10489521 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DEC6E60386 for ; Tue, 26 Jun 2018 16:28:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CED5B28478 for ; Tue, 26 Jun 2018 16:28:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C385828485; Tue, 26 Jun 2018 16:28:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6392B2847E for ; Tue, 26 Jun 2018 16:28:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751773AbeFZQ2D (ORCPT ); Tue, 26 Jun 2018 12:28:03 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:34878 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751094AbeFZQ2C (ORCPT ); Tue, 26 Jun 2018 12:28:02 -0400 Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w5QGO2Q8037729 for ; Tue, 26 Jun 2018 12:28:01 -0400 Received: from e14.ny.us.ibm.com (e14.ny.us.ibm.com [129.33.205.204]) by mx0b-001b2d01.pphosted.com with ESMTP id 2jup4a0fwg-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 26 Jun 2018 12:28:01 -0400 Received: from localhost by e14.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 26 Jun 2018 12:28:01 -0400 Received: from b01cxnp23032.gho.pok.ibm.com (9.57.198.27) by e14.ny.us.ibm.com (146.89.104.201) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Tue, 26 Jun 2018 12:27:59 -0400 Received: from b01ledav001.gho.pok.ibm.com (b01ledav001.gho.pok.ibm.com [9.57.199.106]) by b01cxnp23032.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w5QGRwqq19399050 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 26 Jun 2018 16:27:58 GMT Received: from b01ledav001.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D1DAF28059; Tue, 26 Jun 2018 12:27:39 -0400 (EDT) Received: from b01ledav001.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9E03128060; Tue, 26 Jun 2018 12:27:39 -0400 (EDT) Received: from witherspoon-1.localdomain (unknown [9.27.30.66]) by b01ledav001.gho.pok.ibm.com (Postfix) with ESMTP; Tue, 26 Jun 2018 12:27:39 -0400 (EDT) From: George Wilson To: linux-integrity@vger.kernel.org Cc: Mimi Zohar , George Wilson Subject: [PATCH] ima-evm-utils: check the return code from tpm_pcr_read() in ima_measurement() Date: Tue, 26 Jun 2018 10:27:18 -0600 X-Mailer: git-send-email 2.17.0.582.gccdcbd5 X-TM-AS-GCONF: 00 x-cbid: 18062616-0052-0000-0000-000003045A55 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00009259; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000266; SDB=6.01052654; UDB=6.00539660; IPR=6.00830579; MB=3.00021864; MTD=3.00000008; XFM=3.00000015; UTC=2018-06-26 16:27:59 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18062616-0053-0000-0000-00005D25CFD0 Message-Id: <20180626162718.4916-1-gcwilson@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-06-26_08:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=914 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1806210000 definitions=main-1806260185 Sender: linux-integrity-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-integrity@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Don't log garbage when neither /sys/class/tpm/tpm0/device/pcrs nor /sys/class/misc/tpm0/device/pcrs can be read and exit nicely with a value of 1. Signed-off-by: George Wilson --- src/evmctl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/evmctl.c b/src/evmctl.c index 2ffee78..a5c6221 100644 --- a/src/evmctl.c +++ b/src/evmctl.c @@ -1514,7 +1514,8 @@ static int ima_measurement(const char *file) log_info("PCRAgg %.2d: ", i); log_dump(pcr[i], SHA_DIGEST_LENGTH); - tpm_pcr_read(i, hwpcr, sizeof(hwpcr)); + if (tpm_pcr_read(i, hwpcr, sizeof(hwpcr))) + exit(1); log_info("HW PCR-%d: ", i); log_dump(hwpcr, sizeof(hwpcr));