linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jerry Snitselaar <jsnitsel@redhat.com>
To: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Cc: linux-integrity@vger.kernel.org, stable@vger.kernel.org,
	Roberto Sassu <roberto.sassu@huawei.com>,
	Peter Huewe <peterhuewe@gmx.de>, Jason Gunthorpe <jgg@ziepe.ca>,
	Arnd Bergmann <arnd@arndb.de>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] tpm: Call tpm_put_ops() when the validation for @digests fails
Date: Tue, 10 Sep 2019 08:11:21 -0700	[thread overview]
Message-ID: <20190910151121.3tgzwuhrroog5dvb@cantor> (raw)
In-Reply-To: <20190910142437.20889-1-jarkko.sakkinen@linux.intel.com>

On Tue Sep 10 19, Jarkko Sakkinen wrote:
>The chip is not released when the validation for @digests fails. Add
>tpm_put_ops() to the failure path.
>
>Cc: stable@vger.kernel.org
>Reported-by: Roberto Sassu <roberto.sassu@huawei.com>
>Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>

Reviewed-by: Jerry Snitselaar <jsnitsel@redhat.com>

>---
> drivers/char/tpm/tpm-interface.c | 14 +++++++++-----
> 1 file changed, 9 insertions(+), 5 deletions(-)
>
>diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c
>index 208e5ba40e6e..c7eeb40feac8 100644
>--- a/drivers/char/tpm/tpm-interface.c
>+++ b/drivers/char/tpm/tpm-interface.c
>@@ -320,18 +320,22 @@ int tpm_pcr_extend(struct tpm_chip *chip, u32 pcr_idx,
> 	if (!chip)
> 		return -ENODEV;
>
>-	for (i = 0; i < chip->nr_allocated_banks; i++)
>-		if (digests[i].alg_id != chip->allocated_banks[i].alg_id)
>-			return -EINVAL;
>+	for (i = 0; i < chip->nr_allocated_banks; i++) {
>+		if (digests[i].alg_id != chip->allocated_banks[i].alg_id) {
>+			rc = EINVAL;
>+			goto out;
>+		}
>+	}
>
> 	if (chip->flags & TPM_CHIP_FLAG_TPM2) {
> 		rc = tpm2_pcr_extend(chip, pcr_idx, digests);
>-		tpm_put_ops(chip);
>-		return rc;
>+		goto out;
> 	}
>
> 	rc = tpm1_pcr_extend(chip, pcr_idx, digests[0].digest,
> 			     "attempting extend a PCR value");
>+
>+out:
> 	tpm_put_ops(chip);
> 	return rc;
> }
>-- 
>2.20.1
>

  reply	other threads:[~2019-09-10 15:11 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-10 14:24 [PATCH] tpm: Call tpm_put_ops() when the validation for @digests fails Jarkko Sakkinen
2019-09-10 15:11 ` Jerry Snitselaar [this message]
2019-09-13 13:50   ` Jarkko Sakkinen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190910151121.3tgzwuhrroog5dvb@cantor \
    --to=jsnitsel@redhat.com \
    --cc=arnd@arndb.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=jarkko.sakkinen@linux.intel.com \
    --cc=jgg@ziepe.ca \
    --cc=linux-integrity@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterhuewe@gmx.de \
    --cc=roberto.sassu@huawei.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).