[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL v1 32/32] tpm: tpm_passthrough: Fail startup if FE bu
From: |
Stefan Berger |
Subject: |
[Qemu-devel] [PULL v1 32/32] tpm: tpm_passthrough: Fail startup if FE buffer size < BE buffer size |
Date: |
Sat, 16 Dec 2017 12:41:49 -0500 |
If the requested buffer size of the frontend is smaller than the fixed
buffer size of the host's TPM, fail the startup_tpm() interface function,
which will make the device unusable. We fail it because the backend TPM
could produce larger packets than what the frontend could pass to the OS.
The current combination of TIS frontend and either passthrough or emulator
backend will not lead to this case since the TIS can support any size of
buffer.
Signed-off-by: Stefan Berger <address@hidden>
Reviewed-by: Marc-André Lureau <address@hidden>
---
hw/tpm/tpm_passthrough.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/hw/tpm/tpm_passthrough.c b/hw/tpm/tpm_passthrough.c
index 886af9e..487aae2 100644
--- a/hw/tpm/tpm_passthrough.c
+++ b/hw/tpm/tpm_passthrough.c
@@ -304,6 +304,20 @@ static TPMBackend *tpm_passthrough_create(QemuOpts *opts)
return TPM_BACKEND(obj);
}
+static int tpm_passthrough_startup_tpm(TPMBackend *tb, size_t buffersize)
+{
+ TPMPassthruState *tpm_pt = TPM_PASSTHROUGH(tb);
+
+ if (buffersize && buffersize < tpm_pt->tpm_buffersize) {
+ error_report("Requested buffer size of %zu is smaller than host TPM's "
+ "fixed buffer size of %zu",
+ buffersize, tpm_pt->tpm_buffersize);
+ return -1;
+ }
+
+ return 0;
+}
+
static TpmTypeOptions *tpm_passthrough_get_tpm_options(TPMBackend *tb)
{
TpmTypeOptions *options = g_new0(TpmTypeOptions, 1);
@@ -362,6 +376,7 @@ static void tpm_passthrough_class_init(ObjectClass *klass,
void *data)
tbc->opts = tpm_passthrough_cmdline_opts;
tbc->desc = "Passthrough TPM backend driver";
tbc->create = tpm_passthrough_create;
+ tbc->startup_tpm = tpm_passthrough_startup_tpm;
tbc->reset = tpm_passthrough_reset;
tbc->cancel_cmd = tpm_passthrough_cancel_cmd;
tbc->get_tpm_established_flag = tpm_passthrough_get_tpm_established_flag;
--
2.5.5
- [Qemu-devel] [PULL v1 22/32] tpm-emulator: add a FIXME comment about blocking cancel, (continued)
- [Qemu-devel] [PULL v1 22/32] tpm-emulator: add a FIXME comment about blocking cancel, Stefan Berger, 2017/12/16
- [Qemu-devel] [PULL v1 23/32] tpm-tis: remove redundant 'tpm_tis:' in error messages, Stefan Berger, 2017/12/16
- [Qemu-devel] [PULL v1 25/32] qdev: add DEFINE_PROP_TPMBE, Stefan Berger, 2017/12/16
- [Qemu-devel] [PULL v1 24/32] tpm-tis: check that at most one TPM device exists, Stefan Berger, 2017/12/16
- [Qemu-devel] [PULL v1 26/32] tpm-tis: use DEFINE_PROP_TPMBE, Stefan Berger, 2017/12/16
- [Qemu-devel] [PULL v1 27/32] tpm: remove tpm_register_model(), Stefan Berger, 2017/12/16
- [Qemu-devel] [PULL v1 30/32] tpm: tpm_passthrough: Read the buffer size from the host device, Stefan Berger, 2017/12/16
- [Qemu-devel] [PULL v1 28/32] tpm: Move getting TPM buffer size to backends, Stefan Berger, 2017/12/16
- [Qemu-devel] [PULL v1 29/32] tpm: pull tpm_util_request() out of tpm_util_test(), Stefan Berger, 2017/12/16
- [Qemu-devel] [PULL v1 31/32] tpm: tpm_emulator: get and set buffer size of device, Stefan Berger, 2017/12/16
- [Qemu-devel] [PULL v1 32/32] tpm: tpm_passthrough: Fail startup if FE buffer size < BE buffer size,
Stefan Berger <=
- Re: [Qemu-devel] [PULL v1 00/32] Merge tpm 2017/12/15, Peter Maydell, 2017/12/17