Commit Graph
91279 Commits
Author SHA1 Message Date
Yu Watanabe 5e2d9c6ed1 man: document systemd-sysctl --save= and --revert= 2026-08-21 00:50:02 +09:00
Yu Watanabe 80e346af74 test: add test cases for systemd-sysctl --save= and --revert= 2026-08-21 00:48:25 +09:00
Yu Watanabe fb19c2ffa2 sysctl: introduce --revert= option to remove runtime sysctl config
This may be useful for removing files created by the --save= option.
2026-08-21 00:46:17 +09:00
Yu Watanabe 45bd015441 sysctl: add --save= option to save loaded settings
This may be useful for saving sysctl settings provided on the command line,
via standard input, or with --inline.
2026-08-21 00:45:13 +09:00
Yu Watanabe 1c223728cf sysctl: skip leading whitespaces and ignore arguments start with '#' when --inline 2026-08-21 00:40:53 +09:00
Yu Watanabe 5c76cb0e27 sysctl: --inline requires positional arguments 2026-08-21 00:40:53 +09:00
Chris Coulson 768b6f21ec report: Add a TPM2 signing backend
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.
2026-08-20 15:30:20 +02:00
Stephanie Wilde-Hobbs ac80a8f4f3 hwdb: label Lenovo ThinkPad X1 Tablet Gen 3 trackpoint as pointing stick
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.
2026-08-20 04:53:28 +09:00
Andrew Dunn 8e3d6dc535 crypto-util: zero-pad ECC point coordinates to curve width
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.
2026-08-20 04:06:04 +09:00
r-vdp dc4108c43c network: re-solicit RAs when the link MAC changes
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.
2026-08-20 04:05:12 +09:00
Stephanie Wilde-Hobbs fc08ae472c hwdb: mark Lenovo ThinkPad X1 Tablet Gen 3 touchpad as internal
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.
2026-08-20 04:04:16 +09:00
Yu Watanabe e67956f31c Another batch of conversions to COMMAND and additions of --introspect-cli (#43436)
This is another batch of straightforward conversions. I wanted to do
udevadm here too, but it requires some design work.
2026-08-20 01:41:53 +09:00
Yu Watanabe d971596a02 verbs: fix typo
Found by Fossies.

Follow-up for 7ea090f41b.
2026-08-19 22:58:22 +09:00
Yu Watanabe 6e652b53c6 man: expand documentation for systemd-sysctl --verify
Follow-up for 0b9ac2e675.
2026-08-19 11:01:40 +02:00
Zbigniew Jędrzejewski-Szmek ebd9040b30 Fix memleak and double free in varlink methods (#43431) 2026-08-19 10:58:40 +02:00
Zbigniew Jędrzejewski-Szmek 963b2323ef report-sign-tsm: convert to VERB_COMMAND and add --introspect-cli
The custom help() is replaced by a COMMAND() description, and
--introspect-cli is added. The abstract is now wrapped automatically.
2026-08-19 08:21:30 +02:00
Zbigniew Jędrzejewski-Szmek 8d8cf2cf1a report-sign-plain: convert to VERB_COMMAND and add --introspect-cli
The custom help() is replaced by a COMMAND() description, and
--introspect-cli is added.
2026-08-19 08:21:30 +02:00
Zbigniew Jędrzejewski-Szmek 578e5c1b38 report-files: convert to VERB_COMMAND and add --introspect-cli
The custom help() is replaced by a COMMAND() description, and
--introspect-cli is added.
2026-08-19 08:21:29 +02:00
Zbigniew Jędrzejewski-Szmek 8f42146976 report-cgroup: convert to VERB_COMMAND and add --introspect-cli
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.
2026-08-19 08:21:29 +02:00
Zbigniew Jędrzejewski-Szmek 45966bcf8e report-basic: convert to VERB_COMMAND and add --introspect-cli
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.
2026-08-19 08:21:29 +02:00
Zbigniew Jędrzejewski-Szmek c226b876c0 pull: convert to VERB_COMMAND and add --introspect-cli
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.
2026-08-19 08:21:29 +02:00
Zbigniew Jędrzejewski-Szmek 9832927a08 import-fs: convert to VERB_COMMAND and add --introspect-cli
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.
2026-08-19 08:21:29 +02:00
Zbigniew Jędrzejewski-Szmek 3e61b718a5 import: convert to VERB_COMMAND and add --introspect-cli
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.
2026-08-19 08:21:29 +02:00
Zbigniew Jędrzejewski-Szmek 3a45066bce export: convert to VERB_COMMAND and add --introspect-cli
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.
2026-08-19 08:21:29 +02:00
Zbigniew Jędrzejewski-Szmek df618014a5 udev/scsi_id: convert to VERB_COMMAND and add --introspect-cli
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.
2026-08-19 08:21:29 +02:00
Zbigniew Jędrzejewski-Szmek 9cd507ed5b udev/v4l_id: convert to VERB_COMMAND and add --introspect-cli
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.
2026-08-19 08:21:29 +02:00
Zbigniew Jędrzejewski-Szmek 7038981d86 udev/mtd_probe: convert to VERB_COMMAND and add --introspect-cli
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.
2026-08-19 08:21:29 +02:00
Zbigniew Jędrzejewski-Szmek 5b745242c5 udev/fido_id: convert to VERB_COMMAND and add --introspect-cli
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.
2026-08-19 08:21:29 +02:00
Zbigniew Jędrzejewski-Szmek c90fafdd04 udev/dmi_memory_id: convert to VERB_COMMAND and add --introspect-cli
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.
2026-08-18 23:04:06 +02:00
Zbigniew Jędrzejewski-Szmek cc139a73b8 udev/cdrom_id: convert to VERB_COMMAND and add --introspect-cli
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.
2026-08-18 23:04:06 +02:00
Zbigniew Jędrzejewski-Szmek 43c9d274e9 udev/ata_id: convert to VERB_COMMAND and add --introspect-cli
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.
2026-08-18 23:04:06 +02:00
Zbigniew Jędrzejewski-Szmek c62bfac025 udev/iocost: convert to VERB_COMMAND and add --introspect-cli
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.
2026-08-18 23:04:06 +02:00
Yu Watanabe 4430adbd76 sysinstall: refuse multiple requests
Otherwise, that triggers memory leak and double free.
2026-08-19 03:45:14 +09:00
Yu Watanabe 515121f7b3 resolve: refuse multiple requests
Otherwise, that triggers memory leak and double free.
2026-08-19 03:45:11 +09:00
Yu Watanabe b52f89e53b repart: refuse multiple requests with subscribe mode
Otherwise, that triggers memory leak and double free.
2026-08-19 03:29:26 +09:00
Yu Watanabe 112e4fe00a mute-console: refuse multiple requests per connection
Otherwise, that triggers memory leak and multiple free on the same
object.
2026-08-19 03:29:26 +09:00
Yu Watanabe 54253d2a9c journalctl: do not accept multiple requests to get journal entries with following mode
Otherwise, the previously attached FollowState object will be leaked,
and the latest object will be freed multiple times.
2026-08-19 03:29:26 +09:00
Yu Watanabe c2806a8c1d journal: do not accept multiple requests to sync journal per varlink connection
Otherwise, previously allocated SyncReq object will be leaked,
and the latest SyncReq object will be freed multiple times.
2026-08-19 03:29:26 +09:00
Yu Watanabe 0566d7aa35 journal: coding style fix 2026-08-19 03:29:26 +09:00
Yu Watanabe a7ba64356a journal: update comments
The Manager object was renamed from Server.
Maybe we forget to update these comments at that time.
2026-08-19 03:29:17 +09:00
dongshengyuan 3e55065ccf resolvectl: merge JSON error fields
Follow-up for: 32b3aabfe7
2026-08-19 02:31:39 +09:00
Daan De Meyer 57c4a1ea32 vmspawn: terminate the child processes before removing the runtime directory
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.
2026-08-19 02:30:42 +09:00
dongshengyuan 844c44a0d4 timedated: roll back state on config write failure
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
2026-08-19 02:29:39 +09:00
dongshengyuan 31ef154f15 core: fix integer truncation checks
Use explicit bounds checks for size_t and long conversions
so compilers cannot optimize away round-trip cast checks.

Follow-up for 78238fd7c9.
2026-08-19 02:28:19 +09:00
Zbigniew Jędrzejewski-Szmek f969973b90 Another batch of conversions to COMMAND and additions of --introspect-cli (#43428) 2026-08-18 18:32:55 +02:00
Zbigniew Jędrzejewski-Szmek 92a97a2b9d dissect: describe the mount.ddi helper interface
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.
2026-08-18 16:54:09 +02:00
Zbigniew Jędrzejewski-Szmek da26e6f744 run0: add --no-pager
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.
2026-08-18 16:54:09 +02:00
Zbigniew Jędrzejewski-Szmek 38d854b114 vpick: convert to VERB_COMMAND and add --introspect-cli
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.
2026-08-18 16:54:09 +02:00
Zbigniew Jędrzejewski-Szmek b4199e7376 vmspawn: convert to VERB_COMMAND and add --introspect-cli
The custom help() is replaced by a COMMAND() description, and
--introspect-cli is added.
2026-08-18 16:54:09 +02:00
Zbigniew Jędrzejewski-Szmek 60dee66134 tmpfiles: convert to VERB_COMMAND and add --introspect-cli
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.
2026-08-18 16:54:09 +02:00