Commit Graph

926 Commits

Author SHA1 Message Date
Stefan Berger
9a8ee12f47 travis: Integrate with Coveralls.io
Integrate the Travis builds with Coveralls.io by sumitting the coverage
results to Coveralls.io.

We have to run the coveralls script with sudo rights since otherwise we
get permission denied errors.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2018-10-25 12:30:21 -04:00
Stefan Berger
b8421f3de4 build-sys: Support --enable-test-coverage as an option
Support --enable-test-coverage as an option for compiling with
coverage instrumentation.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2018-10-25 12:30:21 -04:00
Stefan Berger
5eeea3570b build-sys: Support --disable-hardening as an option
By default the hardening compiler flags are enabled and
--disable-hardening disables them.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2018-10-25 10:32:36 -04:00
Stefan Berger
0c00eb5019 swtpm: Have the CUSE TPM return the original TPM start error code
Have the CUSE TPM return the TPM start error, particularly
TPM_DECRYPT_ERROR in case a wrong key was passed, rather than the plain
TPM_FAIL error code. This was a difference with the 'other' swtpm
interfaces that already returned the original error code.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2018-10-25 10:32:36 -04:00
Stefan Berger
3327d83878 samples: Fix a typo
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2018-10-25 10:32:36 -04:00
Stefan Berger
15a14c552a samples: Add support for password protected root CA priv. key
Support creation and usage of the root CA with a password protected
private key. The root CA's key password can be set using the environment
variable SWTPM_ROOTCA_PASSWORD.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2018-10-25 10:32:36 -04:00
Stefan Berger
05f4d55f1f samples: Add a script to create a TPM 1.2 intermediate CA
This (experimental) script uses GnuTLS tpmtool to create a TPM 1.2
intermediate CA that can sign a vTPM's EK and platform certificates.

Add a man page for this tool.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2018-10-15 20:45:48 -04:00
Stefan Berger
07c786d1a0 samples: Enable support for TPM 1.2 signing keys for cert signing via GnuTLS
GnuTLS can use TPM 1.2 keys for signing. For this we just need to support
key URLs in the GnuTLS format:

tpmkey:uuid=...
tpmkey:file=...

We don't try to read these URLs as files but pass them through as URLs to
the swtpm_cert tool that will then try to sign with the TPM 1.2 key by
passing the URL to GnuTLS API calls.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2018-10-15 20:45:48 -04:00
Stefan Berger
fea8979648 swtpm_cert: Allow using a TPM 1.2 signing key for signing cert
Gnutls supports TPM 1.2 keys in its API and we can use a TPM 1.2
signing key for signing the EK or platform certs.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2018-10-15 20:45:48 -04:00
Stefan Berger
33e1e50849 samples: Add a usage screen to swtpm-loclca to show upon --help
swtpm-localca was missing a help screen. This patch adds it and
is shown when --help or -? or -h is passed.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2018-10-12 17:43:19 -04:00
Stefan Berger
f759520c02 tests: Check expected error output against expected error message
Some tests are expected to fail. Capture the error output and test it
against epected error output. This also makes the test output less
noisy.

Also remove some other output noise.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-10-08 06:43:30 -04:00
Stefan Berger
148010c0b6 tests: Shut down swtpm at the end to avoid kill
Shut down the swtpm process at the end to avoid it being killed
and with that getting noise in the test log.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-10-08 06:43:30 -04:00
Stefan Berger
08c8820a74 tests: Return a string from get_file_hash if file not found
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-10-08 06:43:30 -04:00
Stefan Berger
3ad55f8c3a tests: Only run test_tpm2_samples_swtpm_localca if certtool was found
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-10-06 18:09:08 -04:00
Stefan Berger
08682141a1 swtpm: Rename crypto functions to have SWTPM prefix
The crypto functions for AES encryption and decryption clash with crypto
function names of libtpms. Avoid this by prefixing them with SWTPM_ instead
of TPM_.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-10-06 18:09:08 -04:00
Stefan Berger
5478de0a0d build-sys: Link with -lrt if libc does not have clock_gettime()
On older system libc does not provide clock_gettime() so we need
to link with -lrt.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-10-05 22:20:49 -04:00
Stefan Berger
1389bafe3f build-sys: Pass header file to compiler for checking for supported flag
Older versions of gcc need some input file to compile so that
we learn whether -fstack-protector-strong is supported.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-10-05 22:20:49 -04:00
Lukas Vrabec
6e9052da5a Do few changes to follow distribution SELinux policy 2018-10-05 13:34:43 -04:00
Stefan Berger
03c7fe4566 tests: Get the IBM TSS2 test suite and run it
Get the IBM TSS2 test suite from its git repo, compile it, and run
its test suite if SWTPM_TEST_EXPENSIVE=1 is set.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2018-10-05 13:34:22 -04:00
Stefan Berger
0143c410fe SELinux: A few more rules needed by libvirt 4.4 on F28 for running QEMU
This patch adds rules that are needed for running QEMU with libvirt 4.4
on F28. This allows one to test the libvirt management stack and QEMU with
swtpm and SELinux in enforcing mode.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-10-02 12:16:36 -04:00
Stefan Berger
ebf1557dde build-sys: Move glib-2.0 dependency to CUSE TPM build
Only when the CUSE TPM is built we need the glib-2.0 dependency
(which can be removed at some point probably).

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-10-02 10:19:31 -04:00
Stefan Berger
a6fced8d25 swtpm: Use non-exclusive threads to have glib2 clean up after itself
glib2 did not clean up a proxy thread once the pool was torn down. The
reason was that an exclusive pool was used. Switch to a non-exclusive
pool, which will cause the last thread to terminate as well and we have
a clean valgrind log now.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-10-02 09:24:45 -04:00
Stefan Berger
90ae0c2783 tests: wait for files to appear or disappear after starting swtpm
Wait a few seconds for files to appear or disappear after starting the
swtpm process. This helps avoid test failures when the system is under
load.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-10-01 12:52:20 -04:00
Stefan Berger
c46d6717ae tests: Add delay after finding file for process to write into it
Add a delay of 0.2s after a file is found in wait_for_file so that the
process can also write into it. Sometimes we are also interested in the
content and don't seem to get the content since we didn't wait for
the file to have been written to. It happens occasionally when the system
is under load that we don't seem to be able to read the file content
afterwards.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-10-01 12:52:20 -04:00
Stefan Berger
45d2d092f3 tests: Increase timeout for shutdown for running with valgrind
To avoid timeouts when running the tests with valgrind, increase
the timeout until the swtpm process must have terminated after a
shutdown signal to 4 seconds.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-10-01 12:52:20 -04:00
Stefan Berger
b096e8938d swtpm: Initialize structure using memset
Gcc 4.9.2 on ARM does not like the initializer '= { 0 }', either.
So switch it to memset.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-09-30 12:05:20 -04:00
Stefan Berger
fb8fb15965 swtpm: Initialize ptm_est type to avoid uninitialized bytes
Valgrind complains about uninitialized bytes being accessed by a writev()
call in libfuse. It points to a line in the error branch
'error_not_running', but the error does not seem to come from there.
Instead, if we initialize ptm_est to zeros the problem goes away.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-09-28 14:37:35 -04:00
Stefan Berger
86dac14a18 swtpm: Exit CUSE TPM using fuse_session_exit()
With the fuse_session now global, we can use it to exit the CUSE
TPM using fuse_session_exit().

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-09-28 14:37:35 -04:00
Stefan Berger
eddd5787bb swtpm: Implement low level CUSE startup code to get to fuse_session
To be able to get to the low level fuse_session data structure, which
allows us to terminate the program more gracefully than the exit() in
the ioctl processing code, we implement the low level cuse startup code.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-09-28 14:37:35 -04:00
Stefan Berger
6c6e5c936b SELinux: F27 needs allow for swtpm_exec_t:file map
F27 needs an additional rule for starting the swtpm from libvirt.

Add the rule 'allow svirt_t swtpm_exec_t:file map'

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-09-28 07:17:14 -04:00
Stefan Berger
a3914f53fa SELinux: re-add allow rules for file entrypoint
The file entrypoint rules are still needed, so add them back again.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-09-27 15:35:13 -04:00
Stefan Berger
943f03f12e swtpm_ioctl: replace initializer with memset for gcc 4.2.1
gcc 4.2.1 does not accept the initializer '= { 0 }' and so we now switch
this to memset as well.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-09-26 21:55:55 -04:00
Stefan Berger
f070a0b5bb swtpm_ioctl: Initialize structures for use with ioctl()
Valgrind complains that there are uninitialized bytes when ioctl() is called.
This is due to the fact that we are passing the structure to the ioctl()
without specifying how many bytes are valid in the passed buffer.
So, we initialize the buffers to 0 and the complaint is resolved.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-09-27 11:07:06 -04:00
Stefan Berger
100317d541 tests: Call function rather than running 'ps aux' to display proceses
Call a function display_processes_by_name that displays all processes
if needed. The function is quiet, though.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-09-27 10:19:09 -04:00
Stefan Berger
4dd376c3b4 tests: Replace kill_quiet after shutdown with wait_process_gone
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-09-27 09:59:17 -04:00
Stefan Berger
b1eb3620e2 swtpm: Only copy length of user privided IV into possibly longer ivec
When the AES encryption and decryption function were extended to support
256bit keys the size of the user ivec on the stack was also increased to
32 bytes. For the user provided IV we now must only copy 16 bytes in case
an 128 bit key is used. Fix the length parameter to the memcpy().

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-09-26 19:05:59 -04:00
Stefan Berger
ce13edf590 rpm: Fix spec for passing fedora-review
We seem to be missing a dependency on selinux-policy-devel, so add it.
The name of the source tar has to be set to what 'make dist' produces.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-09-25 08:35:45 -04:00
Stefan Berger
1fb811bf9e rpm: swtpm-tools requires swtpm of the exact same version
Tie swtpm-tools updating to swtpm updating and vice versa by requiring
swtpm-tools the swtpm package to have the same version.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-09-25 08:35:45 -04:00
Stefan Berger
b4372fe50f tests: Use python3 rather than python for the test programs
Fedora policy seems to be to use python3 explicitly for the hashbang
rather than python, which could be either python2 or python3. So convert
it to python3. Also adapt configure.ac to require python3 executable.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-09-25 08:35:45 -04:00
Stefan Berger
a246953a50 build-sys: Install libswpm_libtpms into $(libdir)/swtpm
Install the private libswtpm_libtpms into $(libdir)/swtpm
rather than into the shared libaries directory.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-09-25 08:35:45 -04:00
Stefan Berger
908afaf5f8 build-sys: Replace AC_PROG_LIBTOOL with LT_INIT
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-09-25 08:35:45 -04:00
Stefan Berger
3041f38769 build-sys: Do not build man page or SELinux policy for CUSE if --without-cuse is used
To make the RPM building easier for the --without-cuse case we have to omit
a couple of files from being built so that they are not left-overs when
packing the RPM without building swtpm-cuse.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-09-25 08:35:45 -04:00
Stefan Berger
0528804205 rpm: Replace %bcond_with gnutls with %bcond_without gnutls
The meaning of %bcond_without is that it enables a feature by default.
We want to buld with gnutls, so enable it.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-09-25 08:35:45 -04:00
Stefan Berger
e1eca6c8f8 rpm: Add entry to changelog
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-09-25 08:35:45 -04:00
Stefan Berger
3b40c9167a build-sys: Fix policy package dependencies for out-of-tree build
An out-of-tree build fails to build swtpm_svirt.pp due to missing
source files from the swtpm.pp policy. Add the swtpm.{te,if,fc} files
as dependencies of the swtpm_svirt.pp policy package.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-09-25 08:35:45 -04:00
Stefan Berger
1e1252b153 build-sys: Fix the SELinux policy build target for parallel builds
Use .NOTPARALLEL for the SELinux policy build target to avoid running
the rule concurrently and deleting the tmp directory while another
build is running.

For some reason it is not possible to use $(MAKE) since otherwise the
building of the policy package fails.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-09-24 17:48:41 -04:00
Stefan Berger
940a774bb4 docu: Cut down the README to its minimum
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-09-24 17:48:41 -04:00
Stefan Berger
ca14f1cfd9 SELinux: Fix some nits in the SELinux policy files
This patch is partially from Lukas Vrabec (lvrabec@redhat.com) and fixes
some nits in the SELinux policy.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-09-24 17:48:41 -04:00
Stefan Berger
5b09de83a2 SELinux: Install policy package files to /usr/share/selinux/packages
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-09-24 17:48:41 -04:00
Stefan Berger
0f05604869 build-sys: Create compressed policy package files
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-09-24 17:48:41 -04:00