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

Proposed by Christian Ehrhardt 
Status: Merged
Approved by: Christian Ehrhardt 
Approved revision: 41cff4af734a54a184b37064c6c3565a47179c72
Merge reported by: Christian Ehrhardt 
Merged at revision: 41cff4af734a54a184b37064c6c3565a47179c72
Proposed branch: ~paelzer/ubuntu/+source/qemu:lp-1903864-tpm-usage-issues-GROOVY
Merge into: ubuntu/+source/qemu:ubuntu/groovy-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 Pending
git-ubuntu developers Pending
Review via email: mp+397418@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 41cff4af734a54a184b37064c6c3565a47179c72 tree ff6d18285ed4b1d87303c24ca9a94fa5bcfa5066

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

Subscribers

People subscribed via source and target branches