Commit Graph

900 Commits

Author SHA1 Message Date
Thomas Lamprecht
8d2f9bdc35 bump version to 0.9.6+pve1
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-05-25 16:28:00 +02:00
Thomas Lamprecht
52b75137d5 d/control: Proxmox maintains this package for Proxmox projects
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-05-25 16:28:00 +02:00
Thomas Lamprecht
ce9871c173 fixup packaging make file 2023-05-25 16:28:00 +02:00
Thomas Lamprecht
35ccea709e v0.9.6
-----BEGIN PGP SIGNATURE-----
 
 iQEzBAABCAAdFiEEuBi5yt+QicLVzsZrda1lgCoLQhEFAmP+gNkACgkQda1lgCoL
 QhH2DAf9H4kVXq//Pmy10w1hPu2SPw5jz8orJGGNuI7zL0ASuYhoHi3pNr7n/tMJ
 NZnr2YkFYf+xp8pUdtzdcqGqcHpvJV1xTScFAAfnqC1YiDu6lxxo/BTUyKGH3GBD
 YBz3/6iXqcu5oM2dzTObfHlkQ2/q8H5Q2Xzw3xQwG8FpmTLCS+8bzy++69OnUQpo
 Vl0McfcbEFCo5QqQR3NB39gDf0DfefpIxWbHq5nE7lFWyKpzB/OQJZYBiK33k3lz
 4FC1voJvZByADzlPns5UEFL6ovM3y7TrxuICFjmEOeHx7fa5KQt45fPky32+rqLe
 yfg9+ihMk2P13zs2En9zc+hjE+/Xtg==
 =SBU6
 -----END PGP SIGNATURE-----

Merge tag 'v0.9.6' into proxmox/stable-0.9

v0.9.6
2023-05-25 16:16:10 +02:00
Thomas Lamprecht
5621dbe48e add packaging make file
(mis)using the fact that GNU make uses the following Makefile order
GNUmakefile, makefile and Makefile.
https://www.gnu.org/software/make/manual/make.html#Makefile-Names
2023-05-25 16:15:06 +02:00
Stefan Berger
f8c2dc7e12 rpm/debian: Add 0.9.6 entry in changelog
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2023-02-28 15:57:55 -05:00
Stefan Berger
c4d875e74d CHANGES: Updated CHANGES document for 0.9.6
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2023-02-28 15:57:55 -05:00
Stefan Berger
6a6d40d8e2 tpm2: Check size of buffer before accessing it (CVE-2023-1017 & -1018)
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>
2023-02-28 15:57:55 -05:00
Stefan Berger
45134aef3e build-sys: Build libtpms v0.9.6
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2023-02-28 15:57:55 -05:00
Thomas Lamprecht
9b99288356 bump version to 0.9.5~bpo11+1
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-11-11 12:39:45 +01:00
Thomas Lamprecht
08bb4a6f66 v0.9.5
-----BEGIN PGP SIGNATURE-----
 
 iQEzBAABCAAdFiEEuBi5yt+QicLVzsZrda1lgCoLQhEFAmK/FlYACgkQda1lgCoL
 QhFe5AgA5oGyzjYE0UXI9yOAl8Or/zMS68vegakWvCBuwTz+zRlI7UvhpXSN9r9L
 wdmY28ozwfONqxhuf4UJvHhrX6VpTjhf2HWqziKItsscIFVAryqQZyqu0egqfeVW
 XFjwRutfnPug0GU04r7gYEPvRCjRf2boxyWP1rORyjR4NZnlwNfqZRNBhyEy5mNG
 7Gj0WB59bJqy2AxL8hsR1XP7SjRuk8NdfYnFLv23oSjaQkN2tV4TAnRGD8VVrxKV
 31L/DMI8P2MCxWkseWvIE1dwXaO22n8MnXV7ZIG6g+GiwuGa3xM1I0qXhHlAKsQT
 oisFRyXDp9befPkgukKMQEFYkcQyeQ==
 =KRu5
 -----END PGP SIGNATURE-----

Merge tag 'v0.9.5' into proxmox/stable-0.9

v0.9.5
2022-11-11 12:39:17 +01:00
Stefan Berger
df1c3e98d6 rpm/debian: Add 0.9.5 entry in changelog
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2022-07-01 11:36:16 -04:00
Stefan Berger
e93c0082be CHANGES: Updated CHANGES document for 0.9.5
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2022-07-01 11:36:16 -04:00
Stefan Berger
a4b8797259 tpm2: Do not set RSA_FLAG_NO_BLINDING on RSA keys anymore
Do not set the RSA_FLAG_NO_BLINDING on RSA keys anymore. The BoringSSL
documentation states the following:

"RSA_FLAG_NO_BLINDING disables blinding of private operations, which is
a dangerous thing to do. It is deprecated and should not be used. It will
be ignored whenever possible."

So, follow this documentation. OpenSSL does not seem to say much about it.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2022-06-06 08:47:05 -04:00
Stefan Berger
b1b2cf5e15 tpm2: Fix a potential overflow expression (coverity)
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2022-05-29 13:23:21 -04:00
Ross Lagerwall
78a27cf0c3 tpm2: Fix size check in CryptSecretDecrypt
Check the secret size against the size of the buffer, not the size
member that has not been set yet.

Reported by Coverity.

Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
2022-05-24 23:40:22 -04:00
Stefan Berger
6728aada47 build-sys: Build libtpms v0.9.4
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2022-05-24 23:40:22 -04:00
Stefan Berger
e4d68670e1 rpm/debian: Add 0.9.4 entry in changelog
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2022-04-25 14:17:25 -04:00
Stefan Berger
b6dc4fa924 CHANGES: Updated CHANGES document for 0.9.4
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2022-04-25 14:17:25 -04:00
Stefan Berger
64887bc651 tpm: #undef printf in case it is #define'd (OSS-Fuzz)
The build environment used by OSS-Fuzz reports this error.

 In file included from /src/libtpms/src/tpm_debug.c:42:
 /src/libtpms/src/tpm_debug.h:69:9: error: 'printf' macro redefined [-Werror,-Wmacro-redefined]
 #define printf(...) TPMLIB_LogPrintf(__VA_ARGS__);
 :         ^
 /usr/include/x86_64-linux-gnu/bits/stdio2.h:110:11: note: previous definition is here
 # define printf(...) \
           ^
 1 error generated.

The simple fix is to #undef printf in case it is #define'd.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2022-04-21 09:50:50 -04:00
Steve Langasek
26e65226c5 tpm2: Initialize variables due to gcc complaint (s390x, false positive)
Detected by gcc on Ubuntu/s390x

Origin: https://git.launchpad.net/ubuntu/+source/libtpms/tree/debian/patches/uninitialized-variable.patch

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
2022-04-04 16:49:38 -04:00
Steve Langasek
e856a73933 tpm12: Initialize variables due to gcc complaint (s390x, false positive)
Detected by gcc on Ubuntu/s390x

Origin: https://git.launchpad.net/ubuntu/+source/libtpms/tree/debian/patches/uninitialized-variable.patch

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
2022-04-04 16:49:38 -04:00
Stefan Berger
f0fda0646a Fix configure script to support _FORTIFY_SOURCE=3
gcc 12.1 supports _FORTIFY_SOURCE=3. Modify the existing check for whether
_FORTIFY_SOURCE=2 can be used to test compile with the user provided
CFLAGS and only add _D_FORTIFY_SOURCE=2 to the HARDENING_CFLAGS if the
user doesn't provide anything that's not compatible.

Following an online article _FORTIFY_SOURCE=3 may add more overhead, so
we only go up to level 2 for now and let build servers or user provide
the higher level via the CFLAGS.

https://developers.redhat.com/blog/2021/04/16/broadening-compiler-checks-for-buffer-overflows-in-_fortify_source#what_s_next_for__fortify_source

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2022-04-04 16:08:49 -04:00
Stefan Berger
897c8f8697 tpm2: Check return code of BN_div()
Check the return code of BN_div() when calculating Q and Qr of
a private key.

Resolves: https://github.com/stefanberger/libtpms/issues/304
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2022-03-30 13:34:48 -04:00
Stefan Berger
c2e840b88b build-sys: Build libtpms v0.9.4
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2022-03-30 13:34:48 -04:00
Stefan Berger
a63c51805e rpm/debian: Add 0.9.3 entry in changelog
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2022-03-07 12:07:25 -05:00
Stefan Berger
472bc355ef CHANGES: Updated CHANGES document for 0.9.3
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2022-03-07 12:07:25 -05:00
Stefan Berger
3f8fbc831b build-sys: Add probing for -fstack-protector
Add probing for -fstack-protector to the existing
-fstack-protector-strong since not all platforms support either one
of them.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2022-03-02 15:03:08 -05:00
Juergen Repp
1de757972e tpm2: Do not call EVP_PKEY_CTX_set0_rsa_oaep_label() for label of size 0 (OSSL 3)
Openssl 3.0 did return an error if EVP_PKEY_CTX_set0_rsa_oaep_label was called
with label size 0. The function should only be called if the size of the label
is greater 0.
With this fix TPM2_RSA_Encrypt/Decrypt did work with OpenSSL 1.1 and 3.0
for encryption without label.

Signed-off-by: Juergen Repp <juergen.repp@sit.fraunhofer.de>
2022-03-02 09:15:37 -05:00
Stefan Berger
0a11a6726d build-sys: Build libtpms v0.9.3
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2022-03-02 09:15:37 -05:00
Thomas Lamprecht
1e189c19d8 bump version to 0.9.2~bpo11+1
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-02-22 08:12:44 +01:00
Thomas Lamprecht
5332f4c9cb v0.9.2
-----BEGIN PGP SIGNATURE-----
 
 iQEzBAABCAAdFiEEuBi5yt+QicLVzsZrda1lgCoLQhEFAmHXsJcACgkQda1lgCoL
 QhFf5ggAuHBjE5PY096Y4XCo7SPH7+6hxwBo4+Zz/castS7IdHBI7n7TV3PSHywd
 4f9JCw/NzUc10Zp2Q+ab1lvxfhDogKvsoWlliy0geIsiyCiIxE3zwW+n0R/LskFz
 EiaGYhh17cuJpgB+t7MThdLWF8pLeJYw6qpRvyg9szj68Lg6qRe8CzGnLRvDf6pg
 sfKJOrYlxqxrsCLX0rRW70eGskTy+fy57oY2sWtKe+0gSNB9fbL72wC6DxZvcElu
 OEFKA+U6DOsIXG0XXo5CuC/wPJwXQvW+jHNzjvZXsC8uj1j0morU7eBjxQmJWW5n
 1pSkl9g78zeXgWNuXwIjw+3iDcXrDw==
 =zSNi
 -----END PGP SIGNATURE-----

Merge tag 'v0.9.2' into proxmox/0.9.2-1

v0.9.2
2022-02-22 08:11:18 +01:00
Stefan Berger
e81d634c27 rpm/debian: Add 0.9.2 entry in changelog
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2022-01-05 15:59:06 -05:00
Stefan Berger
259c1310ff CHANGES: Updated CHANGES document for 0.9.1
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2022-01-05 08:07:18 -05:00
Stefan Berger
b662e6fd71 tpm2: When writing state initialize s_ContextSlotMask if not set
If s_ContextSlotMask was not set since the TPM 2 was not initialized
by a call to TPM_Manufacture() or the state was not resumed, then
initialize the s_ContextSlotMask to 0xffff.

This situation can occur if a VM with an attached swtpm was started
and the VM's firmware either doesn't support TPM or didn't get to
initialize the vTPM.

The following commands recreated the issue with a SeaBIOS-only VM that
had no attached hard disk but an attached TPM 2:

virsh start BIOS-only-VM ; virsh save BIOS-only-VM save.bin ; \
 virsh restore save.bin

Error: Failed to restore domain from save.bin
error: internal error: qemu unexpectedly closed the monitor: \
2022-01-04T19:26:18.835851Z qemu-system-x86_64: tpm-emulator: Setting the stateblob (type 2) failed with a TPM error 0x3 a parameter is bad
2022-01-04T19:26:18.835899Z qemu-system-x86_64: error while loading state for instance 0x0 of device 'tpm-emulator'
2022-01-04T19:26:18.835929Z qemu-system-x86_64: load of migration failed: Input/output error

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2035731
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2022-01-05 08:07:18 -05:00
Stefan Berger
52cd3bcdfd build-sys: Build libtpms v0.9.2
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2022-01-05 08:07:18 -05:00
Stefan Berger
1ff6fe1f43 CHANGES: Updated CHANGES document for 0.9.1
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-11-24 09:54:47 -05:00
Stefan Berger
826754c525 rpm/debian: Add 0.9.1 entry in changelog
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-11-24 09:54:47 -05:00
kpcyrd
d39256e2e8 Fix "maybe-uninitialized" warning
exp_array_size is always initialized if `rc == TPM_RC_SUCCESS` and never used
if `rc != TPM_RC_SUCCESS` but some compilers have trouble noticing this.

Signed-off-by: kpcyrd <git@rxv.cc>
2021-10-29 10:19:42 -04:00
Stefan Berger
bf1f9c8d4e tpm2: Do not write permanent state if only clock changed
To avoid timeouts on short-running commands, such as TPM2_PCR_Extend,
avoid triggering the writing of the permanent state of the TPM 2
if only the clock was updated. So the clock by itself will not cause
the permanent state to be written out anymore but there have to be
other reasons as well.

The state will still be written out upon a TPM2_Shutdown, which is
supposed to be the last command to be sent to the TPM when shutting
down the VM/vTPM. Also, the permanent state will still carry the
latest clock value if it is retrieved via control channel for
VM/VTPM suspend.

The case that may be affected, but is of lesser importance, is the one
where swtpm's volatile state is written to storage using 'swtpm_ioctl -v'
and then swtpm is terminated and restarted (similar to suspend/resume)
and the permanent state file is read from storage but does not contain
the latest clock value. In this case the go.clock will be updated when
the first command after resume is executed.

This fixes the swtpm issue https://github.com/stefanberger/swtpm/issues/597.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-10-15 17:10:21 -04:00
Stefan Berger
dbfc15279a build-sys: Build libtpms v0.9.1
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-10-15 17:10:21 -04:00
Thomas Lamprecht
e4f8f2f0e9 bump version to 0.9.0+1
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-10-05 06:41:30 +02:00
Stefan Berger
dc4e3f6313 rpm/debian: Add 0.9.0 entry in changelog
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-09-28 16:55:28 -04:00
Stefan Berger
ab25f924d1 CHANGES: Updated CHANGES document for 0.9.0
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-09-28 16:55:28 -04:00
Stefan Berger
4bc846f869 build-sys: Use -DOPENSSL_SUPPRESS_DEPRECATED to suppress warning (OSSL 3)
Instead of using -Wno-deprecated-declarations use
-DOPENSSL_SUPPRESS_DEPRECATED to only suppress OpenSSL deprecated
declarations warnings.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-09-21 16:52:22 -04:00
Stefan Berger
f45bafa9bd build-sys: Add -Wno-deprecated-declarations to default CFLAGS (OSSL 3)
To be able to build with OpenSSL 3.0 we need to added
-Wno-deprecated-declarations to the default CFLAGS.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-09-15 13:28:08 -04:00
Stefan Berger
3091ef1184 build-sys: Test for functions if #defines are not found (OSSL 3)
OpenSSL 3.0 has converted several RSA-related #defines to functions, so
that AX_CHECK_DEFINE only works for OpenSSL 1.1.0 but for OpenSSL 3.0.0
we have to also use AC_CHECK_LIB to determine whether the function is
available.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-09-15 13:28:08 -04:00
Stefan Berger
ed94c7fd14 tpm2: Only call EVP_PKEY_CTX_set0_rsa_oaep_label when label != NULL (OSSL 3)
EVP_PKEY_CTX_set0_rsa_oaep_label must only be called with label != NULL.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-09-15 13:28:08 -04:00
Stefan Berger
c8a7074bb6 tpm2: Use EVP_PKEY_get1_RSA() rather than EVP_PKEY_get0_RSA (OSSL 3)
OpenSSL 3.0 has changed the signature of EVP_PKEY_get0_RSA() from

struct rsa_st *EVP_PKEY_get0_RSA(EVP_PKEY *pkey);

to

const struct rsa_st *EVP_PKEY_get0_RSA(const EVP_PKEY *pkey);

We now have to use EVP_PKEY_get1_RSA with this signature so that we can
access the RSA key. The signature of that function hasn't changed between
OpenSSL 1.1.0 and 3.0.0.

struct rsa_st *EVP_PKEY_get1_RSA(EVP_PKEY *pkey);

Free the additional reference held on the RSA key.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-09-15 13:28:08 -04:00
Stefan Berger
9eb9677795 tpm2: Marshal event sequence objects' hash state
Event sequence objects were never properly marshalled and when their state
was saved and later restored their state may have been corrupted. Fix this
now by also marshalling the state of event sequence objects.

Bump up the version of the HASH_OBJECT's header to '3' so that previously
written state can be resumed if an event sequence object is encountered
and we only unmarshal an event sequence object when the version is at least
'3'.

Fixes issue #259.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-09-09 12:28:17 -04:00