Stable Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] tpm: Call tpm_put_ops() when the validation for @digests fails
@ 2019-09-10 14:24 Jarkko Sakkinen
  2019-09-10 15:11 ` Jerry Snitselaar
  0 siblings, 1 reply; 3+ messages in thread
From: Jarkko Sakkinen @ 2019-09-10 14:24 UTC (permalink / raw)
  To: linux-integrity
  Cc: Jarkko Sakkinen, stable, Roberto Sassu, Peter Huewe,
	Jason Gunthorpe, Arnd Bergmann, Greg Kroah-Hartman, linux-kernel

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>
---
 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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] tpm: Call tpm_put_ops() when the validation for @digests fails
  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
  2019-09-13 13:50   ` Jarkko Sakkinen
  0 siblings, 1 reply; 3+ messages in thread
From: Jerry Snitselaar @ 2019-09-10 15:11 UTC (permalink / raw)
  To: Jarkko Sakkinen
  Cc: linux-integrity, stable, Roberto Sassu, Peter Huewe,
	Jason Gunthorpe, Arnd Bergmann, Greg Kroah-Hartman, open list

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
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] tpm: Call tpm_put_ops() when the validation for @digests fails
  2019-09-10 15:11 ` Jerry Snitselaar
@ 2019-09-13 13:50   ` Jarkko Sakkinen
  0 siblings, 0 replies; 3+ messages in thread
From: Jarkko Sakkinen @ 2019-09-13 13:50 UTC (permalink / raw)
  To: linux-integrity, stable, Roberto Sassu, Peter Huewe,
	Jason Gunthorpe, Arnd Bergmann, Greg Kroah-Hartman, open list

On Tue, Sep 10, 2019 at 08:11:21AM -0700, Jerry Snitselaar wrote:
> 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>

Roberto, can you just squash this fix with yours to a single patch and
send a new patch version? You can add suggested-by tag from me to v4.

/Jarkko

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2019-09-13 13:50   ` Jarkko Sakkinen

Stable Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/stable/0 stable/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 stable stable/ https://lore.kernel.org/stable \
		stable@vger.kernel.org stable@archiver.kernel.org
	public-inbox-index stable

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.stable


AGPL code for this site: git clone https://public-inbox.org/ public-inbox