Commit Graph
7863 Commits
Author SHA1 Message Date
David Tardon f20ae7dbdf udev-util: add wrapper for sd_device_get_property_value()
... that allows to pass additional properties to fall back to.
2023-11-13 19:18:23 +01:00
Yu Watanabe 4cec9b1b17 Merge pull request #30015 from poettering/tpm2-slow-tests
tests: skip slow tpm2 tests if slow tests aren't enabled
2023-11-14 02:38:33 +09:00
Lennart Poettering 47a7a4d404 tests: add macro for generating function enter log message
The test-tpm2 test multiplexes a bunch of tests from a single
entrypoint test that creates the TPM2 connection. This means we only get
the nice log output which test we are looking for once for the
entrypoint.

Let's add a macro that allows it to nicely generate it for the inner
tests too and use it.
2023-11-13 16:50:55 +01:00
Lennart Poettering 3cc7a9fd25 udev-util: add generic device_get_{vendor,model}_string() helpers
We chck the same props in various places, add a single implementation of
a call to inquire this.
2023-11-13 16:24:17 +01:00
Lennart Poettering aa25e19b47 util-lib: share plymouth client code
Let's add a new "plymouth-util.c" module with helpers for talking to
plymouth. We so far had three places for this, let's unify the code
doing this a bit.
2023-11-13 14:17:05 +00:00
Lennart Poettering 1a292659f2 Merge pull request #29995 from keszybz/voidify-timestamp-getters
Rename and voidify timestamp getters
2023-11-13 14:41:42 +01:00
Zbigniew Jędrzejewski-Szmek fa5a025167 Rename {dual,triple}_timestamp_get to {dual,triple}_timestamp_now
Those functions take a pointer to a timestamp and return a timestamp pointer,
so the reader would be justified to think that those are just getters. Rename
them to avoid confusion.
2023-11-13 13:27:07 +01:00
Mike Yuan 8ea288db01 conf-parser: remove unused condition
Follow-up for 9ac2f3c4d2

config_parse() returns 0 only on ENOENT, which can
never happen since we pass the FILE stream.
2023-11-13 10:32:38 +00:00
Mike Yuan 9ac2f3c4d2 conf-parser: pin seen config files
Follow-up for 93f1da4556

Addresses https://github.com/systemd/systemd/commit/93f1da45566d064f4f053b37bbac2813631f58b1#r132152321
2023-11-13 05:11:26 +09:00
Yu Watanabe 7fd93e5acc Merge pull request #29968 from bluca/executor_selinux_lazy_load
executor: lazily load SELinux
2023-11-13 05:06:44 +09:00
Yu Watanabe 5996cc348c conf-parser: fix argument type of ConfigPerfItemLookup
Prompted by #29972.
2023-11-13 00:46:39 +09:00
Yu Watanabe 62c9beaa2c conf-parser: inline variable declaration 2023-11-13 00:46:34 +09:00
Luca Boccassi 0b511787fd selinux: change fd check into assertion 2023-11-11 12:33:19 +00:00
Luca Boccassi 0617da2edb selinux: support lazy initialization
Loading the SELinux DB is slow, so support lazy initialization so
that it is done when needed.
2023-11-11 12:33:19 +00:00
Luca Boccassi 2c6a231b47 selinux: avoid probing memory status if debug logs are not enabled
Given we are optimizing the selinux paths, avoid doing these operations
unless the result is actually used
2023-11-11 12:29:52 +00:00
Luca Boccassi be0916f77c Merge pull request #29955 from poettering/repart-seal-key
repart: add --tpm2-seal-key= support, matching the recently added support cryptenroll has
2023-11-10 16:52:00 +00:00
Lennart Poettering fbe7db47f4 tpm2-setup: also save the SRK to the file system in TPM2_PUBLIC format
We already save it in PEM format, also store it TPM2_PUBLIC format next
to it. This is useful for usage with systemd-cryptenroll's
--tpm2-device-key= switch.
2023-11-09 12:47:24 +01:00
Lennart Poettering a8d8d34bfc tpm2-util: move loading of TPM2B_PUBLIC from disk into tpm2-util.c
No change in behaviour, let's just move this over so that we can reuse
this in repart later (and don't have to export the ugly `sym_` function
pointer for it)
2023-11-09 12:27:43 +01:00
Felix Dörre e375bc5fcc journalctl: verify sealed log epochs are continuous
Currently empty epochs are not sealed. This allows an attacker to truncate
a sealed log and continue it without any problems showing when verifying the
log.

This partially addresses CVE-2023-31438. One way to extend this change to
address CVE-2023-31438 completely, would be to verify that there is exactly
one seal per epoch (and not sealing when the epoch has not ended yet).

the change also adds a journal-file flag: HEADER_COMPATIBLE_SEALED_CONTINUOUS
this flag indicates that a journal file is sealed continuously and decides whether
any missing crypto epochs should trigger a warning or an error.
2023-11-09 05:13:27 +09:00
Dan Streetman c3a2a681be cryptenroll: add support for calculated TPM2 enrollment
Instead of enrolling the local TPM to a luks volume, use the public key from a
TPM to enroll it into the luks volume. This is useful when enrolling a TPM that
is not currently accessible, for example if the TPM is located on a different
system.
2023-11-07 12:20:54 -05:00
Dan Streetman 65883f6c10 tpm2: update test-tpm2 for tpm2_calculate_seal()
Add testing for tpm2_calculate_seal().
2023-11-07 12:00:07 -05:00
Dan Streetman 0a7874ad55 tpm2: add tpm2_calculate_seal() and helper functions
Add functions to calculate a sealed secret object.
2023-11-07 12:00:02 -05:00
Dan Streetman 2d784782bf tpm2: add tpm2_sym_alg_*_string() and tpm2_sym_mode_*_string()
Add functions to convert between alg id and string name for symmetric
algorithms and symmetric encryption modes.
2023-11-07 10:59:44 -05:00
Dan Streetman 2eea1b8f2f tpm2: add test to verify srk templates
Verify the tpm2_get_srk_template() and tpm2_get_best_srk_template() functions
work as expected.
2023-11-07 10:59:44 -05:00
Dan Streetman 788933379d tpm2: allow using tpm2_get_srk_template() without tpm
The SRK templates are defined by specification, so move the check for TPM
support to the tpm2_get_best_srk_template() function, and allow anyone to get
the ECC and RSA templates.

Also add test to verify the SRK templates are correct.
2023-11-07 10:59:44 -05:00
Lennart Poettering 9942f855a9 tree-wide: take in all *our* JSON structures also decimal strings
Let's be friendly in what we accept: whenever we define a JSON
structure, let's also allow decimal strings where we want an integer.

This patch purely replaces JSON_VARIANT_UNSIGNED by
_JSON_VARIANT_TYPE_INVALID in the various JsonDispatch[] tables, so that
we'll happily accept any type in json_dispatch(), so that
json_dispatch_uint64() and related tools can do their thing.

This does not switch over OCI (as a JSON structure not defined by us).
2023-11-07 14:25:40 +01:00
Lennart Poettering 67a3028555 json: teach dispatch logic to also take numbers formatted as strings
JSON famously is problematic with integers beyond 53 bits, because
JavaScript stores everything in double precision floating points.
Various implementations in other languages can deal with signed 64 bit
integers, and a few can deal with unsigned 64bit too (like ours).

Typically program that need more then 53 bit of accuracy encode integers
as decimal strings, to make sure that even if consumers can't really
process larger values they at least won't corrupt the data while passing
it along. This is also recommended by JSON-I (RFC 7493)

To maximize compatibility with other implementations let's add 1st class
parsing support for such objects in the json_dispatch() API.

This makes json_dispatch_uint64() and related calls parse such
integers-formatted-as-decimal-strings as uint64_t. This logic will only
be enabled if the "type" field of JsonDispatch is left unspecified (i.e.
set to negative/_JSON_VARIANT_TYPE_INVALID) though, hence alone does not
change anything in effect.

This purely is about consuming such values, whether we should genreate
them also is a discussion for a separate PR.
2023-11-07 14:25:40 +01:00
Antonio Alvarez Feijoo 14ac242d50 bootspec: fix typo 2023-11-07 11:17:12 +00:00
Luca Boccassi 4a5bf4896f Merge pull request #29882 from keszybz/documentation-cleanup
Documentation cleanup
2023-11-06 21:24:08 +00:00
Zbigniew Jędrzejewski-Szmek 55e40b0be8 tree-wide: s/life-cycle/lifecycle/g 2023-11-06 20:16:34 +01:00
Daan De Meyer ad6216cbc7 boot-entry: Add boot_entry_token_type_to_string() 2023-11-06 14:39:01 +01:00
Yu Watanabe e423b40d35 tree-wide: fix typo 2023-11-04 11:58:12 +09:00
Luca Boccassi 8d04721507 Merge pull request #28891 from poettering/pcrlock
new pcrlock tool for generating signed PCR policies for PCR 0, 1, 4, …
2023-11-03 16:07:43 +00:00
Luca Boccassi 1af46aecf5 Merge pull request #29508 from CodethinkLabs/systemd-vmspawn-pr
systemd-vmspawn implementation that only supports disk images
2023-11-03 16:04:38 +00:00
Lennart Poettering 2037642930 Merge pull request #29840 from poettering/cryptsetup-tweaks-nore
two cryptsetup bugfixes and some clean-ups
2023-11-03 14:40:15 +01:00
Lennart Poettering a434270139 pcrlock: add new pcrlock tool 2023-11-03 11:23:54 +01:00
Lennart Poettering b52e950598 tpm2-util: add common array for TPM2 hash algorithms
This is useful to enumerate all hash algorithms we want to predict
measurements for.
2023-11-03 11:23:34 +01:00
Lennart Poettering 40ce73214a tpm2-util: make various marshalling/unmarshalling calls static, as we only use them internally in tpm2-util.c
Note, some of these were just added in this same PR. We only exported
them initially to make sure gcc doesn't complained about unused local
symbols.
2023-11-03 11:23:14 +01:00
Lennart Poettering ce80da02b8 tpm2-util: add generic helpers for sealing/unsealing data
These helpers tpm2_seal_data()/tpm2_unseal_data() are useful for
sealing/unsealing data without any further semantics around them. This
is different from the existing tpm2_seal()/tpm2_unseal() which seal with
a specific policy and serialize in a specific way, as we use it for disk
encryption.

These new helpers are more generic, they do not serialize in a specific
way or imply policy, they are just the core of the sealing/unsealing.

(We should look into porting tpm2_seal()/tpm2_unseal() onto these new
helpers, but this isn#t trivial, since the classic serialization we use
uses a merged marshalling of private/public key, which we'd have to
change in one way or another)
2023-11-03 11:22:55 +01:00
Lennart Poettering 48d060564a tpm2-util: add helper for creating/removing/updating NV index with stored policy
This is the primary core of what pcrlock is supposed to do eventually:
maintain a TPM2 policy hash inside an NV index which we then can
reference via a PolicyAuthorizeNV expression to lock other objects
against it.
2023-11-03 11:22:35 +01:00
Lennart Poettering 2cd8f75316 tpm2-util: add calls for calculating/submitting PolicyAuthorizeNV + PolicyOR TPM2 policies 2023-11-03 11:22:16 +01:00
Lennart Poettering 34657b1f0b tpm2-util: add helper that calculates name of NV index 2023-11-03 11:21:55 +01:00
Lennart Poettering f7be7a245e tpm2-util: add helper for setting TPM2B_AUTH in binary 2023-11-03 11:21:35 +01:00
Lennart Poettering 360062095d tpm2-util: add helpers for marshalling NV index public areas 2023-11-03 11:21:16 +01:00
Lennart Poettering 9fe3b63672 tpm2-util: add helpers for marshalling public/private keys
Note: we export these new symbols for now. A later commit in this PR
will make them static again. The only reason they are exported here is
to make sure gcc doesn't complain about unused static symbols, and I
really wanted to commit them in a separate commit.
2023-11-03 11:20:56 +01:00
Lennart Poettering 8f3f9c2bf5 tpm2-util: export a couple of functions we'd like to use for pcrlock 2023-11-03 11:20:36 +01:00
Lennart Poettering 199d758879 tpm2-util: pick up a few new symbols from tpm2-tss 2023-11-03 11:20:30 +01:00
Lennart Poettering f88f929470 tpm2-util: add helper for returning path to EFI event log blob 2023-11-03 11:20:11 +01:00
Lennart Poettering a63b260166 tpm2-util: add various uefi event log definitions 2023-11-03 11:19:46 +01:00
Lennart Poettering a758a12870 cryptsetup: pass AskPasswordFlags down into pkcs11 module
The pkcs11 cryptsetup token module is a bit different from the tpm2 +
fido2 ones: it asks for the PIN itself, rather than bubbling up a
request to get a PIN. That's because it might need multiple, and because
we don't want to destroy a the pkcs11 session half-way and thus risk
increasing pin counters.

Hence, we sometimes ask for PINs from our code, rather than let the
libcryptsetup caller do that. So far we didn't pass the AskPasswordFlags
field down into the module though. Fix that.

Fixes: #28665
2023-11-03 09:51:53 +01:00