Commit Graph
89045 Commits
Author SHA1 Message Date
TristanInSec 9b21738498 sd-bus: add depth limit to message_skip_fields() to prevent stack overflow
message_skip_fields() recurses for each nested variant ('v') type in
D-Bus message header fields. A crafted message with deeply nested
variants (e.g., a variant containing a variant containing a variant...)
causes unbounded stack growth, leading to stack overflow and crash.

Add a depth parameter that increments on each recursive call and
rejects messages exceeding BUS_CONTAINER_DEPTH with -EBADMSG. This
matches the existing depth limits enforced elsewhere in the sd-bus
message processing (e.g., bus_message_enter_container).
2026-05-19 17:33:06 -04:00
Ivan Kruglov 6080d1cc42 errno-util: include -ENOENT in ERRNO_IS_XATTR_ABSENT()
The getxattr(2) man page only enumerates xattr-specific errors (ENODATA,
ENOTSUP, ERANGE, E2BIG, ...) in its own ERRORS section, but at the
bottom of that section notes that "the errors documented in stat(2) can
also be returned." stat(2) returns -ENOENT when a component of the path
does not exist, so any xattr lookup against a path can fail with -ENOENT
exactly the same way as -ENODATA — both mean "there is nothing here for
me to read." The previous definition of ERRNO_IS_NEG_XATTR_ABSENT()
reflected only the directly-enumerated errors and missed -ENOENT, so
callers that should semantically swallow "the xattr is absent" instead
bubbled -ENOENT up as a hard error.

The most visible consequence on real fleets has been systemd-journald
spamming dmesg with one line per dispatched log message whenever a
unit's cgroup directory cannot be found at the time
client_context_read_log_filter_patterns() is called — typically inside
containers whose journald observes clients whose unit cgroup is no
longer present in its view (cgroup-namespace boundary, unit teardown
race, transient sub-scope already collapsed back to its unit cgroup,
etc.). The same bug pattern lurks at every other cgroup-xattr callsite:
systemd-oomd reading user.oomd_avoid / user.oomd_omit / user.oomd_ooms
on cgroups it is concurrently killing; killall reading
user.survive_final_kill_signal during shutdown; cg_is_delegated() /
cg_has_coredump_receive() / cgroup_get_managed_oom_kill_last(); etc. For
these, "path is gone" is by construction the same answer as "xattr is
not set" — there is no way for the user to have attached an xattr to a
path that does not exist.

A quick survey of non-cgroup callers (src/portable/portable.c,
src/home/{homework-luks,user-record-util}.c,
src/random-seed/random-seed-tool.c, src/basic/os-util.c) confirms they
all operate on fds or on paths whose absence is already the desired
silent-skip outcome, so widening the macro to also fold in -ENOENT does
not change observable behavior at any other site.

Extend test-xattr-util's getxattr_at_malloc test with an explicit
non-existent-path lookup that asserts ERRNO_IS_NEG_XATTR_ABSENT() now
matches, alongside the pre-existing non-existent-xattr (-ENODATA) check.
2026-05-19 01:45:54 +09:00
Luca Boccassi 6fa5ebc506 dhcp-client: reject messages larger than the maximum UDP payload
dhcp_message_verify_header() only enforced a lower bound on the input
length, so dhcp_message_parse() happily accepted arbitrarily large
buffers. Such inputs could never have been received via UDP and would
later fail in dhcp_message_build() with -E2BIG once the parsed options'
combined size exceeds UDP_PAYLOAD_MAX_SIZE, which the fuzzer surfaced as
an assertion failure.

Reject inputs above UDP_PAYLOAD_MAX_SIZE up front, so the parse stage
mirrors what the wire format can actually carry.

Follow-up for 8c18bb6547

Fixes https://github.com/systemd/systemd/issues/42147

Co-developed-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-19 01:43:25 +09:00
Luca Boccassi cc9ab5af2d Chores for v261~rc1 (#42157) 2026-05-18 15:51:49 +01:00
Jörg Behrmann 5d5483156d NEWS: typo fixes 2026-05-18 14:28:05 +01:00
Zbigniew Jędrzejewski-Szmek be8b41eafa Fixes for claude review report (#42152) 2026-05-18 15:13:24 +02:00
Luca Boccassi 10fd9e4215 meson: bump library sonames for v261~rc1 2026-05-18 12:26:28 +01:00
Luca Boccassi 6f32c24a81 Update po files
ninja -C build systemd-update-po
2026-05-18 12:24:56 +01:00
Luca Boccassi 150d3398fc Update pot file
ninja -C build systemd-pot
2026-05-18 12:18:45 +01:00
Luca Boccassi 20a79f1222 Update syscall numbers
ninja -C build update-syscall-tables update-syscall-header
2026-05-18 12:18:04 +01:00
Luca Boccassi 3b3bec1abe Update hwdb autosuspend rules
ninja -C build update-hwdb-autosuspend
2026-05-18 12:17:23 +01:00
Luca Boccassi b6e160232c Update hwdb
ninja -C build update-hwdb
2026-05-18 12:16:44 +01:00
Luca Boccassi 06960c11b3 NEWS: add new items for v261~rc1 2026-05-18 11:52:25 +01:00
Zbigniew Jędrzejewski-Szmek 901179e3c7 sysupdate: fix noop assert
Reported by qarmin (Rafał Mikrut).
2026-05-18 12:45:56 +02:00
Zbigniew Jędrzejewski-Szmek 3a333585fe repart: fix bogus errno in error message and returned value
Reported by qarmin (Rafał Mikrut).
2026-05-18 12:45:56 +02:00
ishwarbb 133909c8f6 resolved: add configurable DNS cache size
Add CacheSize= option to [Resolve] section of resolved.conf to allow
configuring the maximum number of entries in the per-scope DNS cache.
The default remains 4096 entries. Setting this to 0 disables caching
(similar to Cache=no).

CacheSize= is only read when Cache=yes or Cache=no-negative. When
Cache=no, caching is fully disabled regardless of CacheSize=.

Changes:
- Add cache_size field to Manager struct
- Parse CacheSize= from resolved.conf via gperf
- Thread cache_size through dns_cache_put() and helper functions
- Replace hard-coded CACHE_MAX with the configurable cache_size
- When cache_size is 0 or Cache=no, flush cache and skip caching
- Add man page documentation for the new option
- Add unit tests for cache size enforcement

Co-developed-by: Claude <claude@anthropic.com>
2026-05-18 11:45:03 +01:00
Zbigniew Jędrzejewski-Szmek f0405bfdff nsresourced: fix typo
Reported by qarmin (Rafał Mikrut).
2026-05-18 12:44:45 +02:00
Zbigniew Jędrzejewski-Szmek 4f688e61c9 coredump: use a fixed string instead a scope-delimited compound literal
The compound literal (const char[]){'.','.','.'} has block scope
(C99 6.5.2.5p6). Once we leave the if and loop back, copy[1].iov_base
formally points into a destroyed object. Works on GCC/Clang in practice,
but is UB.

Let's do the easy thing and use a string.

Reported by qarmin (Rafał Mikrut).
2026-05-18 12:44:45 +02:00
Zbigniew Jędrzejewski-Szmek dd2d04179b tree-wide: stop using lambda assignment in Python code (#42145)
Follow-up for #40758.
2026-05-18 12:42:02 +02:00
Zbigniew Jędrzejewski-Szmek fd12cc9a52 core/manager: fix (theoretical) fd leak on invalid messages
We'd leak fds on early return. We are sending a message to ourself,
so it's unlikely to fail. But let's keep the logic correct.

Reported by qarmin (Rafał Mikrut).
2026-05-18 12:33:37 +02:00
Zbigniew Jędrzejewski-Szmek e305f552ec core/dbus-execute: propagate oom in property_get_cpu_affinity
The function already returns errors, so I'm not sure why we ignored
the error in the second call, potentially leaving variables unitialized.
It seems easiest to propagate the error.

Reported by qarmin (Rafał Mikrut).
2026-05-18 12:29:12 +02:00
Zbigniew Jędrzejewski-Szmek 92e0c920c7 basic/path-util: fix executable_is_good
Reported by qarmin (Rafał Mikrut).
2026-05-18 12:28:08 +02:00
Luca Boccassi a7a7b1af39 sd-json: add sd_json_parse_fd() + flags (#42136)
In particular in the recent LUO work we started to read JSON a lot from
fds, let's add some helpers to make that simpler.

No change in behaviour, just helpers to shorten code.
2026-05-18 11:16:48 +01:00
Lennart Poettering 914c41a774 test: add unit test for new sd-json functionality 2026-05-18 10:39:04 +01:00
Lennart Poettering 8c164074be man: add documentation for new sd-json features 2026-05-18 10:39:04 +01:00
Lennart Poettering cd6609499a tree-wide: make use of sd_json_parse_fd() where appropriate 2026-05-18 10:39:04 +01:00
Lennart Poettering 321df4885c sd-json: add sd_json_parse_fd() helper 2026-05-18 08:51:09 +02:00
Lennart Poettering 3d88e78927 homed: port one over one sd_json_parse_file() invocation to SD_JSON_PARSE_SEEK0 2026-05-18 08:51:09 +02:00
Lennart Poettering 584ee9ffe5 sd-json: add SD_JSON_PARSE_SEEK0 flag 2026-05-18 08:51:09 +02:00
Lennart Poettering c91ddaf1ee update TODO 2026-05-18 08:45:21 +02:00
Luca Boccassi 0096c83c5d boot: fix off-by-one truncation when reading efivars
'val' is allocated as 'size + 1', so the NUL terminator must be written
to 'size', rather than 'size - 1'.

Follow-up for fab8275646
2026-05-18 08:26:44 +02:00
Yu Watanabe e61ac7cd27 network/address: drop duplicated address earlier
network_adjust_dhcp_server() searches network->addresses_by_section,
hence without this change, an address entry picked by
network_adjust_dhcp_server() may be detached and freed by the cleanup
function.
2026-05-18 06:40:29 +02:00
Jörg Behrmann 76b5d77cdd ci/linter: stop ignoring lambda assignment lint 2026-05-18 09:43:36 +09:00
Jörg Behrmann b54d167934 test-network: make masq a proper function 2026-05-18 09:43:36 +09:00
Jörg Behrmann 9ea0b5f688 test-network: factor out common functions 2026-05-18 09:42:34 +09:00
Jörg Behrmann 475fb5e44f test-network: factor out common enum 2026-05-18 09:41:23 +09:00
Jörg Behrmann 7cf552e481 test-network: remove unused variable 2026-05-18 09:41:22 +09:00
Jörg Behrmann f4fcd5cfad hwdb/ids_parser: make text_eol a proper function 2026-05-18 09:41:22 +09:00
Jörg Behrmann c884b1410d ukify: factor out method for value parsing in ConfigItem 2026-05-18 09:41:22 +09:00
Yu Watanabe a0177d96dc dhcp-message: introduce dhcp_message_{payload,packet}_size() 2026-05-18 09:34:32 +09:00
Yu Watanabe 3e6c08b967 Introduce several more helper functions to read sysfs attributes and use them where applicable (#41065)
Let's not use sd_device_get_sysattr_value() unless the result is
sanitized, escaped, or filtered.
2026-05-18 07:26:44 +09:00
Yu Watanabe 9b768b5bf5 Apply "ruff format" and "ruff check --fix" for all python scripts (#40758) 2026-05-18 07:26:11 +09:00
RiskoZS 4b2a88fe07 hwdb: Add keymap for Lenovo 15IRX9 (#42141)
This adds a mapping for the Fn+F9 key (used to launch Lenovo Vantage
on Windows) on the Lenovo LOQ 15IRX9 gaming laptop.
2026-05-18 05:28:52 +09:00
Luca Boccassi 1d73c5f04f dhcp-client: clear overloaded sname/file fields after parsing
When SD_DHCP_OPTION_OVERLOAD indicates that the sname and/or file header
fields are overloaded with extra DHCP options, dhcp_message_parse() merges
those options into message->options but leaves the raw bytes untouched in
the header. As a result, dhcp_message_build() emits the header (including
the overloaded bytes) verbatim, and the next parse re-parses those bytes,
appending duplicate entries to the options map (each tag's iov list grows).
Subsequent builds then differ from the first, breaking the parse/build
roundtrip.

This was caught by fuzz-dhcp-client, which asserts that two consecutive
build calls produce identical output.

Zero out the overloaded fields after parsing them, since their content has
already been merged into the options map. This makes the roundtrip
idempotent and avoids re-emitting stale overloaded data in the rebuilt
header. The JSON build/parse path was already correct (it omits sname/file
from the JSON when the overload bit is set), so only the binary path needed
fixing.

Fixes https://github.com/systemd/systemd/issues/42139

Co-developed-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-18 04:52:25 +09:00
Yu Watanabe 2a1a026d72 udev-builtin-input-id: drop unused value 2026-05-18 02:55:56 +09:00
Yu Watanabe 6f72bb7bc9 tree-wide: use device_get_sysattr_unsigned() and friends 2026-05-18 02:55:56 +09:00
Yu Watanabe 6ad682d70f udev-builtin-usb_id: make set_usb_iftype() and friends return const char* 2026-05-18 02:55:56 +09:00
Yu Watanabe 23c93e2cd6 udev-builtin-usb_id: use device_get_sysattr_unsigned() and friends
This also fix the parser of bInterfaceClass from safe_atoi() to
safe_atou_full() as it is unsigned hex.
2026-05-18 02:55:56 +09:00
Yu Watanabe 247e4caa3c sd-device: also add device_get_sysattr_streq() 2026-05-18 02:55:56 +09:00
Yu Watanabe 1e39d3eb08 sd-device: also add device_get_sysattr_u8() and _u16() 2026-05-18 02:55:56 +09:00