From patchwork Thu Jun 18 18:50:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Vorel X-Patchwork-Id: 11612911 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 494AA913 for ; Thu, 18 Jun 2020 18:50:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 38EBF207DD for ; Thu, 18 Jun 2020 18:50:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728069AbgFRSuq (ORCPT ); Thu, 18 Jun 2020 14:50:46 -0400 Received: from mx2.suse.de ([195.135.220.15]:33198 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725953AbgFRSup (ORCPT ); Thu, 18 Jun 2020 14:50:45 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 3E2C2ACED; Thu, 18 Jun 2020 18:50:44 +0000 (UTC) From: Petr Vorel To: linux-integrity@vger.kernel.org Cc: Petr Vorel , Mimi Zohar Subject: [PATCH ima-evm-utils 2/3] Don't run tsspcrread on systems without TPM Date: Thu, 18 Jun 2020 20:50:37 +0200 Message-Id: <20200618185038.21837-1-pvorel@suse.cz> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Sender: linux-integrity-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-integrity@vger.kernel.org as we don't have any algorithm: ./src/evmctl ima_boot_aggregate sh: -c: line 0: syntax error near unexpected token `(' sh: -c: line 0: `tsspcrread -halg (null) -ha 0 -ns 2> /dev/null' sh: -c: line 0: syntax error near unexpected token `(' sh: -c: line 0: `tsspcrread -halg (null) -ha 0 -ns 2> /dev/null' errno: No such file or directory (2) Now it just prints: errno: No such file or directory (2) Fixes: dc00c92 ("ima-evm-utils: calculate the per TPM bank boot_aggregate") Signed-off-by: Petr Vorel --- Hi Mimi, not really sure if this is a best place to handle the problem. Kind regards, Petr src/evmctl.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/evmctl.c b/src/evmctl.c index 94ec56b..03eeb6e 100644 --- a/src/evmctl.c +++ b/src/evmctl.c @@ -1796,6 +1796,12 @@ static int read_tpm_banks(int num_banks, struct tpm_bank_info *bank) for (i = 0; i < num_banks; i++) { err = 0; for (j = 0; j < NUM_PCRS && !err; j++) { + if (!bank[i].algo_name) { + log_debug("No algo_name for PCR: %d\n", i); + bank[i].supported = 0; + continue; + } + err = tpm2_pcr_read(bank[i].algo_name, j, bank[i].pcr[j], bank[i].digest_size, &errmsg); From patchwork Thu Jun 18 18:50:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Vorel X-Patchwork-Id: 11612913 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5102790 for ; Thu, 18 Jun 2020 18:50:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 402CE207DD for ; Thu, 18 Jun 2020 18:50:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728137AbgFRSur (ORCPT ); Thu, 18 Jun 2020 14:50:47 -0400 Received: from mx2.suse.de ([195.135.220.15]:33206 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725953AbgFRSuq (ORCPT ); Thu, 18 Jun 2020 14:50:46 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 3C233AD76; Thu, 18 Jun 2020 18:50:45 +0000 (UTC) From: Petr Vorel To: linux-integrity@vger.kernel.org Cc: Petr Vorel , Mimi Zohar Subject: [RFC PATCH ima-evm-utils 3/3] logging: Print also LOG_INFO messages Date: Thu, 18 Jun 2020 20:50:38 +0200 Message-Id: <20200618185038.21837-2-pvorel@suse.cz> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200618185038.21837-1-pvorel@suse.cz> References: <20200618185038.21837-1-pvorel@suse.cz> MIME-Version: 1.0 Sender: linux-integrity-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-integrity@vger.kernel.org as some errors are using it, e.g. in previous fix just errno would be printed: ./src/evmctl ima_boot_aggregate Failed to read any TPM PCRs errno: No such file or directory (2) Signed-off-by: Petr Vorel --- Hi Mimi, Just attempt to do quick fix. I guess reconsidering levels as code has changed would be better, but require more work. Kind regards, Petr src/libimaevm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libimaevm.c b/src/libimaevm.c index 683cfb8..4bcce13 100644 --- a/src/libimaevm.c +++ b/src/libimaevm.c @@ -82,7 +82,7 @@ static const char *const pkey_hash_algo_kern[PKEY_HASH__LAST] = { }; struct libimaevm_params imaevm_params = { - .verbose = LOG_INFO - 1, + .verbose = LOG_INFO, .x509 = 1, .hash_algo = "sha1", };