Commit Graph
91078 Commits
Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek 94af9a8b40 verbs: wrap abstract too
So far there's only one multi-line abstract. But as pointed out in the
review, it's silly to handle footer but not the abstract.

help_abstract() is not reused because it only works with one-line
abstracts. (It always prints an empty line to separate paragraphs.)
So the formatting is done anew in print_wrapped(). I think this is OK,
since it's all very simple. After everything has been converted to
COMMAND() and its helpers, help_abstract() and the sister functions will
become unused and can be dropped then.
2026-08-13 13:52:35 +02:00
Zbigniew Jędrzejewski-Szmek 7ea090f41b verbs: wrap the help footer at print time
The footer is now wrapped to min($COLUMNS, 80) when it is printed, so
CommandDescription footers do not need to be hard-wrapped in the source,
and make use of the available terminal width. Newlines embedded in the
text are preserved and each line is wrapped independently, so explicit
line breaks can still be used where needed, e.g. before the example
command line in varlinkctl.

The text is wrapped at max of 80 columns to avoid very wrong lines on
wide terminals. Such lines are hard to read.

A new helper is added for this. We already have format_strv_width in
format-table, but it requires a strv, so we'd need to conver the data,
and returns a formatted string, which we'd need to print ourselves. So
overall, it seems better to add a dedicated helper.
2026-08-13 13:48:24 +02:00
Zbigniew Jędrzejewski-Szmek 7670c20c6e verbs: add PagerFlags pointer to all CommandDescription's
Before this series, many help() functions opened the pager. This got lost
in the translation. Starting the pager requires access to arg_pager_flags.
While we could pipe this through in case when command_print_help() is
called directly, but this hard in the case when verb_help_auto() or
VERB_COMMON_HELP_AUTO/VERB_COMMON_HELP_AUTO_HIDDEN are used. Let's instead
extend the (const static) CommandDescription structure with a pointer to
the arg_pager_flags variable. This restores the pager functionality in a
uniform fashion with a one-line change in the individual binaries.
2026-08-13 13:46:08 +02:00
Zbigniew Jędrzejewski-Szmek 8a14181f55 resolvectl: separate systemd-resolve in introspection data
Previously, the systemd-resolve compat alias was described in the same
CommandDescription structure and resolvectl. But they have different
option sets, so this doesn't really work. The alias is deprecated, so
describe it as such in the abstract, but give it a separate entry.

$ build/resolvectl --introspect-cli
{
  "mediaType": "application/vnd.io.systemd.cli-introspection-0",
  "commands": [
    {
      "names": [ "resolvconf" ],
      "abstract": [
        "Register DNS server and domain configuration with systemd-resolved."
      ],
      ...
    },
    {
      "names": [ "resolvectl" ],
      "abstract": [
        "Send control commands to the network name resolution manager, or\nresolve domain names, IPv4 and IPv6 addresses, DNS records, and services."
      ],
      ...
    },
    {
      "names": [ "systemd-resolve" ],
      "abstract": [
        "Send control commands to the network name resolution manager, or\nresolve domain names, IPv4 and IPv6 addresses, DNS records, and services.\n\nThis command is deprecated. Use resolvectl.1 instead."
      ],
      ...
    }
  ]
}
2026-08-13 13:23:05 +02:00
Zbigniew Jędrzejewski-Szmek 1a54ce154c various: add --introspect-cli 2026-08-13 13:23:05 +02:00
Zbigniew Jędrzejewski-Szmek 6c83ea9eda Add infrastracture to introspect commandline binaries
This adds the helpers to add a hidden --introspect-cli option which
prints a machine-readable description of the program's interface and
exits. Applicable to any programs that have been converted to
VERB_COMMAND().

The output format follows the draft CLI-Introspection Specification
(https://github.com/behrmann/uapi-specifications/blob/cli-introspection/specs/cli_introspection.md):
a single JSON document with a fixed "mediaType" string and an array of
command objects, one per VERB_COMMAND() defined in the binary, so multicall
binaries are described in full. Options are taken from the command's option
namespace, so e.g. systemd-dissect does not list the mount.ddi mount-helper
options.

$ build/systemd-id128 --json=pretty --introspect-cli
{
        "mediaType" : "application/vnd.io.systemd.cli-introspection-0",
        "commands" : [
                {
                        "names" : [
                                "systemd-id128"
                        ],
                        "version" : "262~devel",
                        "features" : [
                                "-PAM",
                                ...
                        ],
                        "abstract" : [
                                "Generate and print 128-bit identifiers."
                        ],
                        "options" : [
                                {
                                        "names" : [
                                                "-h",
                                                "--help"
                                        ],
                                        "argument" : "no_argument",
                                        "help" : "Show this help"
                                },
                                ...
                        ],
                        "verbs" : [
                                {
                                        "names" : [
                                                "new"
                                        ],
                                        "abstract" : [
                                                "Generate a new ID"
                                        ],
                                        "maxArguments" : 1
                                },
                                ...
                        ]
                }
        ]
}

$ build/systemd-id128 --introspect-cli | jq '.commands[0].options[].names[-1]'
"--help"
"--version"
"--no-pager"
"--no-legend"
"--json"
"-j"
"--pretty"
"--value"
"--app-specific"
"--uuid"
"--introspect-cli"
2026-08-13 13:23:05 +02:00
Zbigniew Jędrzejewski-Szmek adbec875af systemd-notify: convert to VERB_COMMAND 2026-08-13 13:23:05 +02:00
Zbigniew Jędrzejewski-Szmek 816ce4eeee notify: do not print full help output on error
Printing a wall of text is obnoxious. Just tell the user what the
problem was.
2026-08-13 13:23:05 +02:00
Zbigniew Jędrzejewski-Szmek 66246c98b5 systemd-dissect: convert to VERB_COMMAND 2026-08-13 13:23:05 +02:00
Zbigniew Jędrzejewski-Szmek df03655bc5 resolvectl: convert to VERB_COMMAND 2026-08-13 13:23:05 +02:00
Zbigniew Jędrzejewski-Szmek 580489eeec resolvectl: drop --help for systemd-resolve
The rename was done in v239. We generally don't document obsolete
interfaces, so let's just drop the (very nice) --help that we have here.
2026-08-13 13:23:05 +02:00
Zbigniew Jędrzejewski-Szmek a60c999d5b systemd-backlight: convert to VERB_COMMAND 2026-08-13 13:23:05 +02:00
Zbigniew Jędrzejewski-Szmek c9cd66ee3a backlight: add parse_argv() 2026-08-13 13:23:05 +02:00
Zbigniew Jędrzejewski-Szmek 92462517a1 systemd-ask-password: convert to VERB_COMMAND 2026-08-13 13:23:05 +02:00
Zbigniew Jędrzejewski-Szmek 24acd23d8d systemd-analyze: convert to VERB_COMMAND 2026-08-13 13:23:05 +02:00
Zbigniew Jędrzejewski-Szmek 37e3568236 systemd-ac-power: convert to VERB_COMMAND 2026-08-13 13:23:05 +02:00
Zbigniew Jędrzejewski-Szmek edb15285d0 systemd-veritysetup: convert to VERB_COMMAND
The --help output now shows -h/--help.

"verity protected" is changed to the more correct spelling of
"verity-protected".
2026-08-13 13:23:05 +02:00
Zbigniew Jędrzejewski-Szmek c81b5d36b9 veritysetup: add the usual parse_argv() function
More options will be added later, so let's use the usual
setup.
2026-08-13 13:23:05 +02:00
Zbigniew Jędrzejewski-Szmek d94e88fe14 varlinkctl: convert to VERB_COMMAND
help verb is moved to the end as in most other commands.
2026-08-13 13:23:05 +02:00
Zbigniew Jędrzejewski-Szmek 6566264405 homectl: convert to VERB_COMMAND 2026-08-13 13:23:05 +02:00
Zbigniew Jędrzejewski-Szmek e256153186 verbs: add flags and allow verbs&options tables to not be synchronized 2026-08-13 13:23:05 +02:00
Zbigniew Jędrzejewski-Szmek 7e2ef99cfb timedatectl: convert to VERB_COMMAND 2026-08-13 13:23:05 +02:00
Zbigniew Jędrzejewski-Szmek 0059c3f5f2 verbs: introduce VERB_COMMON_HELP_AUTO{,_HIDDEN} 2026-08-13 13:23:04 +02:00
Zbigniew Jędrzejewski-Szmek 0ebe40080e id128: convert to VERB_COMMAND 2026-08-13 13:23:04 +02:00
Zbigniew Jędrzejewski-Szmek 8616e54872 verbs: add "program header" and generate all help from data
We add a CommandDescription that contains basic info about the program:
- names (the main name and deprecated aliases)
- abstract, man page list, footer
This gets stored as a fake verb entry through VERB_COMMAND macro.

We can then generate the full help for the program from the verbs
and option arrays.

The formatting of man page links is changed from the form used
previously: the section is printed as ".N" instead of "(N)". This
for has the following advantages:
- the form with parenthesis looks like a function call, so e.g. close(1)
  is both a valid call and a man page link.
- the new form can be automatically selected with a double click in the
  typical terminal configurations, while '(' would usually terminate the
  selection area.
- parentheses are special in shell syntax, so even the user manages to
  successfully select and paste them, they still have to add quoting or
  escaping on the command line.
- the new form is shorter
- it looks better
2026-08-13 13:23:04 +02:00
Zbigniew Jędrzejewski-Szmek 4d620b49f5 shared/format-table: add helper to sync widths of a table array 2026-08-13 13:23:04 +02:00
Paul Meyer d66923ea07 test: fix race in TEST-07-PID1 multi-unit transaction subtest
Test failed with the following:

TEST-07-PID1.sh[20020]: + systemctl stop issue8102-nop-dep.service
TEST-07-PID1.sh[20409]: ++ systemctl show -P ActiveState issue8102-nop-dep.service
TEST-07-PID1.sh[20020]: + [[ failed == inactive ]]

systemctl start only waits for the jobs of the units named on the
command line, so the start job pulled in for issue8102-nop-dep.service
via Wants= was not waited for. When the following stop landed while its
ExecStart= was still running, the process was SIGTERMed, and since
Type=oneshot does not treat termination by signal as a clean exit, the
unit ended up failed instead of inactive:

issue8102-nop-dep.service: Changed start -> stop-sigterm
issue8102-nop-dep.service: Main process exited, code=killed, status=15/TERM
issue8102-nop-dep.service: Failed with result 'signal'.

Start both units explicitly so both jobs are waited for.

Signed-off-by: Paul Meyer <katexochen0@gmail.com>
2026-08-13 09:58:53 +01:00
Armaan Sandhu 32ac7af788 strv: treat newlines as hard line breaks in strv_rebreak_lines()
A newline embedded in an input entry only reset the width counter and the
leading-whitespace state, but the text collected before it was never flushed.
If nothing but whitespace followed the newline, the end-of-line path then saw
that we were still in the leading whitespace and emitted an empty line,
dropping everything before the newline: "foo\n" turned into "".

Newlines also didn't start a new output entry, so returned entries could
contain newlines and be wider than the requested width, even though callers
expect one output entry per output line.

Flush the collected line at the newline instead, reusing the same logic as at
the end of the string, and treat a trailing newline as terminating the last
line rather than adding an empty one.
2026-08-13 07:11:49 +09:00
Armaan Sandhu 5dc41f8283 options: reject an empty long option name
An argument of the form "--=VALUE" leaves an empty option name, which
startswith() treats as a prefix of every defined option. Depending on how many
long options a namespace defines that yields either an ambiguity error listing
every option, or, with exactly one option defined, a unique partial match that
silently parses "--=VALUE" as that option.
2026-08-13 07:11:37 +09:00
Yu Watanabe 3ae53ab8f6 analyze: allow --json= for the chid, blame and identify-tpm2 verbs (#43366)
verb_chid(), verb_blame() and verb_identify_tpm2() all render their
output via table_print_with_pager() with arg_json_format_flags, so JSON
output has been implemented for them since each verb was introduced.
None of them was ever added to the verb allowlist
that gates --json=, so e.g. systemd-analyze chid --json=pretty failed
with:

Option --json= is only supported for security, inspect-elf,
dlopen-metadata, ...

This adds them to the allowlist and the error message. After a sweep of
src/analyze/ for arg_json_format_flags, these are the only remaining
verbs that render through it but were not allowlisted.

has-tpm2 is deliberately not included: verb_has_tpm2() defers to
verb_has_tpm2_generic(), which writes plain text via printf() and has no
JSON support, so accepting --json= there would silently ignore it. The
table_print_with_pager() call in analyze-has-tpm2.c
belongs to verb_identify_tpm2(), which is what got allowlisted instead.

The chid gap went unnoticed because its TEST-65-ANALYZE coverage is
guarded behind a check for SMBIOS board_vendor and a non-container
environment, so it only runs on bare-metal/VM runners.
2026-08-13 00:06:07 +09:00
Luca Boccassi aec25f2770 Two HWDB fixes (#43367) 2026-08-12 15:12:58 +01:00
David Tardon 1d75afb798 hwdb: fix modalias
This line matches only if svn is the first field, but DMI modaliases
normally begin with BIOS fields such as bvn/bvr/bd. Use a wildcard like
other similar entries in the file.

Follow-up-for: 0aaea4b376
2026-08-12 13:30:36 +02:00
David Tardon ef3a8760cc hwdb: fix modalias
I'm not sure if these leading zeros matter or not, but the description
at the top of the file clearly says that the numbers are 4-digit. The
author of this entry also mentions evdev:input:b0003v1020p0501* in the
PR that added it.

Follow-up-for: 4ae4470ad9
2026-08-12 12:57:42 +02:00
Ivan Kruglov 46a91a1867 test: cover --json= for the blame and identify-tpm2 verbs
Both verbs render through arg_json_format_flags but --json= was rejected for
them until the previous commit, and nothing in TEST-65-ANALYZE exercised it.
Add coverage in line with the other JSON-capable verbs.

identify-tpm2 is only invoked when has-tpm2 reports full support, as it
fails with EOPNOTSUPP when built without TPM2 support.
2026-08-12 03:54:33 -07:00
Ivan Kruglov b3f76af401 shell-completion: offer --json= for the standalone verbs that support it
Several verbs in the STANDALONE bucket accept --json=, but that bucket only
offers --help --version --system --user --global --no-pager, so completion
never suggested the option for them.

Split those verbs out into a new STANDALONE_JSON bucket that additionally
offers --json=off/pretty/short. The verbs are moved rather than copied, as
${VERBS[*]} is used to complete the verb list itself.
2026-08-12 03:54:10 -07:00
Ivan Kruglov 9b16161f34 analyze: allow --json= for the chid, blame and identify-tpm2 verbs
verb_chid(), verb_blame() and verb_identify_tpm2() all render their output
via table_print_with_pager() with arg_json_format_flags, so JSON output has
been implemented for them since they were introduced. However, none of them
was ever added to the verb allowlist that gates --json=, so e.g.
"systemd-analyze chid --json=pretty" failed with:

Option --json= is only supported for security, inspect-elf, ...

Add them to the allowlist (and the error message) so the option is accepted.
These are the only remaining verbs that render through arg_json_format_flags
but were not allowlisted.

Note that has-tpm2 is deliberately not included: verb_has_tpm2() defers to
verb_has_tpm2_generic(), which writes plain text via printf() and has no JSON
support, so accepting --json= there would silently ignore it.

This went unnoticed for chid because the TEST-65-ANALYZE coverage for it is
guarded behind a check for SMBIOS board_vendor and a non-container
environment, so it only runs on bare-metal/VM runners.
2026-08-12 03:53:42 -07:00
dongshengyuan 628e8304cc resolved: notice route-only domain updates
SetLinkDomains() tracks whether the configured search domain list changed
so it can skip redundant persistence. The route_only flag is part of the
D-Bus API and is persisted as a ~ prefix, but flipping an existing domain
between search and route-only only updated in-memory state and left
changed false. The method then skipped link_save_user() and
manager_write_resolv_conf(), leaving stale state until restart.

Reproduced on Ubuntu with systemd 259:

  sudo resolvectl domain enp1s0 route-only-repro.test
  sudo resolvectl domain enp1s0 '~route-only-repro.test'
  resolvectl domain enp1s0
  grep '^DOMAINS=' /run/systemd/resolve/netif/$(cat /sys/class/net/enp1s0/ifindex)
  grep -H route-only-repro.test /run/systemd/resolve/*.conf

Before, resolvectl showed ~route-only-repro.test, but the persisted state
file still showed DOMAINS=route-only-repro.test, and the generated
resolv.conf files still contained search route-only-repro.test.

After this change, the state file is updated to
DOMAINS=~route-only-repro.test and the generated resolv.conf files are
refreshed so the route-only domain is not emitted as a search domain.

Follow-up for: cbf23f3853
2026-08-12 18:51:34 +09:00
Timon de Groot 40315add91 hwdb: add Blue Microphones Yeti X (#43363)
This microphone has vendor specific HID controls to control gain,
output, monitoring levels, polar patterns, etc.

Naming is completely based on names reported by the USB device itself
(`manufacturer` and `product`).

Information about this microphone:
- https://micpedia.com/microphone/blue-yeti-x/
- https://www.logitechg.com/en-us/shop/p/yeti-x-professional-microphone
2026-08-12 06:57:38 +09:00
zhaoshuang abffa868a8 virt: detect Alibaba Cloud ECS as KVM
Alibaba Cloud ECS instances expose "Alibaba Cloud ECS" in DMI
product_name/bios_vendor and "Alibaba Cloud" in sys_vendor. None of
these match dmi_vendor_table[], so systemd-detect-virt --vm reports
"none" on these machines, even though they run on a KVM-based
hypervisor. This is especially visible on ARM64 instances, where the
CPUID fallback does not exist (x86 only) and /proc/device-tree is
not populated.

Add "Alibaba Cloud ECS" to dmi_vendor_table[], mapping to
VIRTUALIZATION_KVM. The narrower prefix avoids matching the bare
"Alibaba Cloud" sys_vendor value, reducing the false-positive
surface for Alibaba's bare-metal (X-Dragon) instances compared to
the original broader prefix. bios_vendor also carries the same
string on ECS VMs though, so the protection is not complete —
fully resolving the VM-vs-bare-metal ambiguity would need the
SMBIOS BIOS-Characteristics bit check that the Amazon EC2 entry
uses.

The existing "back to DMI" fallback path in detect_vm() reports
"kvm" on both x86 and ARM64.
2026-08-12 04:12:19 +09:00
dongshengyuan e98c68104b core: do not chown fd-passed TTYs
When stdio is passed as file descriptors, the provider of those
descriptors remains responsible for their ownership and access mode.

This keeps run0 in a pipeline from changing the caller's TTY ownership
to the target user, which can otherwise break later terminal access from
the original user.

Fixes #43336
2026-08-12 03:11:02 +09:00
dongshengyuan e8454eb14c detect-virt: continue parsing after --cvm
--cvm is a mode switch, so it must not stop option parsing.
Keep parsing after it to honor later options and validate arguments.

Before: --cvm --quiet printed none; --cvm unexpected-argument printed none.
After: --cvm --quiet prints nothing; extra arguments are rejected.

Follow-up for: 5e0c61f64d
2026-08-12 03:02:33 +09:00
dongshengyuan f40aa8ea1c vpick: terminate tries output with newline
tries should be line-oriented like the other --print= modes.
Terminate its counter output with a newline to avoid glued CLI output.

Before: output bytes were 2b 32 2d 33.
After: output bytes are 2b 32 2d 33 0a.

Follow-up for: 9e61ed1115
2026-08-12 03:02:33 +09:00
Yu Watanabe 4443d0ec16 Fix error paths for pcrextend_pcr_now and pkcs7_extract_signers (#43357)
- pcrextend: Fix use-after-free/double-free error in pcrextend_pcr_now

  With SignInitrdPCRs=disabled in mkosi the TPM/PCR services are broken
which triggers the error path in the varlink call which means that we
get parameters set in the response. The wrong ownership assumption when
looking at the reply with _cleanup_ set caused a memory corruption that
surfaced in systemd-sysext with an ABRT.
This is a common mistake done with the API, fix it by not setting
_cleanup_(sd_json_variant_unrefp).

- pkcs7: Correct error handling for pkcs7_extract_signers

  The lack of error handling for sym_i2d_X509_NAME/sym_i2d_ASN1_INTEGER
means that we get a NULL iovec that will cause an assertion failure
later. The use of regular free for OpenSSL is probably okay but since
the allocator can differ, one should use OPENSSL_free.
Add error handling and do an explicit copy instead of ownership transfer
between possibly different allocators.
2026-08-12 02:48:51 +09:00
Luca Boccassi 8271442983 test: drop forgotten set +e (#43359)
This was introduced all the way back in 2019 where this particular test
case was the last one in the file, so it worked as intended.
Unfortunately, since then we added new tests after this one, which means
this particular `set +e` masked fails in any of them (except for
assert_*() calls, which call exit on fail).
2026-08-11 17:40:25 +01:00
Frantisek Sumsal ed0727fecd test: sync the journal before checking it for ordering cycle messages
Otherwise we might get an empty match:

TEST-03-JOBS.sh[100]: + IDS_FILE=/tmp/TEST-03-JOBS-CYCLE-IDS-30241
TEST-03-JOBS.sh[314]: + varlinkctl call /run/systemd/io.systemd.Manager io.systemd.Manager.Describe '{}'
TEST-03-JOBS.sh[315]: + jq .runtime.TransactionsWithOrderingCycle
TEST-03-JOBS.sh[316]: ++ jq length /tmp/TEST-03-JOBS-CYCLE-IDS-30241
TEST-03-JOBS.sh[100]: + [[ 20 -ge 20 ]]
TEST-03-JOBS.sh[100]: + for i in {0..19}
TEST-03-JOBS.sh[317]: ++ jq -r '.[0]' /tmp/TEST-03-JOBS-CYCLE-IDS-30241
TEST-03-JOBS.sh[100]: + journalctl -b TRANSACTION_ID=48 --grep 'cycle starting with'
TEST-03-JOBS.sh[318]: -- No entries --
[FAILED] Failed to start TEST-03-JOBS.service - TEST-03-JOBS.
[  !!  ] Exiting: unit TEST-03-JOBS.service failed

Even though the message was properly emitted:

$ journalctl --file TEST-03-JOBS-1.journal -b TRANSACTION_ID=48 --grep 'cycle starting with'
Aug 11 14:46:15 H systemd[1]: [🡕] transaction-cycle17.service: Unable to break cycle starting with transaction-cycle17.service/start
2026-08-11 16:12:42 +02:00
Frantisek Sumsal 143c284567 test: drop forgotten set +e
This was introduced all the way back in 2019 where this particular test
case was the last one in the file, so it worked as intended.
Unfortunately, since then we added new tests after this one, which means
this particular `set +e` masked fails in any of them (except for
assert_*() calls, which call exit on fail).
2026-08-11 16:12:42 +02:00
Frantisek Sumsal 2c4e86c290 test: fix & enhance test for RestartMode=
Stay `set +e` in the test masked that this test has apparently never
worked in the first place: when a unit is killed with a signal, any
bound unit is stopped retroactively via
retroactively_stop_dependencies() but it's not restarted again, as the
restart for the bound unit is queued as TRY_RESTART in a following
transaction - but at this point the bound unit is already inactive, so
the TRY_RESTART job collapses into a NOP.

Let's account for this and also add a couple of test cases for
RestartMode= with an explicit restart, which should trigger the bound
unit as well (assuming it's active).

Follow-up for 9b42c58a2b.
2026-08-11 16:11:25 +02:00
Christian Brauner 0b2d1203cb bpf-restrict-fsaccess: allow execution from overlayfs on signed dm-verity (#43223)
RestrictFileSystemAccess= currently denies execution from any overlayfs
  mount, even when every layer sits on a signed dm-verity device. The
enforcement hooks compare file->f_inode->i_sb->s_dev against the map of
  trusted devices and for a file on an overlay that's the overlay's own
  anonymous device, never the backing block device. So the fairly common
  image based setup where a signed DDI is the lower layer and a writable
  upper is stacked on top of it is out.

Kernel v7.2 grew the bpf_real_data_inode() kfunc which resolves a file
to
the inode hosting its data. Use it from the two enforcement hooks that
get
to see the union-level file. Execution through such an overlay then
works
  while anything whose data lives in an untrusted upper layer is still
  denied.

  All of it is gated on kernel support. The kfunc is a __weak __ksym and
every call sits behind a const volatile .rodata flag that PID1 only sets
when the kernel BTF advertises the function, so the object still loads
on
older kernels and keeps denying union filesystems exactly like before.
If
loading with resolution enabled fails anyway the loader retries with the
  flag off. A setup failure here is fatal to PID1 startup and I'd rather
  degrade than not boot.

  Two things worth pointing out. The mmap_file hook matters more than it
  looks like. binfmt_elf maps the PT_INTERP interpreter via vm_mmap() so
  ld.so is only ever checked there and never by bprm_check_security. And
  file_mprotect deliberately doesn't use the kfunc. It runs under
  mmap_write_lock where sleeping in d_real() would invert the documented
i_rwsem -> mmap_lock order, and it doesn't need it anyway since
ovl_mmap()
  has already installed the backing file into vma->vm_file by then.
  
   Known limitations:

    * With metacopy=on an untrusted upper layer can still own a trusted
      binary's mode, ownership and setuid bits since the resolution only
follows the data. Documented in the man page, just don't build that.

    * composefs with a separate data directory isn't covered. That needs
fs-verity digests and bpf_get_fsverity_digest() takes a struct file
      and gets the overlay inode, so it doesn't compose with this today.

    * erofs page cache sharing is denied. The inode comes from a pseudo
      filesystem whose s_dev is never in the verity map.

    * Multi-device filesystems like btrfs stay unsupported, as before.
    
    Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
2026-08-11 14:31:25 +02:00
Kai Lüke 76a6dc6dc0 pcrextend: Fix use-after-free/double-free error in pcrextend_pcr_now
With SignInitrdPCRs=disabled in mkosi the TPM/PCR services are broken
which triggers the error path in the varlink call which means that we
get parameters set in the response. The wrong ownership assumption when
looking at the reply with _cleanup_ set caused a memory corruption that
surfaced in systemd-sysext with an ABRT.
This is a common mistake done with the API, fix it by not setting
_cleanup_(sd_json_variant_unrefp).
2026-08-11 20:35:57 +09:00
Kai Lüke a257de2688 pkcs7: Correct error handling for pkcs7_extract_signers
The lack of error handling for sym_i2d_X509_NAME/sym_i2d_ASN1_INTEGER
means that we get a NULL iovec that will cause an assertion failure
later. The use of regular free for OpenSSL is probably okay but since
the allocator can differ, one should use OPENSSL_free.
Add error handling and do an explicit copy instead of ownership transfer
between possibly different allocators.
2026-08-11 20:31:00 +09:00