Merge ~paelzer/ubuntu/+source/qemu:lp-1903864-tpm-usage-issues-FOCAL into ubuntu/+source/qemu:ubuntu/focal-devel

Proposed by Christian Ehrhardt 
Status: Merged
Approved by: Christian Ehrhardt 
Approved revision: 684547c2897fc5b9a8449a9abc74a8a6851ef49b
Merge reported by: Christian Ehrhardt 
Merged at revision: 684547c2897fc5b9a8449a9abc74a8a6851ef49b
Proposed branch: ~paelzer/ubuntu/+source/qemu:lp-1903864-tpm-usage-issues-FOCAL
Merge into: ubuntu/+source/qemu:ubuntu/focal-devel
Diff against target: 136 lines (+114/-0)
3 files modified
debian/changelog (+7/-0)
debian/patches/series (+1/-0)
debian/patches/ubuntu/lp-1903864-tpm_emulator-Report-an-error-if-chardev-is-missing.patch (+106/-0)
Reviewer Review Type Date Requested Status
Robie Basak sru Approve
Canonical Server Team Pending
Canonical Server packageset reviewers Pending
Ubuntu Server Dev import team Pending
Review via email: mp+397417@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :
Revision history for this message
Robie Basak (racb) wrote :

commit 684547c2897fc5b9a8449a9abc74a8a6851ef49b tree ff5906bd8f26fa136c9f993eeed57ddd1a2299fa

review: Approve (sru)
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Bugs 1903864 + 1913395 got combined and rebased onto the latest security upload.
Content is still the same.

Tagged and Uploaded

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Uploaded, setting state to "merged"

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/debian/changelog b/debian/changelog
2index 9ab80c5..c875642 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -1,3 +1,10 @@
6+qemu (1:4.2-3ubuntu6.12) focal; urgency=medium
7+
8+ * d/p/u/lp-1903864-tpm_emulator-Report-an-error-if-chardev-is-missing.patch:
9+ fix tpm-emulator: parameter 'chardev' is missing (LP: #1903864)
10+
11+ -- Christian Ehrhardt <christian.ehrhardt@canonical.com> Thu, 28 Jan 2021 09:20:37 +0100
12+
13 qemu (1:4.2-3ubuntu6.11) focal; urgency=medium
14
15 * d/p/ubuntu/lp-1907656-s390x-s390-virtio-ccw-Reset-PCI-devices-during-subsy:
16diff --git a/debian/patches/series b/debian/patches/series
17index d4a07ee..310d0e9 100644
18--- a/debian/patches/series
19+++ b/debian/patches/series
20@@ -239,3 +239,4 @@ ubuntu/CVE-2020-25723.patch
21 ubuntu/CVE-2020-27616.patch
22 ubuntu/CVE-2020-27617.patch
23 ubuntu/lp-1907656-s390x-s390-virtio-ccw-Reset-PCI-devices-during-subsy.patch
24+ubuntu/lp-1903864-tpm_emulator-Report-an-error-if-chardev-is-missing.patch
25diff --git a/debian/patches/ubuntu/lp-1903864-tpm_emulator-Report-an-error-if-chardev-is-missing.patch b/debian/patches/ubuntu/lp-1903864-tpm_emulator-Report-an-error-if-chardev-is-missing.patch
26new file mode 100644
27index 0000000..f506eff
28--- /dev/null
29+++ b/debian/patches/ubuntu/lp-1903864-tpm_emulator-Report-an-error-if-chardev-is-missing.patch
30@@ -0,0 +1,106 @@
31+From 88f830745721ba8c9e9d2831c01045a6f130c1a6 Mon Sep 17 00:00:00 2001
32+From: Stefan Berger <stefanb@linux.vnet.ibm.com>
33+Date: Fri, 24 Jul 2020 08:57:26 -0400
34+Subject: [PATCH] tpm_emulator: Report an error if chardev is missing
35+MIME-Version: 1.0
36+Content-Type: text/plain; charset=UTF-8
37+Content-Transfer-Encoding: 8bit
38+
39+This patch fixes the odd error reporting when trying to send a file
40+descriptor to the TPM emulator if one has not passed a valid chardev.
41+
42+$ x86_64-softmmu/qemu-system-x86_64 -tpmdev emulator,id=tpm0
43+qemu-system-x86_64: -tpmdev emulator,id=tpm0: tpm-emulator: Failed to send CMD_SET_DATAFD: Success
44+qemu-system-x86_64: -tpmdev emulator,id=tpm0: tpm-emulator: Could not cleanly shutdown the TPM: Success
45+
46+This is the new error report:
47+
48+$ x86_64-softmmu/qemu-system-x86_64 -tpmdev emulator,id=tpm0
49+qemu-system-x86_64: -tpmdev emulator,id=tpm0: tpm-emulator: parameter 'chardev' is missing
50+
51+This change does not hide the display of supported TPM types if a non-existent type is passed:
52+
53+$ x86_64-softmmu/qemu-system-x86_64 -tpmdev nonexistent,id=tpm0
54+qemu-system-x86_64: -tpmdev nonexistent,id=tpm0: Parameter 'type' expects a TPM backend type
55+Supported TPM types (choose only one):
56+ passthrough Passthrough TPM backend driver
57+ emulator TPM emulator backend driver
58+
59+Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
60+Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
61+Reviewed-by: Markus Armbruster <armbru@redhat.com>
62+
63+Backport-Notes: path to tpm_emulator.c file was different
64+Origin: backport, https://git.qemu.org/?p=qemu.git;a=commit;h=88f830745721ba8c9e9d2831c01045a6f130c1a6
65+Bug-Ubuntu: https://bugs.launchpad.net/bugs/1903864
66+Last-Update: 2021-01-28
67+
68+---
69+ backends/tpm/tpm_emulator.c | 38 ++++++++++++++++++++++---------------
70+ 1 file changed, 23 insertions(+), 15 deletions(-)
71+
72+diff --git a/backends/tpm/tpm_emulator.c b/backends/tpm/tpm_emulator.c
73+index 9605339f93..a9b0f55e67 100644
74+--- a/hw/tpm/tpm_emulator.c
75++++ b/hw/tpm/tpm_emulator.c
76+@@ -549,27 +549,30 @@ err_exit:
77+ static int tpm_emulator_handle_device_opts(TPMEmulator *tpm_emu, QemuOpts *opts)
78+ {
79+ const char *value;
80++ Error *err = NULL;
81++ Chardev *dev;
82+
83+ value = qemu_opt_get(opts, "chardev");
84+- if (value) {
85+- Error *err = NULL;
86+- Chardev *dev = qemu_chr_find(value);
87+-
88+- if (!dev) {
89+- error_report("tpm-emulator: tpm chardev '%s' not found.", value);
90+- goto err;
91+- }
92++ if (!value) {
93++ error_report("tpm-emulator: parameter 'chardev' is missing");
94++ goto err;
95++ }
96+
97+- if (!qemu_chr_fe_init(&tpm_emu->ctrl_chr, dev, &err)) {
98+- error_prepend(&err, "tpm-emulator: No valid chardev found at '%s':",
99+- value);
100+- error_report_err(err);
101+- goto err;
102+- }
103++ dev = qemu_chr_find(value);
104++ if (!dev) {
105++ error_report("tpm-emulator: tpm chardev '%s' not found", value);
106++ goto err;
107++ }
108+
109+- tpm_emu->options->chardev = g_strdup(value);
110++ if (!qemu_chr_fe_init(&tpm_emu->ctrl_chr, dev, &err)) {
111++ error_prepend(&err, "tpm-emulator: No valid chardev found at '%s':",
112++ value);
113++ error_report_err(err);
114++ goto err;
115+ }
116+
117++ tpm_emu->options->chardev = g_strdup(value);
118++
119+ if (tpm_emulator_prepare_data_fd(tpm_emu) < 0) {
120+ goto err;
121+ }
122+@@ -925,6 +928,11 @@ static void tpm_emulator_shutdown(TPMEmulator *tpm_emu)
123+ {
124+ ptm_res res;
125+
126++ if (!tpm_emu->options->chardev) {
127++ /* was never properly initialized */
128++ return;
129++ }
130++
131+ if (tpm_emulator_ctrlcmd(tpm_emu, CMD_SHUTDOWN, &res, 0, sizeof(res)) < 0) {
132+ error_report("tpm-emulator: Could not cleanly shutdown the TPM: %s",
133+ strerror(errno));
134+--
135+2.30.0
136+

Subscribers

People subscribed via source and target branches