New Upstream Release - libtpms
Ready changes
Summary
Merged new upstream version: 0.9.6 (was: 0.9.2).
Resulting package
Built on 2023-07-13T01:55 (took 6m58s)
The resulting binary packages can be installed (if you have the apt repository enabled) by running one of:
apt install -t fresh-releases libtpms-devapt install -t fresh-releases libtpms0-dbgsymapt install -t fresh-releases libtpms0
Lintian Result
Diff
diff --git a/CHANGES b/CHANGES
index bba88c9..4f24c4e 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,25 @@
CHANGES - changes for libtpms
+version 0.9.6:
+ - tpm2: Check size of buffer before accessing it (CVE-2023-1017 & -1018)
+
+version 0.9.5:
+ - tpm2: Do not set RSA_FLAG_NO_BLINDING on RSA keys anymore
+ - tpm2: Fix a potential overflow expression (coverity)
+ - tpm2: Fix size check in CryptSecretDecrypt
+
+version 0.9.4:
+ - tpm: #undef printf in case it is #define'd (OSS-Fuzz)
+ - tpm2: Check return code of BN_div()
+ - tpm2: Initialize variables due to gcc complaint (s390x, false positive)
+ - tpm12: Initialize variables due to gcc complaint (s390x, false positive)
+ - build-sys: Fix configure script to support _FORTIFY_SOURCE=3
+
+version 0.9.3:
+ - build-sys: Add probing for -fstack-protector
+ - tpm2: Do not call EVP_PKEY_CTX_set0_rsa_oaep_label() for label of size
+ (OSSL 3)
+
version 0.9.2:
- tpm2: When writing state initialize s_ContextSlotMask if not set
diff --git a/configure.ac b/configure.ac
index ea76130..664f9a3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3,7 +3,7 @@
#
# See the LICENSE file for the license associated with this file.
-AC_INIT([libtpms],[0.9.2])
+AC_INIT([libtpms],[0.9.6])
AC_PREREQ([2.69])
AC_CONFIG_SRCDIR(Makefile.am)
AC_CONFIG_AUX_DIR([.])
@@ -284,19 +284,20 @@ AC_ARG_ENABLE([hardening],
AS_HELP_STRING([--disable-hardening], [Disable hardening flags]))
if test "x$enable_hardening" != "xno"; then
- # Some versions of gcc fail with -Wstack-protector enabled
- TMP="$($CC -fstack-protector-strong $srcdir/include/libtpms/tpm_error.h 2>&1)"
- if echo $TMP | $GREP 'unrecognized command line option' >/dev/null; then
- HARDENING_CFLAGS="-fstack-protector "
+ # Some versions of gcc fail with -Wstack-protector,
+ # some with -Wstack-protector-strong enabled
+ if ! $CC -fstack-protector-strong $srcdir/include/libtpms/tpm_error.h 2>/dev/null; then
+ if $CC -fstack-protector $srcdir/include/libtpms/tpm_error.h 2>/dev/null; then
+ HARDENING_CFLAGS="-fstack-protector "
+ fi
else
HARDENING_CFLAGS="-fstack-protector-strong "
fi
- dnl Must not have -O0 but must have a -O for -D_FORTIFY_SOURCE=2
- TMP1="$(echo $CFLAGS | sed -n 's/.*\(-O0\).*/\1/p')"
- TMP2="$(echo $CFLAGS | sed -n 's/.*\(-O\).*/\1/p')"
- if test -z "$TMP1" && test -n "$TPM2"; then
- HARDENING_CFLAGS="$HARDENING_CFLAGS -D_FORTIFY_SOURCE=2 "
+ dnl Only support -D_FORTIFY_SOURCE=2 and have higher levels passed in by user
+ dnl since they may create more overhead
+ if $CC $CFLAGS -Werror -D_FORTIFY_SOURCE=2 $srcdir/include/libtpms/tpm_library.h 2>/dev/null; then
+ HARDENING_CFLAGS="$HARDENING_CFLAGS -D_FORTIFY_SOURCE=2"
fi
dnl Check linker for 'relro' and 'now'
save_CFLAGS="$CFLAGS"
diff --git a/debian/changelog b/debian/changelog
index 9f1b620..07f3d25 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,42 @@
+libtpms (0.9.6-1) UNRELEASED; urgency=low
+
+ * New upstream release.
+ * Drop patch tpm2-Check-size-of-buffer-before-accessing-it-CVE-20.patch,
+ present upstream.
+
+ -- Debian Janitor <janitor@jelmer.uk> Thu, 13 Jul 2023 01:48:55 -0000
+
+libtpms (0.9.6) RELEASED; urgency=high
+
+ - tpm2: Check size of buffer before accessing it (CVE-2023-1017 & -1018)
+
+ -- Stefan Berger <stefanb@linux.ibm.com> Tue, 28 Feb 2023 09:00:00 -0500
+
+libtpms (0.9.5) RELEASED; urgency=medium
+
+ - tpm2: Do not set RSA_FLAG_NO_BLINDING on RSA keys anymore
+ - tpm2: Fix a potential overflow expression (coverity)
+ - tpm2: Fix size check in CryptSecretDecrypt
+
+ -- Stefan Berger <stefanb@linux.ibm.com> Fri, 01 Jul 2022 09:00:00 -0500
+
+libtpms (0.9.4) RELEASED; urgency=medium
+
+ - tpm: #undef printf in case it is #define'd (OSS-Fuzz)
+ - tpm2: Check return code of BN_div()
+ - tpm2: Initialize variables due to gcc complaint (s390x, false positive)
+ - tpm12: Initialize variables due to gcc complaint (s390x, false positive)
+ - build-sys: Fix configure script to support _FORTIFY_SOURCE=3
+
+ -- Stefan Berger <stefanb@linux.ibm.com> Mon, 25 Apr 2022 09:00:00 -0500
+
+libtpms (0.9.3) RELEASED; urgency=medium
+
+ - build-sys: Add probing for -fstack-protector
+ - tpm2: Do not call EVP_PKEY_CTX_set0_rsa_oaep_label() for label of size (OSSL 3)
+
+ -- Stefan Berger <stefanb@linux.ibm.com> Mon, 07 Mar 2022 09:00:00 -0500
+
libtpms (0.9.2-3.1) unstable; urgency=medium
* Non-maintainer upload.
diff --git a/debian/patches/0003-set-man-page-date-to-last-changelog.patch b/debian/patches/0003-set-man-page-date-to-last-changelog.patch
index 39d4a19..0ab95e7 100644
--- a/debian/patches/0003-set-man-page-date-to-last-changelog.patch
+++ b/debian/patches/0003-set-man-page-date-to-last-changelog.patch
@@ -1,9 +1,11 @@
Description: Set the date of man pages to the last changelog entry.
Forwarded: not-needed
---- a/man/man3/Makefile.am
-+++ b/man/man3/Makefile.am
-@@ -55,11 +55,14 @@
+Index: libtpms.git/man/man3/Makefile.am
+===================================================================
+--- libtpms.git.orig/man/man3/Makefile.am
++++ libtpms.git/man/man3/Makefile.am
+@@ -55,11 +55,14 @@ man3_MANS_generated = \
TPM_Malloc.3
man3_MANS += $(man3_MANS_generated)
diff --git a/debian/patches/0004-fix-ftbfs-bug.patch b/debian/patches/0004-fix-ftbfs-bug.patch
index a8e456b..4d65fed 100644
--- a/debian/patches/0004-fix-ftbfs-bug.patch
+++ b/debian/patches/0004-fix-ftbfs-bug.patch
@@ -1,9 +1,11 @@
Description: Fix FTBFS caused by the incomplete condition.
Forwarded: not-needed
---- a/src/tpm2/NVDynamic.c
-+++ b/src/tpm2/NVDynamic.c
-@@ -122,7 +122,7 @@
+Index: libtpms.git/src/tpm2/NVDynamic.c
+===================================================================
+--- libtpms.git.orig/src/tpm2/NVDynamic.c
++++ libtpms.git/src/tpm2/NVDynamic.c
+@@ -122,7 +122,7 @@ NvNextByType(
if(HandleGetType(nvHandle) == type)
break;
}
diff --git a/debian/patches/do_not_inline_makeiv.patch b/debian/patches/do_not_inline_makeiv.patch
index 393e2ac..f93519f 100644
--- a/debian/patches/do_not_inline_makeiv.patch
+++ b/debian/patches/do_not_inline_makeiv.patch
@@ -6,9 +6,11 @@ The ppc64 gcc compiler has an issue with MakeIv.
src/tpm2/AlgorithmTests.c | 3 +++
1 file changed, 3 insertions(+)
---- a/src/tpm2/AlgorithmTests.c
-+++ b/src/tpm2/AlgorithmTests.c
-@@ -179,6 +179,9 @@
+Index: libtpms.git/src/tpm2/AlgorithmTests.c
+===================================================================
+--- libtpms.git.orig/src/tpm2/AlgorithmTests.c
++++ libtpms.git/src/tpm2/AlgorithmTests.c
+@@ -179,6 +179,9 @@ TestSMAC(
/* 10.2.1.4.1 MakeIv() */
/* Internal function to make the appropriate IV depending on the mode. */
static UINT32
diff --git a/debian/patches/no_local_check.patch b/debian/patches/no_local_check.patch
index c7f461e..105c2eb 100644
--- a/debian/patches/no_local_check.patch
+++ b/debian/patches/no_local_check.patch
@@ -8,9 +8,11 @@ on Ubuntu Jammy.
src/Makefile.am | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
---- a/src/Makefile.am
-+++ b/src/Makefile.am
-@@ -599,7 +599,7 @@
+Index: libtpms.git/src/Makefile.am
+===================================================================
+--- libtpms.git.orig/src/Makefile.am
++++ libtpms.git/src/Makefile.am
+@@ -599,7 +599,7 @@ LDFLAGS_ARCH += $(findstring -m32, $(AM_
LDFLAGS_ARCH += $(findstring -m64, $(AM_LDFLAGS))
check-local: SHELL?="/usr/bin/env bash"
diff --git a/debian/patches/series b/debian/patches/series
index 1f4b815..a7d63d9 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -2,4 +2,3 @@
0004-fix-ftbfs-bug.patch
do_not_inline_makeiv.patch
no_local_check.patch
-tpm2-Check-size-of-buffer-before-accessing-it-CVE-20.patch
diff --git a/debian/patches/tpm2-Check-size-of-buffer-before-accessing-it-CVE-20.patch b/debian/patches/tpm2-Check-size-of-buffer-before-accessing-it-CVE-20.patch
deleted file mode 100644
index 89fef6a..0000000
--- a/debian/patches/tpm2-Check-size-of-buffer-before-accessing-it-CVE-20.patch
+++ /dev/null
@@ -1,55 +0,0 @@
-From: Stefan Berger <stefanb@linux.ibm.com>
-Date: Mon, 20 Feb 2023 14:41:10 -0500
-Subject: tpm2: Check size of buffer before accessing it (CVE-2023-1017 &
- -1018)
-Origin: https://github.com/stefanberger/libtpms/commit/324dbb4c27ae789c73b69dbf4611242267919dd4
-Bug-Debian: https://bugs.debian.org/1032420
-Bug-Debian-Security: https://security-tracker.debian.org/tracker/CVE-2023-1018
-Bug-Debian-Security: https://security-tracker.debian.org/tracker/CVE-2023-1017
-
-Check that there are sufficient bytes in the buffer before reading the
-cipherSize from it. Also, reduce the bufferSize variable by the number
-of bytes that make up the cipherSize to avoid reading and writing bytes
-beyond the buffer in subsequent steps that do in-place decryption.
-
-This fixes CVE-2023-1017 & CVE-2023-1018.
-
-Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
----
- src/tpm2/CryptUtil.c | 6 ++++++
- 1 file changed, 6 insertions(+)
-
-diff --git a/src/tpm2/CryptUtil.c b/src/tpm2/CryptUtil.c
-index 002fde0987a9..8fae5b6903ca 100644
---- a/src/tpm2/CryptUtil.c
-+++ b/src/tpm2/CryptUtil.c
-@@ -830,6 +830,10 @@ CryptParameterDecryption(
- + sizeof(session->sessionKey.t.buffer)));
- TPM2B_HMAC_KEY key; // decryption key
- UINT32 cipherSize = 0; // size of cipher text
-+
-+ if (leadingSizeInByte > bufferSize)
-+ return TPM_RC_INSUFFICIENT;
-+
- // Retrieve encrypted data size.
- if(leadingSizeInByte == 2)
- {
-@@ -837,6 +841,7 @@ CryptParameterDecryption(
- // data to be decrypted
- cipherSize = (UINT32)BYTE_ARRAY_TO_UINT16(buffer);
- buffer = &buffer[2]; // advance the buffer
-+ bufferSize -= 2;
- }
- #ifdef TPM4B
- else if(leadingSizeInByte == 4)
-@@ -844,6 +849,7 @@ CryptParameterDecryption(
- // the leading size is four bytes so get the four byte size field
- cipherSize = BYTE_ARRAY_TO_UINT32(buffer);
- buffer = &buffer[4]; //advance pointer
-+ bufferSize -= 4;
- }
- #endif
- else
---
-2.39.2
-
diff --git a/dist/libtpms.spec b/dist/libtpms.spec
index b372a23..d37d1bc 100644
--- a/dist/libtpms.spec
+++ b/dist/libtpms.spec
@@ -1,8 +1,8 @@
# --- libtpm rpm-spec ---
%define name libtpms
-%define version 0.9.2
-%define release 0~dev1
+%define version 0.9.6
+%define release 1
# Valid crypto subsystems are 'freebl' and 'openssl'
%if "%{?crypto_subsystem}" == ""
@@ -112,6 +112,18 @@ rm -f $RPM_BUILD_ROOT%{_libdir}/libtpms.la
%postun -p /sbin/ldconfig
%changelog
+* Tue Feb 28 2023 Stefan Berger - 0.9.6-1
+- tpm2: Check size of buffer before accessing it (CVE-2023-1017 & -1018)
+
+* Fri Jul 01 2022 Stefan Berger - 0.9.5-1
+- Release of version 0.9.5
+
+* Mon Apr 25 2022 Stefan Berger - 0.9.4-1
+- Release of version 0.9.4
+
+* Mon Mar 07 2022 Stefan Berger - 0.9.3-1
+- Release of version 0.9.3
+
* Thu Jan 06 2022 Stefan Berger - 0.9.2-1
- Release of version 0.9.2
diff --git a/dist/libtpms.spec.in b/dist/libtpms.spec.in
index a051a94..7ce779c 100644
--- a/dist/libtpms.spec.in
+++ b/dist/libtpms.spec.in
@@ -2,7 +2,7 @@
%define name @PACKAGE@
%define version @VERSION@
-%define release 0~dev1
+%define release 1
# Valid crypto subsystems are 'freebl' and 'openssl'
%if "%{?crypto_subsystem}" == ""
@@ -112,6 +112,18 @@ rm -f $RPM_BUILD_ROOT%{_libdir}/libtpms.la
%postun -p /sbin/ldconfig
%changelog
+* Tue Feb 28 2023 Stefan Berger - 0.9.6-1
+- tpm2: Check size of buffer before accessing it (CVE-2023-1017 & -1018)
+
+* Fri Jul 01 2022 Stefan Berger - 0.9.5-1
+- Release of version 0.9.5
+
+* Mon Apr 25 2022 Stefan Berger - 0.9.4-1
+- Release of version 0.9.4
+
+* Mon Mar 07 2022 Stefan Berger - 0.9.3-1
+- Release of version 0.9.3
+
* Thu Jan 06 2022 Stefan Berger - 0.9.2-1
- Release of version 0.9.2
diff --git a/include/libtpms/tpm_library.h b/include/libtpms/tpm_library.h
index df7079d..78411c3 100644
--- a/include/libtpms/tpm_library.h
+++ b/include/libtpms/tpm_library.h
@@ -50,7 +50,7 @@ extern "C" {
#define TPM_LIBRARY_VER_MAJOR 0
#define TPM_LIBRARY_VER_MINOR 9
-#define TPM_LIBRARY_VER_MICRO 2
+#define TPM_LIBRARY_VER_MICRO 6
#define TPM_LIBRARY_VERSION_GEN(MAJ, MIN, MICRO) \
(( MAJ << 16 ) | ( MIN << 8 ) | ( MICRO ))
diff --git a/src/tpm12/tpm_nvram.c b/src/tpm12/tpm_nvram.c
index 1235973..b67e36c 100644
--- a/src/tpm12/tpm_nvram.c
+++ b/src/tpm12/tpm_nvram.c
@@ -1290,7 +1290,7 @@ TPM_RESULT TPM_Process_NVReadValue(tpm_state_t *tpm_state,
TPM_BOOL physicalPresence;
TPM_BOOL isGPIO = FALSE;
BYTE *gpioData = NULL;
- TPM_NV_DATA_SENSITIVE *d1NvdataSensitive;
+ TPM_NV_DATA_SENSITIVE *d1NvdataSensitive = NULL;
uint32_t s1Last;
/* output parameters */
diff --git a/src/tpm2/BnMath.c b/src/tpm2/BnMath.c
index 0154fb5..67832f1 100644
--- a/src/tpm2/BnMath.c
+++ b/src/tpm2/BnMath.c
@@ -426,7 +426,7 @@ BnSetBit(
// Grow the number if necessary to set the bit.
while(bn->size <= offset)
bn->d[bn->size++] = 0;
- bn->d[offset] |= (crypt_uword_t)(1 << RADIX_MOD(bitNum));
+ bn->d[offset] |= ((crypt_uword_t)1 << RADIX_MOD(bitNum));
return TRUE;
}
/* 10.2.3.3.17 BnTestBit() */
diff --git a/src/tpm2/CryptUtil.c b/src/tpm2/CryptUtil.c
index 9879f91..8fae5b6 100644
--- a/src/tpm2/CryptUtil.c
+++ b/src/tpm2/CryptUtil.c
@@ -732,7 +732,7 @@ CryptSecretDecrypt(
nonceCaller->t.size);
}
// make sure secret will fit
- if(secret->t.size > data->t.size)
+ if(secret->t.size > sizeof(data->t.buffer))
return TPM_RC_FAILURE;
data->t.size = secret->t.size;
// CFB decrypt, using nonceCaller as iv
@@ -830,6 +830,10 @@ CryptParameterDecryption(
+ sizeof(session->sessionKey.t.buffer)));
TPM2B_HMAC_KEY key; // decryption key
UINT32 cipherSize = 0; // size of cipher text
+
+ if (leadingSizeInByte > bufferSize)
+ return TPM_RC_INSUFFICIENT;
+
// Retrieve encrypted data size.
if(leadingSizeInByte == 2)
{
@@ -837,6 +841,7 @@ CryptParameterDecryption(
// data to be decrypted
cipherSize = (UINT32)BYTE_ARRAY_TO_UINT16(buffer);
buffer = &buffer[2]; // advance the buffer
+ bufferSize -= 2;
}
#ifdef TPM4B
else if(leadingSizeInByte == 4)
@@ -844,6 +849,7 @@ CryptParameterDecryption(
// the leading size is four bytes so get the four byte size field
cipherSize = BYTE_ARRAY_TO_UINT32(buffer);
buffer = &buffer[4]; //advance pointer
+ bufferSize -= 4;
}
#endif
else
diff --git a/src/tpm2/Marshal.c b/src/tpm2/Marshal.c
index a3fa08a..fe83b21 100644
--- a/src/tpm2/Marshal.c
+++ b/src/tpm2/Marshal.c
@@ -2195,7 +2195,7 @@ UINT16
TPM2B_NV_PUBLIC_Marshal(TPM2B_NV_PUBLIC *source, BYTE **buffer, INT32 *size)
{
UINT16 written = 0;
- BYTE *sizePtr;
+ BYTE *sizePtr = NULL;
if (buffer != NULL) {
sizePtr = *buffer;
diff --git a/src/tpm2/crypto/openssl/CryptRsa.c b/src/tpm2/crypto/openssl/CryptRsa.c
index 4ed0438..b5d6b6c 100644
--- a/src/tpm2/crypto/openssl/CryptRsa.c
+++ b/src/tpm2/crypto/openssl/CryptRsa.c
@@ -1356,10 +1356,9 @@ CryptRsaEncrypt(
if (tmp == NULL)
ERROR_RETURN(TPM_RC_FAILURE);
memcpy(tmp, label->buffer, label->size);
+ if (EVP_PKEY_CTX_set0_rsa_oaep_label(ctx, tmp, label->size) <= 0)
+ ERROR_RETURN(TPM_RC_FAILURE);
}
- // label->size == 0 is supported
- if (EVP_PKEY_CTX_set0_rsa_oaep_label(ctx, tmp, label->size) <= 0)
- ERROR_RETURN(TPM_RC_FAILURE);
tmp = NULL;
break;
default:
diff --git a/src/tpm2/crypto/openssl/Helpers.c b/src/tpm2/crypto/openssl/Helpers.c
index f47cdbf..896e37d 100644
--- a/src/tpm2/crypto/openssl/Helpers.c
+++ b/src/tpm2/crypto/openssl/Helpers.c
@@ -439,8 +439,6 @@ InitOpenSSLRSAPublicKey(OBJECT *key, // IN
EVP_PKEY_assign_RSA(*pkey, rsakey) == 0)
ERROR_RETURN(TPM_RC_FAILURE)
- RSA_set_flags(rsakey, RSA_FLAG_NO_BLINDING);
-
retVal = TPM_RC_SUCCESS;
Exit:
@@ -521,8 +519,7 @@ InitOpenSSLRSAPrivateKey(OBJECT *rsaKey, // IN
ERROR_RETURN(TPM_RC_FAILURE);
/* Q = N/P; no remainder */
BN_set_flags(P, BN_FLG_CONSTTIME); // P is secret
- BN_div(Q, Qr, N, P, ctx);
- if(!BN_is_zero(Qr))
+ if (!BN_div(Q, Qr, N, P, ctx) || !BN_is_zero(Qr))
ERROR_RETURN(TPM_RC_BINDING);
BN_set_flags(Q, BN_FLG_CONSTTIME); // Q is secret
diff --git a/src/tpm_debug.h b/src/tpm_debug.h
index a9671d6..30f7c6a 100644
--- a/src/tpm_debug.h
+++ b/src/tpm_debug.h
@@ -66,6 +66,9 @@ extern int swallow_rc;
#endif /* TPM_DEBUG */
#endif
+#ifdef printf
+# undef printf
+#endif
#define printf(...) TPMLIB_LogPrintf(__VA_ARGS__);
#endif
Debdiff
[The following lists of changes regard files as different if they have different names, permissions or owners.]
Files in second set of .debs but not in first
-rw-r--r-- root/root /usr/lib/debug/.build-id/0c/62e5320c029a9af9700c938854a2afbfdf2a84.debug -rw-r--r-- root/root /usr/lib/x86_64-linux-gnu/libtpms.so.0.9.6 lrwxrwxrwx root/root /usr/lib/x86_64-linux-gnu/libtpms.so -> libtpms.so.0.9.6 lrwxrwxrwx root/root /usr/lib/x86_64-linux-gnu/libtpms.so.0 -> libtpms.so.0.9.6
Files in first set of .debs but not in second
-rw-r--r-- root/root /usr/lib/debug/.build-id/a4/1f770c1bbdfc0795a5671e2b33f987246110db.debug -rw-r--r-- root/root /usr/lib/x86_64-linux-gnu/libtpms.so.0.9.2 lrwxrwxrwx root/root /usr/lib/x86_64-linux-gnu/libtpms.so -> libtpms.so.0.9.2 lrwxrwxrwx root/root /usr/lib/x86_64-linux-gnu/libtpms.so.0 -> libtpms.so.0.9.2
No differences were encountered between the control files of package libtpms-dev
No differences were encountered between the control files of package libtpms0
Control files of package libtpms0-dbgsym: lines which differ (wdiff format)
Build-Ids: a41f770c1bbdfc0795a5671e2b33f987246110db 0c62e5320c029a9af9700c938854a2afbfdf2a84