Merge ~slyon/ubuntu/+source/tpm2-tss:disable-s390x-features into ubuntu/+source/tpm2-tss:ubuntu/devel

Proposed by Lukas Märdian
Status: Merged
Merge reported by: Lukas Märdian
Merged at revision: fc4c2cbfac3af899d660955620aba1814f090343
Proposed branch: ~slyon/ubuntu/+source/tpm2-tss:disable-s390x-features
Merge into: ubuntu/+source/tpm2-tss:ubuntu/devel
Diff against target: 190 lines (+156/-0)
5 files modified
debian/changelog (+12/-0)
debian/patches/0001-tss2-tcti-tcti-libtpms-fix-test-failure-on-big-endia.patch (+52/-0)
debian/patches/disable-tests-on-big-endian.patch (+60/-0)
debian/patches/fix-tcti-spi-helper-big-endian.patch (+29/-0)
debian/patches/series (+3/-0)
Reviewer Review Type Date Requested Status
Lukas Märdian (community) Approve
git-ubuntu import Pending
Review via email: mp+449200@code.launchpad.net
To post a comment you must log in.
19c52de... by Lukas Märdian

Fix big-endian issue in tcti-spi-helper

debian/patches/fix-tcti-spi-helper-big-endian.patch

c9ad1b2... by Lukas Märdian

Fix failing tests on big-endian, due to broken binary test input files

debian/patches/disable-tests-on-big-endian.patch

fc4c2cb... by Lukas Märdian

Update changelog

Revision history for this message
Lukas Märdian (slyon) wrote :

I uploaded this into the archive myself. It also got accepted into Debian meanwhile.

review: Approve

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 44f460d..42a9b2d 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -1,3 +1,15 @@
6+tpm2-tss (4.0.1-2ubuntu2) mantic; urgency=medium
7+
8+ * Fix FTBFS due to big-endian conversion issues (LP: #2031020)
9+ + Apply tcti libtpms fixes for s390x s390x
10+ d/p/0001-tss2-tcti-tcti-libtpms-fix-test-failure-on-big-endia.patch
11+ + Fix big-endian issue in tcti-spi-helper
12+ d/p/fix-tcti-spi-helper-big-endian.patch
13+ + Fix failing tests on big-endian, due to broken binary test input files
14+ d/p/disable-tests-on-big-endian.patch
15+
16+ -- Lukas Märdian <slyon@ubuntu.com> Tue, 22 Aug 2023 13:58:05 +0200
17+
18 tpm2-tss (4.0.1-2ubuntu1) mantic; urgency=medium
19
20 * Merge from Debian unstable. Remaining changes:
21diff --git a/debian/patches/0001-tss2-tcti-tcti-libtpms-fix-test-failure-on-big-endia.patch b/debian/patches/0001-tss2-tcti-tcti-libtpms-fix-test-failure-on-big-endia.patch
22new file mode 100644
23index 0000000..3868e44
24--- /dev/null
25+++ b/debian/patches/0001-tss2-tcti-tcti-libtpms-fix-test-failure-on-big-endia.patch
26@@ -0,0 +1,52 @@
27+From 9ae85535d6383a50731ad9e70c16b55622e126ae Mon Sep 17 00:00:00 2001
28+From: "Ying-Chun Liu (PaulLiu)" <paulliu@debian.org>
29+Date: Sun, 6 Aug 2023 05:24:02 +0800
30+Subject: [PATCH] tss2-tcti: tcti-libtpms: fix test failure on big-endian
31+ platform
32+
33+Due to tcti_libtpms->response_len and tcti_libtpms->response_buffer_len
34+are size_t. We cannot convert the (size_t *) to (uint32_t *) on big-endian
35+platforms. Thus we create temp uint32_t variables. Make the call and
36+then assign it back to size_t variables.
37+
38+This commit partially fix the test failure on big-endian platforms.
39+
40+Signed-off-by: Ying-Chun Liu (PaulLiu) <paulliu@debian.org>
41+---
42+ src/tss2-tcti/tcti-libtpms.c | 11 +++++++++--
43+ 1 file changed, 9 insertions(+), 2 deletions(-)
44+
45+diff --git a/src/tss2-tcti/tcti-libtpms.c b/src/tss2-tcti/tcti-libtpms.c
46+index 922a4402..10ed913d 100644
47+--- a/src/tss2-tcti/tcti-libtpms.c
48++++ b/src/tss2-tcti/tcti-libtpms.c
49+@@ -370,6 +370,8 @@ tcti_libtpms_transmit(
50+ tpm_header_t header;
51+ TSS2_RC rc;
52+ TPM_RESULT ret;
53++ uint32_t resp_size;
54++ uint32_t respbufsize;
55+
56+ rc = tcti_common_transmit_checks(tcti_common, cmd_buf, TCTI_LIBTPMS_MAGIC);
57+ if (rc != TSS2_RC_SUCCESS) {
58+@@ -386,11 +388,16 @@ tcti_libtpms_transmit(
59+ }
60+
61+ LOGBLOB_DEBUG(cmd_buf, size, "Sending command with TPM_CC 0x%" PRIx32, header.size);
62++ resp_size = (uint32_t) tcti_libtpms->response_len;
63++ respbufsize = (uint32_t) tcti_libtpms->response_buffer_len;
64+ LIBTPMS_API_CALL(fail, tcti_libtpms, TPMLIB_Process, &tcti_libtpms->response_buffer,
65+- (uint32_t *) &tcti_libtpms->response_len,
66+- (uint32_t *) &tcti_libtpms->response_buffer_len,
67++ (uint32_t *) &resp_size,
68++ (uint32_t *) &respbufsize,
69+ (uint8_t *) cmd_buf,
70+ size);
71++ tcti_libtpms->response_len = resp_size;
72++ tcti_libtpms->response_buffer_len = respbufsize;
73++
74+ rc = tcti_libtpms_store_state(tcti_libtpms);
75+ if (rc != TSS2_RC_SUCCESS) {
76+ LOG_ERROR("Failed to store state file");
77+--
78+2.40.1
79diff --git a/debian/patches/disable-tests-on-big-endian.patch b/debian/patches/disable-tests-on-big-endian.patch
80new file mode 100644
81index 0000000..68a3670
82--- /dev/null
83+++ b/debian/patches/disable-tests-on-big-endian.patch
84@@ -0,0 +1,60 @@
85+Description: The test files (binaries) for IMA and system events contain little
86+ endian integers which are assigned to the big endian integers with memcpy.
87+ The conversion has to be fixed.
88+Author: Lukas Märdian <slyon@ubuntu.com>
89+Bug: https://github.com/tpm2-software/tpm2-tss/issues/2531
90+Bug-Ubuntu: https://bugs.launchpad.net/bugs/2031020
91+Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1040521
92+Forwarded: not-needed
93+Last-Update: 2023-08-22
94+---
95+--- tpm2-tss-4.0.1.orig/test/unit/fapi-eventlog.c
96++++ tpm2-tss-4.0.1/test/unit/fapi-eventlog.c
97+@@ -8,6 +8,7 @@
98+ #include <config.h>
99+ #endif
100+
101++#include <endian.h>
102+ #include <stdarg.h>
103+ #include <inttypes.h>
104+ #include <string.h>
105+@@ -168,6 +169,7 @@ int
106+ main(int argc, char *argv[])
107+ {
108+ const struct CMUnitTest tests[] = {
109++# if __BYTE_ORDER == __LITTLE_ENDIAN
110+ cmocka_unit_test(check_bios_nuc),
111+ cmocka_unit_test(check_bios_pc_client),
112+ cmocka_unit_test(check_event_uefiservices),
113+@@ -175,6 +177,7 @@ main(int argc, char *argv[])
114+ cmocka_unit_test(check_event_uefivar),
115+ cmocka_unit_test(check_event),
116+ cmocka_unit_test(check_specid_vendordata),
117++# endif
118+ };
119+ return cmocka_run_group_tests(tests, NULL, NULL);
120+ }
121+--- tpm2-tss-4.0.1.orig/test/unit/fapi-ima-eventlog.c
122++++ tpm2-tss-4.0.1/test/unit/fapi-ima-eventlog.c
123+@@ -8,6 +8,7 @@
124+ #include <config.h>
125+ #endif
126+
127++#include <endian.h>
128+ #include <stdarg.h>
129+ #include <inttypes.h>
130+ #include <string.h>
131+@@ -259,11 +260,13 @@ int
132+ main(int argc, char *argv[])
133+ {
134+ const struct CMUnitTest tests[] = {
135++# if __BYTE_ORDER == __LITTLE_ENDIAN
136+ cmocka_unit_test(check_invalidate_event),
137+ cmocka_unit_test(check_get_name),
138+ cmocka_unit_test(check_sml_ima_sha1),
139+ cmocka_unit_test(check_sml_ima_ng_sha1),
140+ cmocka_unit_test(check_sml_ima_sig_sha256),
141++# endif
142+ };
143+ return cmocka_run_group_tests(tests, NULL, NULL);
144+ }
145diff --git a/debian/patches/fix-tcti-spi-helper-big-endian.patch b/debian/patches/fix-tcti-spi-helper-big-endian.patch
146new file mode 100644
147index 0000000..2778c78
148--- /dev/null
149+++ b/debian/patches/fix-tcti-spi-helper-big-endian.patch
150@@ -0,0 +1,29 @@
151+Description: uint32_t is converted to a void* buffer.
152+ We need to convert it back to the correct endianess.
153+Author: Lukas Märdian <slyon@ubuntu.com>
154+Forwarded: https://github.com/tpm2-software/tpm2-tss/pull/2686
155+Bug: https://github.com/tpm2-software/tpm2-tss/issues/2531
156+Bug-Ubuntu: https://bugs.launchpad.net/bugs/2031020
157+Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1040521
158+Last-Update: 2023-08-22
159+---
160+--- tpm2-tss-4.0.1.orig/src/tss2-tcti/tcti-spi-helper.c
161++++ tpm2-tss-4.0.1/src/tss2-tcti/tcti-spi-helper.c
162+@@ -2,6 +2,8 @@
163+ /*
164+ * Copyright 2020 Fraunhofer SIT. All rights reserved.
165+ */
166++#define _BSD_SOURCE
167++#include <endian.h>
168+ #include <errno.h>
169+ #include <fcntl.h>
170+ #include <inttypes.h>
171+@@ -312,7 +314,7 @@ static uint32_t spi_tpm_helper_read_sts_
172+ {
173+ uint32_t status = 0;
174+ spi_tpm_helper_read_reg(ctx, TCTI_SPI_HELPER_TPM_STS_REG, &status, sizeof(status));
175+- return status;
176++ return le32toh(status);
177+ }
178+
179+ static void spi_tpm_helper_write_sts_reg(TSS2_TCTI_SPI_HELPER_CONTEXT* ctx, uint32_t status)
180diff --git a/debian/patches/series b/debian/patches/series
181index 49ba955..b173354 100644
182--- a/debian/patches/series
183+++ b/debian/patches/series
184@@ -1,3 +1,6 @@
185 0001_disable_fapi_io_test.patch
186 0002-fix-version.patch
187 0003-test-unit-tcti-libtpms-fix-test-failed-at-32-bit-pla.patch
188+0001-tss2-tcti-tcti-libtpms-fix-test-failure-on-big-endia.patch
189+fix-tcti-spi-helper-big-endian.patch
190+disable-tests-on-big-endian.patch

Subscribers

People subscribed via source and target branches