Patch tpm2-tss for CVE-2023-22745 (#4807)
This commit is contained in:
Родитель
3c713ca93d
Коммит
03c63e5bad
|
@ -0,0 +1,113 @@
|
|||
diff --git a/src/tss2-rc/tss2_rc.c b/src/tss2-rc/tss2_rc.c
|
||||
index b0c6f96..1fd74e2 100644
|
||||
--- a/src/tss2-rc/tss2_rc.c
|
||||
+++ b/src/tss2-rc/tss2_rc.c
|
||||
@@ -1,5 +1,8 @@
|
||||
/* SPDX-License-Identifier: BSD-2-Clause */
|
||||
-
|
||||
+#ifdef HAVE_CONFIG_H
|
||||
+#include "config.h"
|
||||
+#endif
|
||||
+#include <assert.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
@@ -835,7 +838,7 @@ tss_err_handler (TSS2_RC rc)
|
||||
static struct {
|
||||
char name[TSS2_ERR_LAYER_NAME_MAX];
|
||||
TSS2_RC_HANDLER handler;
|
||||
-} layer_handler[TPM2_ERROR_TSS2_RC_LAYER_COUNT] = {
|
||||
+} layer_handler[TPM2_ERROR_TSS2_RC_LAYER_COUNT + 1] = {
|
||||
ADD_HANDLER("tpm" , tpm2_ehandler),
|
||||
ADD_NULL_HANDLER, /* layer 1 is unused */
|
||||
ADD_NULL_HANDLER, /* layer 2 is unused */
|
||||
@@ -870,7 +873,7 @@ unknown_layer_handler(TSS2_RC rc)
|
||||
static __thread char buf[32];
|
||||
|
||||
clearbuf(buf);
|
||||
- catbuf(buf, "0x%X", tpm2_error_get(rc));
|
||||
+ catbuf(buf, "0x%X", rc);
|
||||
|
||||
return buf;
|
||||
}
|
||||
@@ -967,19 +970,27 @@ Tss2_RC_Decode(TSS2_RC rc)
|
||||
catbuf(buf, "%u:", layer);
|
||||
}
|
||||
|
||||
- handler = !handler ? unknown_layer_handler : handler;
|
||||
-
|
||||
/*
|
||||
* Handlers only need the error bits. This way they don't
|
||||
* need to concern themselves with masking off the layer
|
||||
* bits or anything else.
|
||||
*/
|
||||
- UINT16 err_bits = tpm2_error_get(rc);
|
||||
- const char *e = err_bits ? handler(err_bits) : "success";
|
||||
- if (e) {
|
||||
- catbuf(buf, "%s", e);
|
||||
+ if (handler) {
|
||||
+ UINT16 err_bits = tpm2_error_get(rc);
|
||||
+ const char *e = err_bits ? handler(err_bits) : "success";
|
||||
+ if (e) {
|
||||
+ catbuf(buf, "%s", e);
|
||||
+ } else {
|
||||
+ catbuf(buf, "0x%X", err_bits);
|
||||
+ }
|
||||
} else {
|
||||
- catbuf(buf, "0x%X", err_bits);
|
||||
+ /*
|
||||
+ * we don't want to drop any bits if we don't know what to do with it
|
||||
+ * so drop the layer byte since we we already have that.
|
||||
+ */
|
||||
+ const char *e = unknown_layer_handler(rc >> 8);
|
||||
+ assert(e);
|
||||
+ catbuf(buf, "%s", e);
|
||||
}
|
||||
|
||||
return buf;
|
||||
diff --git a/test/unit/test_tss2_rc.c b/test/unit/test_tss2_rc.c
|
||||
index 1c8d66c..9369bed 100644
|
||||
--- a/test/unit/test_tss2_rc.c
|
||||
+++ b/test/unit/test_tss2_rc.c
|
||||
@@ -198,7 +198,7 @@ test_custom_handler(void **state)
|
||||
* Test an unknown layer
|
||||
*/
|
||||
e = Tss2_RC_Decode(rc);
|
||||
- assert_string_equal(e, "1:0x2A");
|
||||
+ assert_string_equal(e, "1:0x100");
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -281,6 +281,23 @@ test_tcti(void **state)
|
||||
assert_string_equal(e, "tcti:Fails to connect to next lower layer");
|
||||
}
|
||||
|
||||
+static void
|
||||
+test_all_FFs(void **state)
|
||||
+{
|
||||
+ (void) state;
|
||||
+
|
||||
+ const char *e = Tss2_RC_Decode(0xFFFFFFFF);
|
||||
+ assert_string_equal(e, "255:0xFFFFFF");
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
+test_all_FFs_set_handler(void **state)
|
||||
+{
|
||||
+ (void) state;
|
||||
+ Tss2_RC_SetHandler(0xFF, "garbage", custom_err_handler);
|
||||
+ Tss2_RC_SetHandler(0xFF, NULL, NULL);
|
||||
+}
|
||||
+
|
||||
/* link required symbol, but tpm2_tool.c declares it AND main, which
|
||||
* we have a main below for cmocka tests.
|
||||
*/
|
||||
@@ -312,6 +329,8 @@ main(int argc, char* argv[])
|
||||
cmocka_unit_test(test_esys),
|
||||
cmocka_unit_test(test_mu),
|
||||
cmocka_unit_test(test_tcti),
|
||||
+ cmocka_unit_test(test_all_FFs),
|
||||
+ cmocka_unit_test(test_all_FFs_set_handler)
|
||||
};
|
||||
|
||||
return cmocka_run_group_tests(tests, NULL, NULL);
|
|
@ -1,13 +1,14 @@
|
|||
Summary: OSS implementation of the TCG TPM2 Software Stack (TSS2)
|
||||
Name: tpm2-tss
|
||||
Version: 2.4.6
|
||||
Release: 1%{?dist}
|
||||
Release: 2%{?dist}
|
||||
License: BSD
|
||||
Vendor: Microsoft Corporation
|
||||
Distribution: Mariner
|
||||
Group: System Environment/Security
|
||||
URL: https://github.com/tpm2-software/tpm2-tss
|
||||
Source0: https://github.com/tpm2-software/tpm2-tss/releases/download/%{version}/%{name}-%{version}.tar.gz
|
||||
Patch0: CVE-2023-22745.patch
|
||||
BuildRequires: json-c-devel
|
||||
BuildRequires: openssl-devel
|
||||
Requires: json-c
|
||||
|
@ -28,7 +29,7 @@ Requires: %{name} = %{version}-%{release}
|
|||
The libraries and header files needed for TSS2 development.
|
||||
|
||||
%prep
|
||||
%setup -q
|
||||
%autosetup -p1
|
||||
|
||||
%build
|
||||
%configure \
|
||||
|
@ -88,6 +89,9 @@ fi
|
|||
%{_mandir}/man7/*
|
||||
|
||||
%changelog
|
||||
* Wed Feb 08 2023 Rachel Menge <rachelmenge@microsoft.com> - 2.4.6-2
|
||||
- Add patch to resolve CVE-2023-22745
|
||||
|
||||
* Tue Jan 18 2022 Daniel McIlvaney <damcilva@microsoft.com> - 2.4.6-1
|
||||
- Update to version 2.4.6
|
||||
- Verified license
|
||||
|
|
Загрузка…
Ссылка в новой задаче