Commit Graph

745 Commits

Author SHA1 Message Date
Stefan Berger
7129aea83a rpm/debian: Add 0.1.1-1 entry to changelog
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-07-09 16:47:54 -04:00
Stefan Berger
1e855c9551 CHANGES: Updated CHANGES document for 0.1.1
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-07-09 16:47:54 -04:00
Stefan Berger
8259972812 Travis: Work around failing OsX builds due to brew error
The Travis build on OSX was failing due to the following error:

/usr/local/Homebrew/Library/Homebrew/brew.rb:23:in `require_relative': \
   /usr/local/Homebrew/Library/Homebrew/global.rb:110: \
   syntax error, unexpected keyword_rescue, expecting keyword_end (SyntaxError)

	from /usr/local/Homebrew/Library/Homebrew/brew.rb:23:in `<main>'

The command "brew tap discoteq/discoteq" failed and exited with 1 during .

This patch resolves the issue.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-06-29 10:17:57 -04:00
Stefan Berger
81cf6774a7 tests: Adapt test cases' expected PCR result due to libtpms TPM 2 fix
libtpms version 0.6.3, 0.7.3, and master have a change to the TPM 2 code
that affects the pcrUpdateCounter, which now returns a smaller value than
before.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-06-29 10:17:57 -04:00
Stefan Berger
1e194c34f8 build-sys: build swtpm-0.1.1
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-06-29 10:17:57 -04:00
Stefan Berger
4398444d8b swtpm_cert: Use gnutls_x509_crt_get_subject_key_id API call for subj keyId
Use the gnutls_x509_crt_get_subject_key_id() API call to get the subject
key ID of the signer's certificate rather than gnutls_x509_crt_get_key_id().
The latter returns the same result most of the time but there are instances
when this is not the case and the returned result is wrong.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-10-22 12:39:17 -04:00
Stefan Berger
63e0dc808f swtpm_cert: Fix OIDs for TPM 2 platforms data
The OIDs for the TPM 1.2 and TPM 2 platform data
are different (though have the same name in the spec).
Adapt them for the TPM 2 case.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-10-17 13:00:01 -04:00
Stefan Berger
ca85606210 swtpm: Fix illegal heap access while parsing options
Fix an illegal heap access while parsing the options by making
sure that we do not access the tok variable beyond its size
when comparing a character to '=' and later on when accessing
the value after the '='.

This bug was discovered by configuring as follows on Fedora 28:
  CFLAGS="-fsanitize=address -g -ggdb" LIBS="-lasan" \
    ./configure --prefix=/usr

and running tests like this:

  sudo bash -c "SWTPM_TEST_EXPENSIVE=1 make -j32 check"

The test case test_tpm2_ctrlchannel2 indicated the error.

It looks like gcc on Ubuntu Xenial on Travis did not detect this
error.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-04-18 08:27:26 -04:00
Stefan Berger
04e7be8901 tests: Use file descriptor 100 rather than 200 (fix OpenBSD)
Use file descriptor 100 rather than 200 to pass on OpenBSD

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-04-03 06:58:22 -04:00
Stefan Berger
3fa0ddc388 swtpm: Fix return code of change_process_owner
The return code of change_process_owner must be negative.
This patch fixes one occurrence.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-04-03 06:58:22 -04:00
Marc-André Lureau
d803d84575 swtpm-setup: follow XDG spec more closely for default config
According to the XDG spec,
https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html:
"If $XDG_CONFIG_HOME is either not set or empty, a default equal to
$HOME/.config should be used."

This fixes setting up a TPM with libvirt running in a user session.

It works by checking if configuration files are readable in the
directory priority order (XDG_CONFIG_HOME, then HOME, then SYSCONFDIR).

When libvirt is running as a system instance, $HOME isn't set, so it
will fall back on @SYSCONFDIR@ (/etc usually)

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2019-02-26 09:07:20 -05:00
Stefan Berger
1c82dc3b48 rpm: Adjust RPM spec file for 0.1 release
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-02-26 09:07:20 -05:00
Stefan Berger
2c25d137f7 debian: Edit changelog for 0.1.0 release
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-01-28 17:03:26 -05:00
Stefan Berger
0c1ecae282 doc: Create CHANGES file for initial release
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-01-28 17:03:26 -05:00
Stefan Berger
9e8e018145 debian: Fix libtpms0 dependency and force gnutls availability
Libtpms is now libtpms0 as a dependency.
Gnutls is neede for swtpm_cert to create the certs. Force it to
be available.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-01-28 17:03:26 -05:00
Stefan Berger
44b92d43cd debian: Add post install script for swtpm-tools
Add a post install script for swtpm-tools that creates
the /var/lib/swtpm-localca directory and changes ownersip
on it.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-01-28 17:03:26 -05:00
Stefan Berger
b8e9b4aeeb run_test.sh: Replace -j8 with -j$(nproc)
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-01-28 17:03:26 -05:00
Stefan Berger
e60e777c7b tests: Fix error handling if pkcs11 test runs on x86_64 with i386 executable
Softhsm cannot be installed as an i386 executable/library and as
a x86_64 executable/library on a Fedora host. The pkcs11 test then
fails since it cannot pick up the libsofthsm.so needed for an i386
executable (swtpm_cert) on a x86_64 host. This fixes test run errors
for run_test.sh by skipping the test in case swtpm_cert returns
a specific error message related to not being able to import the
pkcs11 URI object.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-01-28 17:03:26 -05:00
Stefan Berger
8c2cb90f11 test: Replace uname -o with uname -s
Replace single occurrence of uname -o with uname -s so it's portable.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-01-23 17:56:31 -05:00
Stefan Berger
bfdad297ed tests: Use wait_process_gone rather than sleep
Use wait_process_gone with 2 seconds timeout to wait for the swtpm to
have terminated after SIGTERM or connection loss. This avoids test
failures on slow Raspberry Pi 2.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-01-23 17:56:31 -05:00
Stefan Berger
02b7d5da10 Make softhsm/pkcs11 test case work on Travis on OS X
We need to run the softhsm/pkcs11 test case as root (sudo) under OS X
so that we can write the file /etc/gnutls/pkcs11.conf. However, once
we run the tests as root we cannot run the 'brew ls' command anymore
since it refuses to run with high privileges. So, if we run as root we
need to use sudo to switch to the nobody user to run the 'brew ls'
command that gives us the name of the softhsm pkcs11 module.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-01-23 15:42:52 -05:00
Stefan Berger
b5e7e2a41f tests: Make the test case work on OS X
On OS X we need to be able to change /etc/gnutls/pkcs11.conf for
p11tool to pick up the softhsm pkcs11 module correctly. We need
(password-less) sudo to be able to do this.

Unforutnately this test case does not run on Travis since Travis
seems to require passwords under some circumstances.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-01-23 12:48:43 -05:00
Stefan Berger
34308cc7d3 tests: Add test case that uses a pkcs11 URI for signing a cert
Use SoftHSM to create a pkcs11 URI and then use the pkcs11 URI
to sign the certificate of a TPM 2.0 with this key using swtpm-localca.

This test case works with softhsm >= 2.3.0 on Fedora and should work
with a recent version of Ubuntu. If an error is encountered setting
up the softhsm2 environment, we just skip the test.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-01-23 12:48:43 -05:00
Stefan Berger
7a3d1cde46 samples: Enable swtpm-localca to sign with a pkcs11 URI
Allow the user to specify a pkcs11 URI in the signingkey field
in swtpm-localca.conf.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-01-23 12:48:43 -05:00
Stefan Berger
2b0f421224 tests: Gate the IBM TSS 2 related test with SWTPM_TEST_IBMTSS2
Older versions of the IBM TSS2, such as in FC26 for example, behave
slightly different than the code in the test case expects (certain
files are not generated or may have a different name). So gate this
test case with SWTPM_TEST_IBMTSS2 environment variable so we don't run
it by default if the TSS tools are found and so we do not run into
possible errors due to an older version of the stack installed on the
system.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-01-17 18:57:53 -05:00
Stefan Berger
a1c9aedd77 tests: Set TPM_INTERFACE_TYPE=socsim
Set the TPM_INTERFACE_TYPE to socsim to override a potential
compile-time default.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-01-17 18:57:53 -05:00
Stefan Berger
6dbab87358 tests: Remove 'less' command from test case
Remove a 'less' command from previous debugging from the test
case.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-01-17 17:08:04 -05:00
Stefan Berger
2bfa8312d9 swtpm_setup.sh: Replace mktemp --tmpdir=<> with TMPDIR=<> mktemp
To avoid failures with mktemp call on BSD type of systems replace
mktemp --tmpdir=<dir> with TMPDIR=<dir> mktemp, which seems more portable.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-01-17 11:28:40 -05:00
Stefan Berger
b61e8c5fb5 swtpm_setup: Use OSX specific function to get path of executable
OS X cannot resolve the path we get from genenv("_") when running a
test script on Travis (reason unknown). So we use _NSGetExecutablePath()
instead and display the path in the error message in case realpath()
fails.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-01-17 11:28:40 -05:00
Stefan Berger
aef6895d2a travis: Run tests on OSX, install, and run quick test
Run the build on OSX as well and run a quick test that exercises
some of the config files installed in --prefix=/usr/local

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-01-17 11:28:40 -05:00
Stefan Berger
d16b86b7b0 build-sys: Adjust localstatedir and files using it
Adjust the localstatedir variable to not have ${prefix} if
prefix is '/usr/', otherwise use ${prefix}.

Also adjust the files that were pointing to directories that
are controlled by $localstatedir.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-01-17 11:28:40 -05:00
Stefan Berger
0432b6535c build-sys: Fix hard coded /etc path and replace with @SYSCONFDIR@
When the project is configured with --prefix=/usr/local several configuration
files are installed to /usr/local/etc but not read by the programs that
need them. This patch fixes this issue by replacing @SYSCONFDIR@ in the source
code of those files with the actual used path.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-01-17 11:28:40 -05:00
Stefan Berger
bc4d1d0341 debian: Add missing build dependencies
3 build dependencies were missing for a clean environment.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-01-16 16:03:49 -05:00
Stefan Berger
a530ec8acc debian: Change architecture for swtpm-dev from all to any
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-01-07 13:16:30 -05:00
Stefan Berger
5311e60e55 man: Fix man pages to include short summary in NAME section
Fix the man pages to include a short summary in the NAME section.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-01-07 13:16:30 -05:00
Stefan Berger
ef606d4a65 build-sys: If TPM 1.2 NVRAM area tools are missing print out a warning
Allow to build without the TPM 1.2 NVRAM area tools but print out a warning
that they are needed for TPM 1.2 certificate injection.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2018-12-15 10:06:03 -05:00
Stefan Berger
eaa658cb70 build-sys: Create m4 directory on older systems
Older systems, such as RHEL 6, need the m4 directory to be created.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2018-12-15 10:06:03 -05:00
Stefan Berger
8b9484a350 man: Extend man pages for swtpm-localca.conf for pkcs11 URIs
The signingkey entry can also be a pkcs11: URI. The semilcolons in the URI
have to be escaped due to the shell reading the entries.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2018-12-11 15:25:00 -05:00
Stefan Berger
655bc4be17 swtpm_cert: Support PKCS11 URIs for a CA using a PKCS11 module for signing
For PKCS11 modules (such as SoftHSM) to sign a TPM EK or platform
certificate we use 'pkcs11:' prefixed URIs like those URIs for
TPM 1.2 starting with tpmkey:.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2018-12-11 13:44:36 -05:00
Stefan Berger
ccb00a55cd samples: Escape the GnuTLS PKCS11 URL before using in command line
GnuTLS PKCS11 URLs have ';' in the string that we need to preserve for
passing to GnuTLS. So we escape the semicolons before using them on the
command line.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2018-12-11 13:44:36 -05:00
Stefan Berger
eaf2a1db22 travis: Use ubsan (undefined behavior sanitizer) in a test run
Add another parallel test run that uses ubsan.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2018-11-23 20:36:25 -05:00
Stefan Berger
b8e0cbd299 swtpm: ubsan: Make 64 bit flags field of ptm_getinfo 8-byte aligned
Make the 64bit flags field of the ptm_getinfo structure 8-byte
aligned.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2018-11-23 20:36:25 -05:00
Stefan Berger
50af85f7fd swtpm_bios: ubsan: Use tpm_resp_header structure to access header fields
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2018-11-23 20:36:25 -05:00
Stefan Berger
41c8da12ce swtpm_setup.sh: First send SIGTERM to processes then (later) SIGKILL
Implement terminate_proc, which first tries to gracefully terminate a
process and then, if synchronization is requested, waits for 1 second
for it to disappear and then kills it with SIGKILL if it didn't go away.

Use this function for stop_tpm and stop_tcsd, which will first try
to send a SIGTERM to a process assuming it will terminate while we
do something else and then, in case the process needs to be restarted,
make sure that it's gone before it is restarted.

This addresses an issue where previously SIGTERM was sent to a process
before it was restarted but the restarting failed due to the previous
process still holding a lock on the file because it wasn't able to react
to the SIGTERM fast enough.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2018-11-23 10:08:26 -05:00
Stefan Berger
bd247379e9 swtpm: Uninstall signal handler before closing notication file descriptor
Uninstall the signal handler before we close the signal handler's
notification file descriptor so that signals received after the file
descriptor is closed do not cause an error.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2018-11-23 10:08:26 -05:00
Stefan Berger
dff1c07dac swtpm_setup: Free memory in case of error
Free the allocated memory in case of an error condition.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2018-11-23 10:08:26 -05:00
Stefan Berger
ae98b04512 swtpm: Coverity: Check msg parameter upon return from recvmsg
Make sure that the msg parameter passed into recvmsg wasn't modified
by the library and verify that the pointers and sizes it contains are
still valid after the call. This addresses an issue raised by Coverity.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2018-11-21 10:45:10 -05:00
Stefan Berger
63f7079fd7 tests: Use bash's built-in echo rather than /bin/echo
The BSD's cannot use /bin/echo -en but we have to use bash's built-in
one.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2018-11-19 18:50:42 -05:00
Stefan Berger
078e3bcdff tests: Convert test case to also use binary formatted key
To get better code coverage, convert existing test case to
use one time a hex formatted key and the other time the same
key in binary format.

Do some improvements on the test code on the way.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2018-11-19 17:07:31 -05:00
Stefan Berger
13b76898a5 tests: Add missing file sizes and some other reorg to test case
2 file sizes were missing. Also use $() to execut commands rather
than ``. Use get_filesize to get the size of a file.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2018-11-19 17:07:31 -05:00