Commit Graph
81674 Commits
Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek 8fc7b2a211 coredump: also stop forwarding non-dumpable processes
See the comment in the patch for details.

Suggested-by: Qualys Security Advisory <qsa@qualys.com>
2025-05-29 00:10:55 +02:00
Zbigniew Jędrzejewski-Szmek 0c49e0049b coredump: use %d in kernel core pattern
The kernel provides %d which is documented as
"dump mode—same as value returned by prctl(2) PR_GET_DUMPABLE".

We already query /proc/pid/auxv for this information, but unfortunately this
check is subject to a race, because the crashed process may be replaced by an
attacker before we read this data, for example replacing a SUID process that
was killed by a signal with another process that is not SUID, tricking us into
making the coredump of the original process readable by the attacker.

With this patch, we effectively add one more check to the list of conditions
that need be satisfied if we are to make the coredump accessible to the user.

Reportedy-by: Qualys Security Advisory <qsa@qualys.com>

In principle, %d might return a value other than 0, 1, or 2 in the future.
Thus, we accept those, but emit a notice.
2025-05-29 00:10:08 +02:00
Zbigniew Jędrzejewski-Szmek 49f1f2d4a7 coredump: get rid of _META_MANDATORY_MAX
No functional change. This change is done in preparation for future changes.
Currently, the list of fields which are received on the command line is a
strict subset of the fields which are always expected to be received on a
socket. But when we add new kernel args in the future, we'll have two
non-overlapping sets and this approach will not work. Get rid of the variable
and enumerate the required fields. This set will never change, so this is
actually more maintainable.

The message with the hint where to add new fields is switched with
_META_ARGV_MAX. The new order is more correct.
2025-05-26 15:33:08 +02:00
Zbigniew Jędrzejewski-Szmek 61d78f1788 Restore compatibility for coredump --backtrace (#37559) 2025-05-22 13:40:29 +02:00
Daan De Meyer ababb70245 Clang tidy headers (#37566) 2025-05-22 12:01:57 +02:00
Daan De Meyer 54b59d914e meson: Run clang-tidy on libsystemd headers as well 2025-05-22 11:25:32 +02:00
Daan De Meyer 5ea01af240 meson: Use .inc for generated code meant to be included in other files
These files use the .h extension but are not standalone so let's not
make it appear like they are proper headers and instead use the .inc
extension.
2025-05-22 11:25:29 +02:00
Daan De Meyer c60a8c72d1 boot: Clean up includes
Instead of introducing efi-forward.h, we use efi.h for the same purpose
in the boot/ folder.
2025-05-22 11:10:20 +02:00
Luca Boccassi c3c79aeb52 Revert "logind: always enclose list fields (that may contain spaces) in quotes"
This breaks GNOME on Wayland, login no longer works:

gnome-shell[2250]: Running GNOME Shell (using mutter 48.2) as a Wayland display server
gnome-shell[2250]: Failed to setup: Failed to find any matching session
systemd[2054]: org.gnome.Shell@wayland.service: Failed with result 'protocol'.
systemd[2054]: Failed to start org.gnome.Shell@wayland.service - GNOME Shell on Wayland.

This reverts commit b0555149de.
2025-05-22 10:00:52 +01:00
Daan De Meyer bf7476233a Various cleanups (#37564) 2025-05-22 10:40:35 +02:00
Daan De Meyer 6ae1ba8a84 core: Clean up includes
Follow up for 836e4e7ea8
2025-05-22 09:41:18 +02:00
Daan De Meyer f848cb8d3e test: Remove unused includes 2025-05-22 09:41:18 +02:00
Daan De Meyer 6cc59a2de6 machine: Fix comment 2025-05-22 09:41:18 +02:00
Daan De Meyer 836e4e7ea8 core: Clean up includes
Split out of #37344.
2025-05-22 09:37:20 +02:00
Matteo Croce 6288739eaf networkd: print a meaningful error on failure
test_keep_configuration_on_restart() works, but the error printed is
misleading because self.assertNotEmpty() doesn't exist.

Add a working assert statement so, when the unmanaged interface is
altered, the test fails with a meaningful error, like:

        ### ip monitor dev unmanaged0 BEGIN
        222:33::/64 proto kernel metric 256 pref medium
        FAIL
        [...]
        Traceback (most recent call last):
          File "/work/src/test/test-network/systemd-networkd-tests.py", line 5085, in test_keep_configuration_on_restart
            self.assertEqual(line, '')
        AssertionError: '222:33::/64 proto kernel metric 256 pref medium' != ''
        - 222:33::/64 proto kernel metric 256 pref medium

While at it, strip the trailing newline so we can print easily the
string (and in future build more a robust regexp which uses the $ token)
2025-05-22 09:33:39 +02:00
Mike Yuan 9daa1dbcce Several minor follow-ups for #33995 (#37558) 2025-05-22 00:22:00 +02:00
Zbigniew Jędrzejewski-Szmek c673f1f67a coredump: wrap long lines, fix grammar in comments 2025-05-21 23:51:31 +02:00
Zbigniew Jędrzejewski-Szmek ded0aac389 coredump: restore compatibility with older patterns
This was broken in f45b801551. Unfortunately
the review does not talk about backward compatibility at all. There are
two places where it matters:
- During upgrades, the replacement of kernel.core_pattern is asynchronous.
  For example, during rpm upgrades, it would be updated a post-transaction
  file trigger. In other scenarios, the update might only happen after
  reboot. We have a potentially long window where the old pattern is in
  place. We need to capture coredumps during upgrades too.
- With --backtrace. The interface of --backtrace, in hindsight, is not
  great. But there are users of --backtrace which were written to use
  a specific set of arguments, and we can't just break compatiblity.
  One example is systemd-coredump-python, but there are also reports of
  users using --backtrace to generate coredump logs.

Thus, we require the original set of args, and will use the additional args if
found.

A test is added to verify that --backtrace works with and without the optional
args.
2025-05-21 23:45:14 +02:00
Yu Watanabe 2fbbf6c4c7 unit-def: reindent comments
Prompted by dfdeb0b1cb.
2025-05-22 05:15:08 +09:00
Yu Watanabe fe6a2c8a6c test-vpick: use more strict check
Follow-up for 4fc9940760.
2025-05-22 05:11:14 +09:00
Daan De Meyer 847e9fc366 logind: Add missing include
Follow up for 1aa202dd24
2025-05-21 21:23:06 +02:00
Yu Watanabe 276ddd8a91 logind: state serialization fixes (#37555)
Turns out our escaping was really broken when saving/restoring
session/seat/user state. Let's fix that.
2025-05-22 03:54:40 +09:00
Daan De Meyer 4bde87437a analyze: Clean up includes
Split out of #37344.
2025-05-22 03:06:46 +09:00
Matteo Croce bcb9e72b6b networkd: ensure that unmanaged interfaces aren't touched
Extend the test_keep_configuration_on_restart in order to check
that the unmanaged interface isn't altered in any way.
2025-05-22 03:04:40 +09:00
Lennart Poettering c450027d14 env-file: rework write_env_file() to make use of O_TMPFILE 2025-05-22 02:50:48 +09:00
Lennart Poettering dfc9fd0147 logind: rename EnableWallMessages= configuration knob to WallMessages= (#37553)
We generally frown on config options that are called
EnableXYZ=/DisableXYZ=, hence drop this here too. Note that the original
sin was that the pre-existing D-Bus property already used the prefix.
But given that D-Bus properties are substantially more low-level (i.e.
developer focused) than the config knobs, let's bite the bullet and
name the configuration option cleanly, even if the dbus property carries
the damn prefix.

The knob was added post v257, hence this is not a compat break.

Follow-up for: 130698dc20
2025-05-22 02:47:57 +09:00
Lennart Poettering 3c70cbae0f machined: call pidref_verify() in some cases this was missing
We need to protect us from recycled PIDs here like everywhere else: once
we read data from /proc/$PID/ we need to validate that $PID still points
to the original pidfd.
2025-05-22 02:38:38 +09:00
Daan De Meyer acca52ab24 core: Make various ActivationDetails functions take a const argument 2025-05-22 02:17:39 +09:00
Daan De Meyer baa3fadfb7 network: Clean up includes
Split out of #37344.
2025-05-22 02:15:43 +09:00
Daan De Meyer f712008289 bootctl: Clean up includes
Split out of #37344.
2025-05-22 02:14:09 +09:00
Daan De Meyer fee4eaa1b7 cryptenroll: Clean up includes
Split out of #37344.
2025-05-22 01:41:12 +09:00
Daan De Meyer 96fafb925c cryptsetup: Clean up includes
Split out of #37344.
2025-05-22 01:40:01 +09:00
Yu Watanabe abe7cc5678 README: update badges 2025-05-22 01:37:05 +09:00
Yu Watanabe 8d9e00ea55 core/namespace: unapplicable -> inapplicable
Follow-up for dfdeb0b1cb.
2025-05-22 01:21:09 +09:00
Daan De Meyer eea9eb1f05 journal: Clean up includes
Split out of #37344.
2025-05-21 18:10:42 +02:00
Daan De Meyer 6c68f5d4ba journal-remote: Clean up includes
Split out of #37344.
2025-05-21 18:10:19 +02:00
Daan De Meyer 9412e9e97b import: Clean up headers
Split out of #37344.
2025-05-21 18:09:52 +02:00
Daan De Meyer 6ad1d1ede6 login: Clean up includes
Split out of #37344.
2025-05-21 18:09:28 +02:00
Daan De Meyer 64943cac5d machine: Clean up includes
Split out of #37344.
2025-05-21 18:08:50 +02:00
Lennart Poettering f01d8658a3 logind: also save pidfdid as part of session state, even if we don't parse it 2025-05-21 17:33:40 +02:00
Lennart Poettering 1aa202dd24 logind: save/restore inhibitor process pidfdid 2025-05-21 17:33:40 +02:00
Lennart Poettering b0555149de logind: always enclose list fields (that may contain spaces) in quotes 2025-05-21 17:33:40 +02:00
Lennart Poettering 232f4e12fe logind: fix escaping of various fields in state files
parse_env_file() applies a certain kind of unescaping, and we really
need to match that when writing out arbitrary strings.

(This gets a bit confusing in the inhibit case, since that already
applied one level of escaping on its own...)
2025-05-21 17:33:40 +02:00
Lennart Poettering 019c8ea26a logind: port logind state files to fopen_tmpfile_linkable()
This replaces use of fopen_temporary() with fopen_tmpfile_linkable() +
flink_tmpfile(). This both shortens the code and means we use O_TMPFILE
for installing these files, which is always good.

No change in behaviour otherwise.
2025-05-21 17:33:40 +02:00
Lennart Poettering e27333b2cc env-file: add helper for printing a properly escaped env var file assignment 2025-05-21 17:33:40 +02:00
Daan De Meyer d9eadbbca0 portable: Fix comment 2025-05-21 23:59:28 +09:00
Daan De Meyer 0bbd8e18ed systemctl: Clean up includes
Split out of #37344.
2025-05-21 23:59:03 +09:00
Daan De Meyer dc59a1517d udev: Clean up includes
Split out of #37344.
2025-05-21 23:57:31 +09:00
Daan De Meyer 5cf0b3b5bc sysupdate: Clean up includes
Split out of #37344.
2025-05-21 23:53:40 +09:00
Daan De Meyer 54f3008a1e pretty-print: Add missing fileio.h include
LONG_LINE_MAX comes from fileio.h and is used in pretty-print.h so
pretty-print.h should include it.
2025-05-21 23:53:40 +09:00