This adds an initial TPM2 implementation of the io.systemd.Report.Signer
interface, which returns a set of signed TPM attestations that also
includes the supplied report digest.
The returned report consists of multiple components:
- A signed PCR quote generated with TPM2_Quote.
- Signed NvPCR attestations generated with TPM2_NV_Certify.
- A signed audit session attestation generated with
TPM2_GetSessionAuditDigest.
Each signed report component includes the JSON encoded TPMS_ATTEST
attestation structure and corresponding signature, in both PEM encoded
form and as a JSON encoded TPMT_SIGNATURE structure.
NvPCR report components also include the readable name of the NvPCR, the
NV index public area as the JSON encoded TPMS_NV_PUBLIC structure, and some
additional authenticated data that is digested and supplied as the
qualifying data to the TPM2_NV_Certify command. This authenticated data
includes the NvPCR name and priority.
The report digest that is supplied via varlink is supplied as the
qualifying data to the audit session attestation.
The returned report also includes the event log which is retrieved from
pcrlock's varlink interface, and the public area of the signing key in
both PEM encoded form and as a JSON encoded TPMT_PUBLIC structure.
The audit session attestation is always the last component. The
preceding components are all executed with the audit session, and the
signer requires the audit session to remain exclusive whilst generating
the report. What this does is provide evidence to a verifier that the
overall report is a single, consistent snapshot of the system (ie, no
other TPM commands executed whilst generating the report) because the
audit session attestation contains a field that indicates that the
session was exclusive at the time it was attested.
The set of attested PCRs and NvPCRs are currently hardcoded. It includes
all firmware PCRs with the exception of PCR6, and all other PCRs with
the exception of the IMA one (which isn't useful on its own without the
IMA log). All defined NvPCRs are included.
A verifier can verify the signed attestation components individually by
verifying their signatures against the supplied attestation data, using
the supplied public key.
For the PCR report component, a verifier can replay the measurements in
the log in order to reconstruct the PCR values, and then use this and
the PCR selection from the attestation in order to calculate the PCR
digest, and then check that this matches the one in the attestation.
For the NvPCR report components, a verifier checks that the NV index
name in the attestation matches one that is anchored in PCR9 to be sure
that the attestation is for a valid NvPCR. A verifier can then replay
the measurements in the log to ensure that the resulting NvPCR value
matches the one supplied in the attestation. The authenticated data is a
JSON blob containing the NvPCR name and priority. A verifier can digest
this and ensure it matches the qualifying data in the attestation.
The audit session attestation includes the audit session digest and
whether the audit session was still exclusive when the attestation was
generated. A verifier should confirm exclusivity. The digest includes a
record of all TPM commands executed with the audit session, as each
command results in it being extended with the command parameter hash and
the result parameter hash. A verifier should replay the preceding report
components to compute an expected audit digest and make sure that this
digest matches the one in the attestation in order to be sure that the
overall report represents a single, consistent snapshot. The other
report components provide sufficient information for a verifier to
reconstruct the cpHash and rpHash.
When reconstructing the cpHash for the PCR and NvPCR components, the
signing scheme is the NULL scheme (they use the attestation key's
signing scheme). The required signing key public area is supplied in
the report. The supplied qualifying data is in the extra data field of
the attestation.
The PCR selection is also required to reconstruct the cpHash for the
PCR component. The PCR selection is available in the attestation.
The name of the NV index is also required to reconstruct the cpHash for
the NvPCR components. The name is available in the attestation.
The rpHash for each component can be reconstructed from the supplied
attestation blob and signature.
In the future, we might want to add more report component types. Eg, we
could add report components for ordinary NV indexes. Using the audit
session means that we could also add additional components that the TPM
can't attest directly, such as the values of interesting TPM properties
(as the TPM2_GetCapability calls will appear in the audit session digest).
The attestation signing key is stored as a JSON file in the report
signer's state directory. Different types of keys are supported:
- Ordinary keys that are protected by an existing persistent TPM key
such as the SRK or EK.
- Persistent TPM keys.
- Primary keys, which are recreated using a template on use.
When an ordinary or primary key is used, the report signer saves the
object context in its runtime directory. This context is used on future
invocations. This has the benefit that where a primary key is used, it
doesn't need to be recreated on each use. When an ordinary key is used,
we don't need to run TPM2_Load, which requires authorization with the
parent key, on each This authorization currently requires a policy
session for low-range EKs.
Regardless of the key type, it must be a restricted signing key. If no
key exists, an ordinary key is generated automatically.
The attestation key can also have an associated credential which is
attached to the signed report. The credential can be issued by a CA or
some other party during onboarding, and is presented to a verifier as
proof that the attestation key is authentic. It is considered an opaque
blob in order to not require it to be a specific format, such as a X.509
certificate. I've called this a "voucher" though because "cred" or
"credential" has other meanings in systemd.
As a follow-up to this, I plan to add a varlink interface for creating
attestation keys that can be used for report signing.
The trackpoint of the ThinkPad X1 Tablet Gen 3 detachable keyboard (USB
17EF:60B5) lives in the same HID interface as the touchpad, which is
bound to hid-multitouch. The kernel never sets INPUT_PROP_POINTING_STICK
for it, so input_id classifies the trackpoint as a plain mouse.
Mark it as a pointing stick so libinput applies trackpoint acceleration
instead of the mouse acceleration profile.
The interface also exposes a second mouse node without a middle button;
the modal match keys on the button set (k110,111,112) to select only the
trackpoint node and leave the touchpad and the other mouse node
untouched.
ecc_pkey_to_curve_x_y() marshalled the affine point coordinates with
BN_num_bytes() + BN_bn2bin(), which produce the minimal big-endian
encoding and strip any leading zero bytes. The affine coordinates are
elements of the curve's underlying field, though, and consumers expect
them at the fixed field width.
About 1 in 256 keys per coordinate has a most significant zero byte on
the curves whose field width is a whole number of bytes, and about 1 in 2
on P-521, where only the low bit of the leading byte is ever set. The
coordinate then comes out one or more bytes short of the field width. When
that happens tpm2_tpm2b_public_from_openssl_pkey() builds a TPM2B_PUBLIC
whose unique.ecc.x or .y is undersized. The TPM 2.0 reference
implementation requires each coordinate size to equal the key size in
bytes, so TPM2_LoadExternal() rejects the public area with TPM_RC_KEY.
The name a TPM derives for the object also stops matching the name
systemd computes in software, because the name hashes the marshalled
public area.
For a signed PCR policy the key is only round-tripped through the TPM at
unlock time, so an enrolled key with a leading-zero coordinate is
accepted by systemd-cryptenroll and systemd-measure and only fails when
the volume is first unlocked, with:
Esys_LoadExternal() Esys Finish ErrorCode (0x000002dc)
Failed to unseal secret using TPM2: State not recoverable
Derive the curve's field width from the EC group degree and zero-pad both
coordinates to it with BN_bn2binpad(). Padding a full-width coordinate is
a no-op, so only keys that a reference-conformant TPM rejects today change
their marshalling; no enrollment that currently unlocks changes behavior.
Every caller of this converter inherits the fix, including the
systemd-creds public-key binding.
Because the width now comes from the group rather than from the BIGNUM
being written, BN_bn2binpad() can fail where BN_bn2bin() could not, so
both calls return -EIO rather than asserting. It reports that through its
return value without touching the OpenSSL error queue, so these use
log_debug_errno() rather than log_openssl_errors(). EC_GROUP_get_degree
is file-local, matching the other libcrypto symbols used only here.
The tests pin the full expected coordinates for a P-384 key and a P-521
key that each have a leading zero byte. test-tpm2 gains a case pinning
the TPM object name for the P-384 key, because the name is derived from
the marshalled public area and this change alters it for exactly those
keys a reference-conformant TPM rejects today.
A MAC change can mean the link joined another network, e.g. on an
active-backup bond failover with FailOverMACPolicy=active. NDisc only
solicits when it starts, so IPv6 sat stale until the next unsolicited
RA. Restart NDisc to solicit immediately.
Similar to d13c07ecd8 and 373a4020d5, 65-integration.rules sets
ID_INPUT_TOUCHPAD_INTEGRATION=external, and libinput skips
disable-while-typing (DWT) for the device.
The touchpad is integrated into a detachable keyboard which isn't usable
on other devices so it should be marked as internal. This enables palm
detection and DWT.
The custom help() is replaced by a COMMAND() description, and
--introspect-cli is added. The referenced systemd-report-cgroup(8) man
page does not exist, so the reference is dropped.
The custom help() is replaced by a COMMAND() description, and
--introspect-cli is added. The abstract gets a trailing period. There is
no man page for this helper, so none is referenced.
The custom help() is replaced by a COMMAND() description, and
--introspect-cli is added. There is no man page for this internal helper,
so none is referenced.
The custom help() is replaced by a COMMAND() description, and
--introspect-cli is added. There is no man page for this internal helper,
so none is referenced.
The custom help() is replaced by a COMMAND() description, and
--introspect-cli is added. There is no man page for this internal helper,
so none is referenced.
The custom help() is replaced by a COMMAND() description, and
--introspect-cli is added. There is no man page for this internal helper,
so none is referenced.
The custom help() is replaced by a COMMAND() description, and
--introspect-cli is added. The abstract is changed to the imperative.
There is no man page for this udev helper, so none is referenced.
The custom help() is replaced by a COMMAND() description, and
--introspect-cli is added. The abstract is changed to the imperative.
There is no man page for this udev helper, so none is referenced.
The custom help() is replaced by a COMMAND() description, and
--introspect-cli is added. There is no man page for this udev helper, so
none is referenced.
The custom help() is replaced by a COMMAND() description, and
--introspect-cli is added. There is no man page for this udev helper, so
none is referenced.
The custom help() is replaced by a COMMAND() description, and
--introspect-cli is added. The help output had no abstract, so one is
added. There is no man page for this udev helper, so none is referenced.
The custom help() is replaced by a COMMAND() description, and
--introspect-cli is added. The help output had no abstract, so one is
added. There is no man page for this udev helper, so none is referenced.
The custom help() is replaced by a COMMAND() description, and
--introspect-cli is added. The help output had no abstract, so one is
added. There is no man page for this udev helper, so none is referenced.
The custom help() is replaced by a COMMAND() description, and
--introspect-cli is added. The tool has no man page of its own, so
iocost.conf(5), which describes it, is referenced. The test now also looks
for commands in /usr/lib/udev, where the udev helpers are installed.
The runtime directory holds what the helpers we fork off need: swtpm's socket
and, unless --tpm-state= points elsewhere, its state, the virtiofsd sockets,
the varlink control socket, and the QEMU config file. runtime_dir was declared
after the CLEANUP_ARRAY() that terminates those helpers, and cleanup handlers
run in reverse declaration order, so the directory was removed while all of
them were still running. That produces spurious errors from the helpers, and
anything they create while rm_rf() walks the tree can make the final rmdir fail
and leave the runtime directory behind.
Declare runtime_dir before the CLEANUP_ARRAY() instead, so the helpers are sent
SIGTERM and reaped first and the directory only goes away once nothing writes
to it anymore.
While at it, drop the rm_rf_physical_and_freep() destructors from the SSH key
paths. They are only ever assigned paths below the runtime directory, whose
removal takes them along, so those destructors never had an effect.
SetTimezone() and SetLocalRTC() updated the Context before writing
/etc/localtime or /etc/adjtime. If the write failed, D-Bus properties
showed the new value and a repeated request with the same value returned
success without retrying the file update.
Keep the write helpers Context-based, but save the old value before
installing the requested state. Restore the old Context value when the
backing file update fails.
Add TEST-45 coverage for failed alternate localtime and adjtime paths.
Follow-up for: f401e48c2d
Add a second COMMAND() for the mount.ddi helper namespace, like for
mount.storage and mount.mstack, so that it is exposed by --introspect-cli
too.
Fixes 1a54ce154c +
66246c98b5.
Since run0 --help now goes through the pager, provide a way to turn that
off from the command line, like all other commands that page --help. The
option is documented the same way as for systemd-run.
The custom help() is replaced by a COMMAND() description, and
--introspect-cli is added. An explicit "Lookup Keys" option group is added
so that the section heading stays the same.
The custom help() is replaced by a COMMAND() description, and
--introspect-cli is added. An explicit "Commands" option group is added
so that the section heading stays the same. The synopsis is now the same
as for systemd-sysusers, i.e. the "commands" are the options listed in the
Commands section. --help now goes through the pager, like other commands
with --no-pager.