From patchwork Thu Aug 30 14:40:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Martinez Canillas X-Patchwork-Id: 10581823 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 02C8214E1 for ; Thu, 30 Aug 2018 14:40:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E68FD2BFFF for ; Thu, 30 Aug 2018 14:40:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E4B192BFE5; Thu, 30 Aug 2018 14:40:39 +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 7A2732BFFF for ; Thu, 30 Aug 2018 14:40:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729068AbeH3SnF (ORCPT ); Thu, 30 Aug 2018 14:43:05 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:45891 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728972AbeH3SnF (ORCPT ); Thu, 30 Aug 2018 14:43:05 -0400 Received: by mail-wr1-f67.google.com with SMTP id 20-v6so8289827wrb.12 for ; Thu, 30 Aug 2018 07:40:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=jf71dbTDnZLg6ikV/I6nIju0h7RyInX+sBkTaw47ynU=; b=FB8SwNIgVmCE8DcK21emOgLkDYyPONt95lAPf2LIRiynmF7WK2d8v/Le8jHKM+OAsO M+KVebSrbwIkxY9V8UD+3CMVzTMP5w4tkP2AtG4E+punBeGw3SK58u7ZwpNuOTt5aaaK yCUu2FIJFrAKL+sN3Gx4ISl9OpScByQFokdFFr5xduN8S45Py+jtX56AiHupylVQRaBk lkMfhW4gSlfisZpq0Cp5X0SDsUKMdkxRcsQ0N0I7IXqT3zoKEwJ9iJOYiaybsy4TXmV/ RXTXK92N8dIfWpHkisLoxgNpC+JMffF4/96RyaR0QSFMV0R5ZqiSjptBhLzasKbztEli vwcQ== X-Gm-Message-State: APzg51C77P1EU44N/FvoWkVmF8uXuC2RatKihaJSzqidwoIPQTUlxEjv Bh7V6jea5v3RaB6Fl7PJ8J/u8A== X-Google-Smtp-Source: ANB0VdYQXg5mjot/H+aOBXW+BTqBi3IldUDqTAruj94Haodejqsz+WKM5lPdUOmD/FnTYUF/Xt57sQ== X-Received: by 2002:adf:fd12:: with SMTP id e18-v6mr8115853wrr.280.1535640036335; Thu, 30 Aug 2018 07:40:36 -0700 (PDT) Received: from minerva.home ([90.168.169.92]) by smtp.gmail.com with ESMTPSA id m129-v6sm3141600wma.1.2018.08.30.07.40.35 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 30 Aug 2018 07:40:35 -0700 (PDT) From: Javier Martinez Canillas To: linux-kernel@vger.kernel.org Cc: Hans de Goede , Javier Martinez Canillas , Arnd Bergmann , Jarkko Sakkinen , Peter Huewe , Jason Gunthorpe , Greg Kroah-Hartman , linux-integrity@vger.kernel.org Subject: [PATCH] tpm: suppress transmit cmd error logs when TPM 1.2 is disabled/deactivated Date: Thu, 30 Aug 2018 16:40:05 +0200 Message-Id: <20180830144005.6768-1-javierm@redhat.com> X-Mailer: git-send-email 2.17.1 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 For TPM 1.2 chips the system setup utility allows to set the TPM device in one of the following states: * Active: Security chip is functional * Inactive: Security chip is visible, but is not functional * Disabled: Security chip is hidden and is not functional When choosing the "Inactive" state, the TPM 1.2 device is enumerated and registered, but sending TPM commands fail with either TPM_DEACTIVATED or TPM_DISABLED depending if the firmware deactivated or disabled the TPM. Since these TPM 1.2 error codes don't have special treatment, inactivating the TPM leads to a very noisy kernel log buffer that shows messages like the following: tpm_tis 00:05: 1.2 TPM (device-id 0x0, rev-id 78) tpm tpm0: A TPM error (6) occurred attempting to read a pcr value tpm tpm0: TPM is disabled/deactivated (0x6) tpm tpm0: A TPM error (6) occurred attempting get random tpm tpm0: A TPM error (6) occurred attempting to read a pcr value ima: No TPM chip found, activating TPM-bypass! (rc=6) tpm tpm0: A TPM error (6) occurred attempting get random tpm tpm0: A TPM error (6) occurred attempting get random tpm tpm0: A TPM error (6) occurred attempting get random tpm tpm0: A TPM error (6) occurred attempting get random Let's just suppress error log messages for the TPM_{DEACTIVATED,DISABLED} return codes, since this is expected when the TPM 1.2 is set to Inactive. In that case the kernel log is cleaner and less confusing for users, i.e: tpm_tis 00:05: 1.2 TPM (device-id 0x0, rev-id 78) tpm tpm0: TPM is disabled/deactivated (0x6) ima: No TPM chip found, activating TPM-bypass! (rc=6) Reported-by: Hans de Goede Signed-off-by: Javier Martinez Canillas Reviewed-by: Jarkko Sakkinen --- drivers/char/tpm/tpm-interface.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c index 1a803b0cf98..9f61106502a 100644 --- a/drivers/char/tpm/tpm-interface.c +++ b/drivers/char/tpm/tpm-interface.c @@ -663,7 +663,8 @@ ssize_t tpm_transmit_cmd(struct tpm_chip *chip, struct tpm_space *space, return len; err = be32_to_cpu(header->return_code); - if (err != 0 && desc) + if (err != 0 && err != TPM_ERR_DISABLED && err != TPM_ERR_DEACTIVATED + && desc) dev_err(&chip->dev, "A TPM error (%d) occurred %s\n", err, desc); if (err)