]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
5.4-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 14 May 2021 13:45:38 +0000 (15:45 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 14 May 2021 13:45:38 +0000 (15:45 +0200)
added patches:
tpm-fix-error-return-code-in-tpm2_get_cc_attrs_tbl.patch
tpm-tpm_tis-extend-locality-handling-to-tpm2-in-tpm_tis_gen_interrupt.patch
tpm-tpm_tis-reserve-locality-in-tpm_tis_resume.patch

queue-5.4/tpm-fix-error-return-code-in-tpm2_get_cc_attrs_tbl.patch [new file with mode: 0644]
queue-5.4/tpm-tpm_tis-extend-locality-handling-to-tpm2-in-tpm_tis_gen_interrupt.patch [new file with mode: 0644]
queue-5.4/tpm-tpm_tis-reserve-locality-in-tpm_tis_resume.patch [new file with mode: 0644]

diff --git a/queue-5.4/tpm-fix-error-return-code-in-tpm2_get_cc_attrs_tbl.patch b/queue-5.4/tpm-fix-error-return-code-in-tpm2_get_cc_attrs_tbl.patch
new file mode 100644 (file)
index 0000000..cd3e578
--- /dev/null
@@ -0,0 +1,36 @@
+From 1df83992d977355177810c2b711afc30546c81ce Mon Sep 17 00:00:00 2001
+From: Zhen Lei <thunder.leizhen@huawei.com>
+Date: Wed, 12 May 2021 21:39:26 +0800
+Subject: tpm: fix error return code in tpm2_get_cc_attrs_tbl()
+
+From: Zhen Lei <thunder.leizhen@huawei.com>
+
+commit 1df83992d977355177810c2b711afc30546c81ce upstream.
+
+If the total number of commands queried through TPM2_CAP_COMMANDS is
+different from that queried through TPM2_CC_GET_CAPABILITY, it indicates
+an unknown error. In this case, an appropriate error code -EFAULT should
+be returned. However, we currently do not explicitly assign this error
+code to 'rc'. As a result, 0 was incorrectly returned.
+
+Cc: stable@vger.kernel.org
+Fixes: 58472f5cd4f6("tpm: validate TPM 2.0 commands")
+Reported-by: Hulk Robot <hulkci@huawei.com>
+Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
+Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
+Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/char/tpm/tpm2-cmd.c |    1 +
+ 1 file changed, 1 insertion(+)
+
+--- a/drivers/char/tpm/tpm2-cmd.c
++++ b/drivers/char/tpm/tpm2-cmd.c
+@@ -962,6 +962,7 @@ static int tpm2_get_cc_attrs_tbl(struct
+       if (nr_commands !=
+           be32_to_cpup((__be32 *)&buf.data[TPM_HEADER_SIZE + 5])) {
++              rc = -EFAULT;
+               tpm_buf_destroy(&buf);
+               goto out;
+       }
diff --git a/queue-5.4/tpm-tpm_tis-extend-locality-handling-to-tpm2-in-tpm_tis_gen_interrupt.patch b/queue-5.4/tpm-tpm_tis-extend-locality-handling-to-tpm2-in-tpm_tis_gen_interrupt.patch
new file mode 100644 (file)
index 0000000..72459f4
--- /dev/null
@@ -0,0 +1,49 @@
+From e630af7dfb450d1c00c30077314acf33032ff9e4 Mon Sep 17 00:00:00 2001
+From: Jarkko Sakkinen <jarkko@kernel.org>
+Date: Mon, 10 May 2021 15:28:30 +0300
+Subject: tpm, tpm_tis: Extend locality handling to TPM2 in tpm_tis_gen_interrupt()
+
+From: Jarkko Sakkinen <jarkko@kernel.org>
+
+commit e630af7dfb450d1c00c30077314acf33032ff9e4 upstream.
+
+The earlier fix (linked) only partially fixed the locality handling bug
+in tpm_tis_gen_interrupt(), i.e. only for TPM 1.x.
+
+Extend the locality handling to cover TPM2.
+
+Cc: Hans de Goede <hdegoede@redhat.com>
+Cc: stable@vger.kernel.org
+Link: https://lore.kernel.org/linux-integrity/20210220125534.20707-1-jarkko@kernel.org/
+Fixes: a3fbfae82b4c ("tpm: take TPM chip power gating out of tpm_transmit()")
+Reported-by: Lino Sanfilippo <LinoSanfilippo@gmx.de>
+Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
+Tested-by: Lino Sanfilippo <LinoSanfilippo@gmx.de>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/char/tpm/tpm_tis_core.c |   10 ++++------
+ 1 file changed, 4 insertions(+), 6 deletions(-)
+
+--- a/drivers/char/tpm/tpm_tis_core.c
++++ b/drivers/char/tpm/tpm_tis_core.c
+@@ -620,16 +620,14 @@ static int tpm_tis_gen_interrupt(struct
+       cap_t cap;
+       int ret;
+-      /* TPM 2.0 */
+-      if (chip->flags & TPM_CHIP_FLAG_TPM2)
+-              return tpm2_get_tpm_pt(chip, 0x100, &cap2, desc);
+-
+-      /* TPM 1.2 */
+       ret = request_locality(chip, 0);
+       if (ret < 0)
+               return ret;
+-      ret = tpm1_getcap(chip, TPM_CAP_PROP_TIS_TIMEOUT, &cap, desc, 0);
++      if (chip->flags & TPM_CHIP_FLAG_TPM2)
++              ret = tpm2_get_tpm_pt(chip, 0x100, &cap2, desc);
++      else
++              ret = tpm1_getcap(chip, TPM_CAP_PROP_TIS_TIMEOUT, &cap, desc, 0);
+       release_locality(chip, 0);
diff --git a/queue-5.4/tpm-tpm_tis-reserve-locality-in-tpm_tis_resume.patch b/queue-5.4/tpm-tpm_tis-reserve-locality-in-tpm_tis_resume.patch
new file mode 100644 (file)
index 0000000..393050b
--- /dev/null
@@ -0,0 +1,47 @@
+From 8a2d296aaebadd68d9c1f6908667df1d1c84c051 Mon Sep 17 00:00:00 2001
+From: Jarkko Sakkinen <jarkko@kernel.org>
+Date: Mon, 10 May 2021 15:28:31 +0300
+Subject: tpm, tpm_tis: Reserve locality in tpm_tis_resume()
+
+From: Jarkko Sakkinen <jarkko@kernel.org>
+
+commit 8a2d296aaebadd68d9c1f6908667df1d1c84c051 upstream.
+
+Reserve locality in tpm_tis_resume(), as it could be unsert after waking
+up from a sleep state.
+
+Cc: stable@vger.kernel.org
+Cc: Lino Sanfilippo <LinoSanfilippo@gmx.de>
+Reported-by: Hans de Goede <hdegoede@redhat.com>
+Fixes: a3fbfae82b4c ("tpm: take TPM chip power gating out of tpm_transmit()")
+Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/char/tpm/tpm_tis_core.c |   12 ++++++++++--
+ 1 file changed, 10 insertions(+), 2 deletions(-)
+
+--- a/drivers/char/tpm/tpm_tis_core.c
++++ b/drivers/char/tpm/tpm_tis_core.c
+@@ -1035,12 +1035,20 @@ int tpm_tis_resume(struct device *dev)
+       if (ret)
+               return ret;
+-      /* TPM 1.2 requires self-test on resume. This function actually returns
++      /*
++       * TPM 1.2 requires self-test on resume. This function actually returns
+        * an error code but for unknown reason it isn't handled.
+        */
+-      if (!(chip->flags & TPM_CHIP_FLAG_TPM2))
++      if (!(chip->flags & TPM_CHIP_FLAG_TPM2)) {
++              ret = request_locality(chip, 0);
++              if (ret < 0)
++                      return ret;
++
+               tpm1_do_selftest(chip);
++              release_locality(chip, 0);
++      }
++
+       return 0;
+ }
+ EXPORT_SYMBOL_GPL(tpm_tis_resume);