Commit Graph

1070 Commits

Author SHA1 Message Date
Stefan Berger
73364ecb0f debian/rpm: Adjust changelog for 0.5.5 release
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2022-12-08 20:27:58 -05:00
Stefan Berger
a07ea647ba CHANGES: Add documentation for changes in 0.5.5
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2022-12-08 20:27:58 -05:00
Stefan Berger
20141486d4 swtpm: Use uint64_t in tlv_data_append() to avoid integer overflows
Instead of uint32_t use uint64_t's for accumulating needed buffer sizes
that are calculated by adding uint32_t length indicators. Use the uint64_t
to check for excessively large buffer sizes that could cause an integer
overflow if uint32_t was used.

This patch addresses the case where a user passes an old version of TPM
state file to swtpm for reading and the file is 4GB in size and thus can
cause an integer overflow in this particular function.

Otherwise, the previous fix to tlv_data_find_tag() protects swtpm from
integer overflows and later out-of-bound accesses when the TPM state is
initially read from a file (assuming the state file has a header, which
is the case since swtpm 0.1). If an excessively large buffer was passed
to libtpms, it would reject it since it would never be able to take in
that much data.

Data written to the file are coming from libtpms that we can trust in
terms of length indicators.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2022-03-30 15:51:30 -04:00
Stefan Berger
d60f63093e swtpm: Use uint64_t to avoid integer wrap-around when adding a uint32_t
To avoid an integer wrap-around use uint64_t for 'offset' so that adding
an untrusted 32-bit number will allow for comparison against the trusted
'buffer_len' 32-bit number:

        if (offset + td->tlv.length > buffer_len)
            return NULL;

This avoids possible out-of-bound accesses and crashes when reading
specially crafted TPM state input data that have a tlv.length that is so
large that is causes an integer overflow.

Resolves: https://github.com/stefanberger/swtpm/issues/678
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2022-03-30 15:51:30 -04:00
Stefan Berger
140cb42552 build-sys: build swtpm-0.5.5
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2022-03-30 15:51:30 -04:00
Stefan Berger
202b39a09e debian/rpm: Adjust changelog for 0.5.4 release
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2022-03-09 20:43:22 -05:00
Stefan Berger
6dec7525c8 CHANGES: Add documentation for changes in 0.5.4
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2022-03-09 20:39:57 -05:00
Stefan Berger
5243d3c125 swtpm: Do not chdir(/) when using --daemon
With relative paths being used the chdir("/") in daemon() will
cause file access errors.

Resolves: https://github.com/stefanberger/swtpm/issues/671
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2022-03-05 19:43:40 -05:00
Stefan Berger
52d05869a9 build-sys: build swtpm-0.5.4
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2022-03-05 19:43:40 -05:00
Stefan Berger
47795e7da5 debian/rpm: Adjust changelog for 0.5.3 release
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2022-02-18 12:52:49 -05:00
Stefan Berger
aecc510a50 CHANGES: Add documentation for changes in 0.5.3
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2022-02-18 12:52:49 -05:00
Stefan Berger
27d4c5d83f swtpm_localca: Test for available issuercert before creating CA
Avoid trying to create TPM certificates while the issuer certificate has
not been created, yet (in a 2nd step).

To resolve this do not just test for availability of the signing key, which
is created first, but also test for the issuer certifcate, which is created
in a 2nd step when the local CA is created. If either one is missing,
attempt to create the CA.

Resolves: #644
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2022-02-17 20:29:17 -05:00
Stefan Berger
9f683e4986 swtpm: Check header size indicator against expected size (CID 375869)
This fix addresses Coverity issue CID 375869.

Check the header size indicated in the header of the state against the
expected size and return an error code in case the header size indicator
is different. There was only one header size so far since blobheader was
introduced, so we don't need to deal with different sizes.

Without this fix a specially crafted header could cause out-of-bounds
accesses on the byte array containing the swtpm's state.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2022-02-17 17:44:38 -05:00
Stefan Berger
5fded3f3fe Travis: Stop using ASAN for swtpm since one test case fails
It's not possible to recreate the issue with the failing test case
locally on Xenial, so just disable the ASAN usage on swtpm by disabling
the CFLAGS variable.

The one failing test case show this. All other ones work.

FAIL: test_parameters

=====================

Test 0: SUCCESS with parameters ''.
Test 1: SUCCESS with parameters '--createek'.
Test 2: ==27310==ASan runtime does not come first in initial library list; you should either link runtime to your application or manually preload it with LD_PRELOAD.
ERROR: Test with parameters '--take-ownership' failed.
FAIL test_parameters (exit status: 1)

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2022-02-17 15:05:02 -05:00
Stefan Berger
f66a6e5f14 build-sys: Use -DOPENSSL_SUPPRESS_DEPRECATED (OSSL 3)
Use the (undocumented) OPENSSL_SUPPRESS_DEPRECATED to suppress the
deprecated API warnings when compiling swtpm and swtpm_setup with
OpenSSL 3.0.0 replacing the global -Wno-deprecated-declarations.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-09-19 17:40:16 -04:00
Stefan Berger
f343943828 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 19:30:00 -04:00
Tomasz Kłoczko
08816ab3af build-sys: Call autoupdate and fix some resulting issues
autoreconf from autoconf 2.71 emmits a lot of warnings:

+ autoreconf -fiv
autoreconf: export WARNINGS=
autoreconf: Entering directory '.'
autoreconf: configure.ac: not using Gettext
autoreconf: running: aclocal --force -I m4
autoreconf: configure.ac: tracing
autoreconf: running: libtoolize --copy --force
libtoolize: putting auxiliary files in '.'.
libtoolize: copying file './ltmain.sh'
libtoolize: putting macros in AC_CONFIG_MACRO_DIRS, 'm4'.
libtoolize: copying file 'm4/libtool.m4'
libtoolize: copying file 'm4/ltoptions.m4'
libtoolize: copying file 'm4/ltsugar.m4'
libtoolize: copying file 'm4/ltversion.m4'
libtoolize: copying file 'm4/lt~obsolete.m4'
autoreconf: configure.ac: not using Intltool
autoreconf: configure.ac: not using Gtkdoc
autoreconf: running: aclocal --force -I m4
autoreconf: running: /usr/bin/autoconf --force
configure.ac:29: warning: The macro `AC_CONFIG_HEADER' is obsolete.
configure.ac:29: You should run autoupdate.
./lib/autoconf/status.m4:719: AC_CONFIG_HEADER is expanded from...
configure.ac:29: the top level
configure.ac:53: warning: The macro `AC_HELP_STRING' is obsolete.
configure.ac:53: You should run autoupdate.
./lib/autoconf/general.m4:204: AC_HELP_STRING is expanded from...
configure.ac:53: the top level
configure.ac:76: warning: The macro `AC_HEADER_STDC' is obsolete.
configure.ac:76: You should run autoupdate.
./lib/autoconf/headers.m4:704: AC_HEADER_STDC is expanded from...
configure.ac:76: the top level
configure.ac:81: warning: The macro `AC_TYPE_SIGNAL' is obsolete.
configure.ac:81: You should run autoupdate.
./lib/autoconf/types.m4:776: AC_TYPE_SIGNAL is expanded from...
configure.ac:81: the top level
configure.ac:202: warning: The macro `AC_HELP_STRING' is obsolete.
configure.ac:202: You should run autoupdate.
./lib/autoconf/general.m4:204: AC_HELP_STRING is expanded from...
configure.ac:202: the top level
configure.ac:267: warning: The macro `AC_HELP_STRING' is obsolete.
configure.ac:267: You should run autoupdate.
./lib/autoconf/general.m4:204: AC_HELP_STRING is expanded from...
configure.ac:267: the top level
configure.ac:430: warning: The macro `AC_HELP_STRING' is obsolete.
configure.ac:430: You should run autoupdate.
./lib/autoconf/general.m4:204: AC_HELP_STRING is expanded from...
configure.ac:430: the top level
configure.ac:437: warning: The macro `AC_HELP_STRING' is obsolete.
configure.ac:437: You should run autoupdate.
./lib/autoconf/general.m4:204: AC_HELP_STRING is expanded from...
configure.ac:437: the top level
configure.ac:517: warning: The macro `AC_HELP_STRING' is obsolete.
configure.ac:517: You should run autoupdate.
./lib/autoconf/general.m4:204: AC_HELP_STRING is expanded from...
configure.ac:517: the top level
autoreconf: running: /usr/bin/autoheader --force
autoreconf: running: automake --add-missing --copy --force-missing
configure.ac:40: installing './compile'
configure.ac:48: installing './missing'
Makefile.am:34: warning: .PHONY was already defined in condition WITH_SELINUX, which is included in condition TRUE ...
Makefile.am:28: ... '.PHONY' previously defined here
src/swtpm/Makefile.am: installing './depcomp'
autoreconf: './config.sub' is updated
autoreconf: './config.guess' is updated
autoreconf: Leaving directory '.'

Execute autoupdate to apply all those changes.

Signed-off-by: Tomasz Kłoczko <kloczek@github.com>
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-06-23 22:45:35 -04:00
Stefan Berger
883561d343 build-sys: Fix Makefile issue with multiple .PHONY
Recent make's complain about this here:

Makefile.am:34: warning: .PHONY was already defined in condition WITH_SELINUX, which is included in condition TRUE ...
Makefile.am:28: ... '.PHONY' previously defined here

This patch fixes this issue.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-06-23 22:45:35 -04:00
Jonas Witschel
23bc1e7770 swtpm_cert: rename deprecated libtasn1 types
These types have been renamed in libtasn1 version 3.0 (released 2012-10-28).
The most recent libtasn1 version 4.17.0 (released 2021-05-13) now prints
deprecation warnings that are made fatal by -Werror:

ek-cert.c:76:13: error: 'ASN1_ARRAY_TYPE' macro is deprecated, use 'asn1_static_node' instead. [-Werror]
   76 | extern const ASN1_ARRAY_TYPE tpm_asn1_tab[];
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[...]

The new types were introduced almost ten years ago, so they should be pretty
universally available by now.

Signed-off-by: Jonas Witschel <diabonas@archlinux.org>
2021-06-14 15:15:34 -04:00
Stefan Berger
735ab5afee build-sys: build swtpm-0.5.3
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-06-14 15:15:34 -04:00
Stefan Berger
71c4cc1843 tests: Allow volatile state file >= 9000 bytes in test_tpm2_migration_key
Changes to libtpms will require that the volatile state files
during this test may be larger than 9000 bytes.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-05-12 17:01:23 -04:00
Stefan Berger
623b118f4d Travis: Upgrade pip to v20.3.3
Pip 21.0.0 seems to be broken when upgraded to on Xenial. So
let's just only upgrade to 20.3.3.

$ sudo pip3 install --upgrade cryptography
Traceback (most recent call last):
  File "/usr/local/bin/pip3", line 7, in <module>
    from pip._internal.cli.main import main
  File "/usr/local/lib/python3.5/dist-packages/pip/_internal/cli/main.py", line 60
    sys.stderr.write(f"ERROR: {exc}")

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-01-29 15:20:24 -05:00
Stefan Berger
e9acf65456 swtpm: Fix --print-capabilities for 'swtpm chardev'
This patch fixes the following issue:

$ ./src/swtpm/swtpm chardev --print-capabilities --tpm2
swtpm: Error: Missing character device or file descriptor

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-01-13 10:26:18 -05:00
Lili Zhu
6ff31653f6 Update the doc of the flag to connect to TPM via UnixIO socket
Modify the flag from "--unixio" to "--unix"

Signed-off-by: Lili Zhu <lizhu@redhat.com>
2021-01-13 10:26:18 -05:00
Stefan Berger
e59c0c1a7b debian/rpm: Adjust changelog for 0.5.2 release
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-12-26 13:33:15 -05:00
Stefan Berger
8a89afbc70 CHANGES: Add documentation for changes in 0.5.2
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-12-26 13:33:15 -05:00
Stefan Berger
4d9078878d build-sys: buid swtpm-0.5.2
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-12-26 13:33:15 -05:00
Stefan Berger
1dbde0a148 swtpm: Unconditionally close fd if writing of pidfile fails (coverity)
Do not bother trying to keep pidfilefd open in case fd = pidfilefd,
but close it unconditionally. If writing the pidfile fails, the process
terminates anyway, besides that we only ever need to write to the
pidfile once, which is happening in this function.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-12-26 13:33:15 -05:00
Stefan Berger
2cb9f95680 swtpm: Adjust size of message buffer to be of size ptm_hdata
This patch fixes the following compilation issue/bug:

ctrlchannel.c: In function ‘ctrlchannel_process_fd’:
ctrlchannel.c:694:13: error: array subscript ‘ptm_hdata[0]’ is partly outside array bounds of ‘struct output[1]’ [-Werror=array-bounds]
  694 |         data->u.resp.tpm_result = htobe32(res);
      |             ^~
ctrlchannel.c:486:7: note: while referencing ‘output’
  486 |     } output;
      |       ^~~~~~

Sending hashes to the TPM is not currently used in any major
application, so this bug should not affect much.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-12-21 18:18:11 -05:00
Stefan Berger
42b38cb7c8 swtpm_setup: Increase timeout from 10s to 30s for slower machines
Older ARM processors need more time to create the initial CA keys
and then the key for the TPM. So we increase the timeout to 30s.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-12-09 10:49:21 -05:00
Stefan Berger
e3c0a21b46 Travis: Remove OSX CI/CD due to costs
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-12-09 10:49:21 -05:00
Stefan Berger
96f5a04c3d CHANGES: Adjust v0.5.1 release entry
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-11-17 15:47:43 -05:00
Stefan Berger
e621b21d4c samples: Do not follow symlink on logfile (CVE-2020-28407)
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-11-17 15:47:43 -05:00
Stefan Berger
526300236d swtpm_setup: Do not follow symlink on logfile (CVE-2020-28407)
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-11-17 15:47:43 -05:00
Stefan Berger
390f5bd489 debian/rpm: Adjust changelog for 0.5.1 release
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-11-13 20:07:00 -05:00
Stefan Berger
d2543a4306 CHANGES: Add documentation for changes in 0.5.1
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-11-13 20:07:00 -05:00
Stefan Berger
a03cbadd08 swtpm: Use open() (not fopen()) when accessing statefile (CVE-2020-28407)
This patch addresses CVE-2020-28407.

Use the open() call rather than the fopen() call when accessing
the statefile and make sure we do not follow symlinks using O_NOFOLLOW.

The modification does not allow an attacker to create a symbolic link
with the name of the temporary file (TMP2-00.permall for TPM 2) and
have this point to a valueable file and swtpm ends up overwriting the
file. The success of the attack depends on the attacker having access
to the TPM's state directory (--tpmstate dir=...).

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-11-13 20:07:00 -05:00
Stefan Berger
634b629400 swtpm: Switch to open() from fopen() for the pidfile (CVE-2020-28407)
This patch addresses CVE-2020-28407.

Use the open() call rather than the fopen() call when creating a pidfile.
Also prevent us from following symbolic links when opening the pidfile for
writing.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-11-13 20:07:00 -05:00
Stefan Berger
4cc42c0ba3 swtpm: Do not follow symlinks when opening lockfile (CVE-2020-28407)
This patch addresses CVE-2020-28407.

Prevent us from following symliks when we open the lockfile
for writing.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-11-13 20:07:00 -05:00
Stefan Berger
e9c9778d5c swtpm_cert: Switch to open() from fopen() for writing certificate
Switch to open from fopen() and make sure we do not follow symlinks.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-11-13 20:07:00 -05:00
Eiichi Tsukata
62c03e02e5 build-sys: fix configure python cryptography error message
Currently it shows "python setuptools is required" if "import
cryptography" failed.

Signed-off-by: Eiichi Tsukata <eiichi.tsukata@nutanix.com>
2020-11-13 20:07:00 -05:00
Stefan Berger
8ff6418949 tests: Try with tcsd.conf ownership of root:tss if tss:tss did not work
Due to recent changes in tcsd, it doesn't accept 'tss:tss 0600' anymore
for the tcsd config file but we need to use 'root:tss 0640' for it.
So far only Fedora seems to be affected. It now depends on whether tcsd
has been patched what ownership is required. So we try first the old
configuration and then the new one.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-11-09 17:06:09 -05:00
Stefan Berger
20ed6f9804 build-sys: build swtpm-0.5.1
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-11-09 17:06:09 -05:00
наб
f8034dd8e4 debian: drop revision from version, illegal for native-format packages
$ dpkg-buildpackage -us -uc
dpkg-buildpackage: info: source package swtpm
dpkg-buildpackage: info: source version 0.5.0-1
dpkg-buildpackage: info: source distribution RELEASED
dpkg-buildpackage: info: source changed by Stefan Berger <stefanb@linux.ibm.com>
dpkg-source: error: can't build with source format '3.0 (native)':
native package version may not have a revision

Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
2020-10-08 12:34:13 -04:00
Stefan Berger
b931e10985 debian/rpm: Adjust changelog for 0.5.0 release
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-10-07 14:24:43 -04:00
Stefan Berger
611c589691 CHANGES: Add documentation for changes in 0.5.0
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-10-07 14:24:43 -04:00
Stefan Berger
5af35971b8 samples: Do not truncate logfile when testing write-access
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-10-06 15:05:08 -04:00
Stefan Berger
2ba2248351 swtpm_setup: Do not truncate logfile when testing write-access
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-10-06 15:05:08 -04:00
Stefan Berger
1d6a1554a6 swtpm_setup: Remove TPM state file in case error occurred
Remove the TPM state file in case an error occurred.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-10-06 15:05:08 -04:00
Stefan Berger
07ea18bc38 build-sys: Add python-install and python-uninstall targets
To force the installation of the python programs add a python-install
target. This solves an installation issue with non-standard prefix,
like not using /usr or /usr/local, as may be the case on OS X (Apple)
when using homebrew. It leaves the 'make distcheck' working, which also
uses a non-standard prefix and where we don't want to install the tools
due to issues with removing them afterwards where pip3 cannot be used.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-10-05 12:06:05 -04:00