Commit Graph

926 Commits

Author SHA1 Message Date
Stefan Berger
bf5220cf20 swtpm: Add missing kdf option documentation to help screen
Add missing kdf option documentation to help screen. The kdf
option parameter support has been there since 0.1.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2019-06-24 07:27:39 -04:00
Stefan Berger
2d14c61866 tests: Do not run key derivation test on ppc64
The old prime number generation algorithm also does not return
the same numbers on ppc64 (big endian) as on x86_64 or ppc64le,
so do not run the test there.

Signed-off-by: Stefan Berger <stefanb@linu.ibm.com>
2019-06-20 13:20:32 -04:00
Stefan Berger
50a61bbc59 tests: Add test case for deriving key from primary key
Add a test case that tests the derivation of an EC key from the
primary key.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-06-18 17:09:56 -04:00
Stefan Berger
d617dd6d1b tests: Ensure that derived keys are always the same for the same state
Using the same initial state, the derived keys always have to be the
same.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-06-14 22:18:48 -04:00
Stefan Berger
12234f8e5f swtpm: CUSE TPM needs prtcl syscall for thread pool support
The CUSE TPM needs the prctl syscall to function correctly when
commands are passed via the thread pool.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-06-14 22:18:48 -04:00
Stefan Berger
4ba6012cef tests: Use tag v1470 for revision of ibmtss2 test suite
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-06-05 21:31:05 -04:00
Stefan Berger
e87114b4b6 Travis: Set LIBTPMS_CFLAGS when sanitizing swtpm
Set the LIBTPMS_CFLAGS for libtpms to sanitize the same as we sanitize
in swtpm. Also set UBSAN_OPTIONS and ASAN_OPTIONS for directing runtime
behavior to halt_on_error=1.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-04-18 07:59:53 -04:00
Stefan Berger
34eb89f5a0 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 07:59:53 -04:00
Stefan Berger
a9a9320aab swtpm: Add 9 more syscalls to seccomp profile blacklist
Add 9 more syscalls of concern to the seccomp profile blacklist.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-04-12 12:57:43 -04:00
Stefan Berger
86e8f60584 tests: wait for file content in wait_for_file
When the PID_FILE is passed to swtpm as a file descriptor in one test,
we already create a file without content when running
'exec 100<>$PID_FILE'. So we have to extend wait_for_file to also
wait for file content since the 0.2 seconds delay are sometimes not
enough for content to have been written. Otherwise we do not get the
PID of the process. We can extend the function in this way since all
its usages imply that some content should become available.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-04-08 10:17:32 -04:00
Stefan Berger
9bbe79d853 tests: Convert test case to use IPv6 bindaddr ::1 where available
Use the IPv6 bindaddr ::1 where available on Linux. Travis doesn't
seem to support IPv6 addresses at the moment.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-04-04 13:02:19 -04:00
Stefan Berger
f7de241e51 swtpm_bios: Switch to use getaddrinfo to also support IPv6
Switch the lookup of the address to use getaddrinfo so IPv6 also works.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-04-04 13:02:19 -04:00
Stefan Berger
1d043aef78 swtpm_ioctl: Switch to use getaddrinfo to also support IPv6
Switch the lookup of the address to use getaddrinfo so IPv6 also works.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-04-04 13:02:19 -04:00
Stefan Berger
281e7d2d43 travis: Run cpp-coveralls without sudo
Adjust directory and file ownerships so that we don't have to
run cpp-coveralls under sudo.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-04-03 12:46:25 -04:00
Stefan Berger
129c6b5bf2 swtpm: Add support for fd_to_filename on OS X and test it
Extend the previously modified test case to also test on
Darwin now that we are able to convert a file descriptor
to a filename.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-04-03 09:37:03 -04:00
Stefan Berger
19a8cdd67b tests: Use a file descriptor for the pid file on Linux and Cygwin
On Linux and Cygwin we can pass a file descriptor for the pid
file, on other platforms it doesn't work (yet).

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-04-03 09:37:03 -04:00
Stefan Berger
8d70fd4a16 tests: Pass --runas parameter to swtpm
Pass the --runas parameter to swtpm so we can test switching it
to a given user 'nobody'.

We also have to change ownership of files and directories so that
the nobody user can write the coverage files when swtpm ends.
In the test case we then use the trick of changing file ownership
just before we terminate swtpm, which will trigger the writing
of the .gcda files. We need to have nobody own these files.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-04-02 18:08:06 -04:00
Stefan Berger
e533180b17 tests: Use file descriptor passing for log file
Convert test case to use file descriptor passing for the log file.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-04-02 18:08:06 -04:00
Stefan Berger
bb0aa2ad5a tests: Pass file ownership using uid and gid
Pass file ownership using the uid= and gid= parameters when run
as root and check the result.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-04-02 18:08:06 -04:00
Stefan Berger
f487473cf6 tests: Use mode= to set file mode bits in test and check them
Use the mode= parameter of the TPM's state file and a unix
socket to have swtpm set the file mode bits and check that
they are set as expected.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-04-02 18:08:06 -04:00
Stefan Berger
e617652a57 gitignore: Ignore files related to gcov
Ignore files related to gcov.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-04-02 18:08:06 -04:00
Stefan Berger
420a18f1d0 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-02 18:08:06 -04:00
Stefan Berger
4c7faf4617 travis: Exclude libtpms directory from coverage reporting
Exclude libtpms directory from coverage reporting.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-04-02 18:08:06 -04:00
Stefan Berger
59b07baffc 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-02 18:08:06 -04:00
Stefan Berger
45ed7764fb tests: Add yet more tests for TPM 1.2 and enable auditing
Add test cases 25 and 26 and run test 25 with auditing enabled.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-04-01 06:56:31 -04:00
Stefan Berger
c4a9e78aab tests: Fix some issues with TPM 1.2 test
- Clean up state files in case the test suite was interrupted
- Allow running it from the test directory by creating an absolute
  path for TESTDIR so we can find the patch file; error out in
  case the patching fails
- Run test case 2 and 1 as well but ignore ERROR output in case
  of test 1. The errors stem from us not restarting the TPM when
  the test suite asks for it.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-03-29 12:38:55 -04:00
Stefan Berger
b752aed8f5 tests: Add test case running TPM 1.2 test suite
Add a test case that downloads the TPM 1.2 package from sourceforge,
patches a few files for OpenSSL compatibility, and runs a few test
cases of that test suite. Look for ERROR output in the test suite.
This test suite also provides better code coverage for libtpms.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-03-28 20:58:04 -04:00
Stefan Berger
a18cf08504 tests: Use an empty options file in case options file is accessed
To prevent the test case from failing when an no --prefix is used
when configuring, use an empty options file via /dev/null. Otherwise
swtpm-localca starts looking for the options file in a place where
there is none.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-03-26 06:51:00 -04:00
Stefan Berger
5d35321e20 build-sys: Avoid prefix=NONE if no prefix is passed to configure
If no prefix is passed to the configure line we get prefix=NONE
in evaluations of variables that depend on prefix at this point.
If the user provides no --prefix we assume /usr/local as the
default and override the 'NONE' value we have at this point.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-03-21 16:53:49 -04:00
Stefan Berger
9cd723d8e1 man: Add documentation about --seccomp option to man pages
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-03-18 15:43:44 -04:00
Stefan Berger
933f405572 docs: Add entry to CHANGES file about seccomp profile
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-03-18 15:43:44 -04:00
Stefan Berger
758bf70a3a packages: Add libseccomp-devel to rpm and debian build deps
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-03-18 15:43:44 -04:00
Stefan Berger
a3820b8634 tests: Extend tests cases with test for active seccomp profiles
Extend existing test cases to test for active seccomp profiles.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-03-18 15:43:44 -04:00
Stefan Berger
07dfd95887 swtpm: Enable support for seccomp profile
Enable support for the seccomp blacklist profile that is
enabled by default and can be disabled using the following option:

--seccomp action=none

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-03-18 15:43:44 -04:00
Stefan Berger
2dd48f6887 swtpm: Extend options parse for parsing seccomp options
Extend the parse that parses the seccomp options like:

--seccomp action=none|log|kill

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-03-18 15:43:44 -04:00
Stefan Berger
d9947892b1 swtpm: Implement function to build a blacklist seccomp profile for swtpm
We build a blacklist of syscalls that we don't want the swtpm to ever be
able to execute.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-03-18 15:43:44 -04:00
Stefan Berger
df010be650 Travis: Add libseccomp-dev to packages to install
Do not run the 'asan' test with seccomp compiled in since the asan
libraries seem to use syscalls that we blacklist in the seccomp
profile. In particular those are:

- clone
- sigaltstack
- ptrace

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-03-18 15:43:44 -04:00
Stefan Berger
761df6cd63 build-sys: Add libbsecomp to configure.ac
Implement support for --with-seccomp and --without-seccomp for Linux
systems with --with-seccomp being the default. On all other systems
--without-seccomp is the implicit default.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-03-18 15:43:44 -04:00
Stefan Berger
869df69fe0 swtpm: implement uninstall_sighandlers
Implement uninstall sighandlers to uninstall the signal handlers
and not to create another pipe.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-03-14 10:22:54 -04:00
Marc-André Lureau
c5a3a4f2f9 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 08:36:10 -05:00
Stefan Berger
6736dbdba5 rpm: Adjust RPM spec file for 0.1 release
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-02-26 08:33:24 -05:00
Stefan Berger
4d74a926b3 Travis: Get Travis to submit to Coverity again
The extension of the travis.yml with the matrix broke the Coverity
submission. This patch fixes this. We have to build libtpms in
build_command_prepend since before_script now does something different.

We only build in task .1 and exit early on all the other ones if
we are using the coverity_scan git branch.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-02-26 08:33:24 -05:00
Stefan Berger
f1a8a1cb51 Set version to 0.2.0 for next release
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-02-26 08:33:24 -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