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
diff --git a/debian/changelog b/debian/changelog
index 44f460d..42a9b2d 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,15 @@
1tpm2-tss (4.0.1-2ubuntu2) mantic; urgency=medium
2
3 * Fix FTBFS due to big-endian conversion issues (LP: #2031020)
4 + Apply tcti libtpms fixes for s390x s390x
5 d/p/0001-tss2-tcti-tcti-libtpms-fix-test-failure-on-big-endia.patch
6 + Fix big-endian issue in tcti-spi-helper
7 d/p/fix-tcti-spi-helper-big-endian.patch
8 + Fix failing tests on big-endian, due to broken binary test input files
9 d/p/disable-tests-on-big-endian.patch
10
11 -- Lukas Märdian <slyon@ubuntu.com> Tue, 22 Aug 2023 13:58:05 +0200
12
1tpm2-tss (4.0.1-2ubuntu1) mantic; urgency=medium13tpm2-tss (4.0.1-2ubuntu1) mantic; urgency=medium
214
3 * Merge from Debian unstable. Remaining changes:15 * Merge from Debian unstable. Remaining changes:
diff --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
4new file mode 10064416new file mode 100644
index 0000000..3868e44
--- /dev/null
+++ b/debian/patches/0001-tss2-tcti-tcti-libtpms-fix-test-failure-on-big-endia.patch
@@ -0,0 +1,52 @@
1From 9ae85535d6383a50731ad9e70c16b55622e126ae Mon Sep 17 00:00:00 2001
2From: "Ying-Chun Liu (PaulLiu)" <paulliu@debian.org>
3Date: Sun, 6 Aug 2023 05:24:02 +0800
4Subject: [PATCH] tss2-tcti: tcti-libtpms: fix test failure on big-endian
5 platform
6
7Due to tcti_libtpms->response_len and tcti_libtpms->response_buffer_len
8are size_t. We cannot convert the (size_t *) to (uint32_t *) on big-endian
9platforms. Thus we create temp uint32_t variables. Make the call and
10then assign it back to size_t variables.
11
12This commit partially fix the test failure on big-endian platforms.
13
14Signed-off-by: Ying-Chun Liu (PaulLiu) <paulliu@debian.org>
15---
16 src/tss2-tcti/tcti-libtpms.c | 11 +++++++++--
17 1 file changed, 9 insertions(+), 2 deletions(-)
18
19diff --git a/src/tss2-tcti/tcti-libtpms.c b/src/tss2-tcti/tcti-libtpms.c
20index 922a4402..10ed913d 100644
21--- a/src/tss2-tcti/tcti-libtpms.c
22+++ b/src/tss2-tcti/tcti-libtpms.c
23@@ -370,6 +370,8 @@ tcti_libtpms_transmit(
24 tpm_header_t header;
25 TSS2_RC rc;
26 TPM_RESULT ret;
27+ uint32_t resp_size;
28+ uint32_t respbufsize;
29
30 rc = tcti_common_transmit_checks(tcti_common, cmd_buf, TCTI_LIBTPMS_MAGIC);
31 if (rc != TSS2_RC_SUCCESS) {
32@@ -386,11 +388,16 @@ tcti_libtpms_transmit(
33 }
34
35 LOGBLOB_DEBUG(cmd_buf, size, "Sending command with TPM_CC 0x%" PRIx32, header.size);
36+ resp_size = (uint32_t) tcti_libtpms->response_len;
37+ respbufsize = (uint32_t) tcti_libtpms->response_buffer_len;
38 LIBTPMS_API_CALL(fail, tcti_libtpms, TPMLIB_Process, &tcti_libtpms->response_buffer,
39- (uint32_t *) &tcti_libtpms->response_len,
40- (uint32_t *) &tcti_libtpms->response_buffer_len,
41+ (uint32_t *) &resp_size,
42+ (uint32_t *) &respbufsize,
43 (uint8_t *) cmd_buf,
44 size);
45+ tcti_libtpms->response_len = resp_size;
46+ tcti_libtpms->response_buffer_len = respbufsize;
47+
48 rc = tcti_libtpms_store_state(tcti_libtpms);
49 if (rc != TSS2_RC_SUCCESS) {
50 LOG_ERROR("Failed to store state file");
51--
522.40.1
diff --git a/debian/patches/disable-tests-on-big-endian.patch b/debian/patches/disable-tests-on-big-endian.patch
0new file mode 10064453new file mode 100644
index 0000000..68a3670
--- /dev/null
+++ b/debian/patches/disable-tests-on-big-endian.patch
@@ -0,0 +1,60 @@
1Description: The test files (binaries) for IMA and system events contain little
2 endian integers which are assigned to the big endian integers with memcpy.
3 The conversion has to be fixed.
4Author: Lukas Märdian <slyon@ubuntu.com>
5Bug: https://github.com/tpm2-software/tpm2-tss/issues/2531
6Bug-Ubuntu: https://bugs.launchpad.net/bugs/2031020
7Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1040521
8Forwarded: not-needed
9Last-Update: 2023-08-22
10---
11--- tpm2-tss-4.0.1.orig/test/unit/fapi-eventlog.c
12+++ tpm2-tss-4.0.1/test/unit/fapi-eventlog.c
13@@ -8,6 +8,7 @@
14 #include <config.h>
15 #endif
16
17+#include <endian.h>
18 #include <stdarg.h>
19 #include <inttypes.h>
20 #include <string.h>
21@@ -168,6 +169,7 @@ int
22 main(int argc, char *argv[])
23 {
24 const struct CMUnitTest tests[] = {
25+# if __BYTE_ORDER == __LITTLE_ENDIAN
26 cmocka_unit_test(check_bios_nuc),
27 cmocka_unit_test(check_bios_pc_client),
28 cmocka_unit_test(check_event_uefiservices),
29@@ -175,6 +177,7 @@ main(int argc, char *argv[])
30 cmocka_unit_test(check_event_uefivar),
31 cmocka_unit_test(check_event),
32 cmocka_unit_test(check_specid_vendordata),
33+# endif
34 };
35 return cmocka_run_group_tests(tests, NULL, NULL);
36 }
37--- tpm2-tss-4.0.1.orig/test/unit/fapi-ima-eventlog.c
38+++ tpm2-tss-4.0.1/test/unit/fapi-ima-eventlog.c
39@@ -8,6 +8,7 @@
40 #include <config.h>
41 #endif
42
43+#include <endian.h>
44 #include <stdarg.h>
45 #include <inttypes.h>
46 #include <string.h>
47@@ -259,11 +260,13 @@ int
48 main(int argc, char *argv[])
49 {
50 const struct CMUnitTest tests[] = {
51+# if __BYTE_ORDER == __LITTLE_ENDIAN
52 cmocka_unit_test(check_invalidate_event),
53 cmocka_unit_test(check_get_name),
54 cmocka_unit_test(check_sml_ima_sha1),
55 cmocka_unit_test(check_sml_ima_ng_sha1),
56 cmocka_unit_test(check_sml_ima_sig_sha256),
57+# endif
58 };
59 return cmocka_run_group_tests(tests, NULL, NULL);
60 }
diff --git a/debian/patches/fix-tcti-spi-helper-big-endian.patch b/debian/patches/fix-tcti-spi-helper-big-endian.patch
0new file mode 10064461new file mode 100644
index 0000000..2778c78
--- /dev/null
+++ b/debian/patches/fix-tcti-spi-helper-big-endian.patch
@@ -0,0 +1,29 @@
1Description: uint32_t is converted to a void* buffer.
2 We need to convert it back to the correct endianess.
3Author: Lukas Märdian <slyon@ubuntu.com>
4Forwarded: https://github.com/tpm2-software/tpm2-tss/pull/2686
5Bug: https://github.com/tpm2-software/tpm2-tss/issues/2531
6Bug-Ubuntu: https://bugs.launchpad.net/bugs/2031020
7Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1040521
8Last-Update: 2023-08-22
9---
10--- tpm2-tss-4.0.1.orig/src/tss2-tcti/tcti-spi-helper.c
11+++ tpm2-tss-4.0.1/src/tss2-tcti/tcti-spi-helper.c
12@@ -2,6 +2,8 @@
13 /*
14 * Copyright 2020 Fraunhofer SIT. All rights reserved.
15 */
16+#define _BSD_SOURCE
17+#include <endian.h>
18 #include <errno.h>
19 #include <fcntl.h>
20 #include <inttypes.h>
21@@ -312,7 +314,7 @@ static uint32_t spi_tpm_helper_read_sts_
22 {
23 uint32_t status = 0;
24 spi_tpm_helper_read_reg(ctx, TCTI_SPI_HELPER_TPM_STS_REG, &status, sizeof(status));
25- return status;
26+ return le32toh(status);
27 }
28
29 static void spi_tpm_helper_write_sts_reg(TSS2_TCTI_SPI_HELPER_CONTEXT* ctx, uint32_t status)
diff --git a/debian/patches/series b/debian/patches/series
index 49ba955..b173354 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,3 +1,6 @@
10001_disable_fapi_io_test.patch10001_disable_fapi_io_test.patch
20002-fix-version.patch20002-fix-version.patch
30003-test-unit-tcti-libtpms-fix-test-failed-at-32-bit-pla.patch30003-test-unit-tcti-libtpms-fix-test-failed-at-32-bit-pla.patch
40001-tss2-tcti-tcti-libtpms-fix-test-failure-on-big-endia.patch
5fix-tcti-spi-helper-big-endian.patch
6disable-tests-on-big-endian.patch

Subscribers

People subscribed via source and target branches