Commit Graph
78612 Commits
Author SHA1 Message Date
Lennart Poettering a241b796fa pid1: allow removal of foreign-owned subcgroups of cgroups owned by some user (#35922)
This improves operation in unprivileged userns environments, where
unpriv user code might invoke a container with a delegated userns UID
range, and thus ends up with a subcgroup owned by another UID. With this
patch any user is always allowed to remove their own cgroups even if it
has subcgroups owned by other users.

This removes a DoS of sorts, and enforces the rule that users strictly
own everything below cgroups they own.
2025-01-08 21:36:16 +01:00
Daan De Meyer 44368f84d7 fmf: Dump CPU and memory information 2025-01-08 21:14:58 +01:00
Mike Yuan 684e4e5bfb two pidref tweaks (#35918) 2025-01-08 18:58:20 +01:00
Lennart Poettering 1d5fd2e621 test: add testcase that verifies we can safely delete subcgroups owned by other users if we own the parent
This is a test for the previous commits: we create an unpriv, delegated cgroup in
--user mode, then create a subcgroup that is owned by some other user
(to mimic the case where an unpriv user got a userns with delegated UIDs
assigned), and then try to stop the unit. traditionally this would fail,
because our unpriv systemd --user instance can't remove the subcrroup
owned by someone else. With the earlier patches this is addressed.
2025-01-08 15:27:25 +01:00
Lennart Poettering 51a70c8875 cgroup: when we fail to clean up a cgroup, let's ask PID 1 for help 2025-01-08 15:27:25 +01:00
Lennart Poettering 94634b4b03 pid1: add D-Bus API for removing delegated subcgroups
When running unprivileged containers, we run into a scenario where an
unpriv owned cgroup has a subcgroup delegated to another user (i.e. the
container's own UIDs). When the owner of that cgroup dies without
cleaning it up then the unpriv service manager might encounter a cgroup
it cannot delete anymore.

Let's address that: let's expose a method call on the service manager
(primarly in PID1) that can be used to delete a subcgroup of a unit one
owns. This would then allow the unpriv service manager to ask the priv
service manager to get rid of such a cgroup.

This commit only adds the method call, the next commit then adds the
code that makes use of this.
2025-01-08 15:27:25 +01:00
Lennart Poettering 59857b672c pid1: allow moving processes in a userns owned by the user, too
Let's liberalize process migration a bit. Previously, PID 1 would only
allow you to move processes into your own cgroups, if those processes
are owned by you too. This is now slightly relaxed: it's now also OK if
the processes are in a userns owned by you.

This makes process migration more useful in context of unpriv userns.
2025-01-08 15:27:25 +01:00
nl6720 96963e5615 dissect-image: mount the ESP with fmask=0177 (#35871)
Avoid showing the files on the ESP (i.e. a FAT formatted volume) as
executable by removing the execute permission from them.

IMO this makes the colored output of `ls` more sensible since the file
system will be mounted with `noexec` anyway.

Add a `fstype_can_fmask_dmask` function that checks if a file system
type can use the `fmask` and `dmask` mount options.

This replaces `fstype_can_umask` since it was only used in
`partition_pick_mount_options` which only cares about the file system
support for fmask & dmask now.

It somewhat reduces the coverage of the feature since there are more file
systems that support umask as opposed to those supporting dmask & dmask,
but it should not be much of an issue since fmask & dmask are supported
by vfat, exfat and ntfs3.
2025-01-08 15:19:33 +01:00
Lennart Poettering dcb29a931c Simple pam_systemd clean-ups (#35919) 2025-01-08 15:03:36 +01:00
Lennart Poettering 0df46f8908 pidref: drop support for kernels lacking waitid(P_PIDFD, …)
Our baseline is not 5.4, which is where P_PIDFD was introduced.
2025-01-08 14:51:19 +01:00
Lennart Poettering 06744cbb52 pidref: copy fd id in pidref_copy() too 2025-01-08 14:51:19 +01:00
Daan De Meyer 8e3347f3bd fmf: Only mess with /etc/yum.repos.d when running within testing farm
If running tmt locally to debug the test script, make sure we don't
mess with /etc/yum.repos.d.
2025-01-08 13:37:23 +01:00
Daan De Meyer 7f1eceb168 Three fmf fixes (#35917) 2025-01-08 12:29:10 +01:00
Lennart Poettering 394a6ab68c logind: also potentially GC the session if we cannot send reply 2025-01-08 11:24:18 +01:00
Lennart Poettering 1b48aa3523 logind: indicate that 'error' parameter is input by making it const 2025-01-08 11:24:18 +01:00
Lennart Poettering e79502cdfa logind: split out logic that finds free session ID into helper call
Just some refactoring to make an overly large function a bit smaller.
2025-01-08 11:24:18 +01:00
Lennart Poettering 1b58ba768a logind: normalize parameter to create_session()
We can pass a properly typed Manager object here, no reason to pass it
as void*.
2025-01-08 11:20:18 +01:00
Daan De Meyer fc1b08dee2 fmf: Fix glob
Globs inside quotes aren't expanded and we need the glob to be more
specific to avoid matching multiple entries inside the tmt source
directory.
2025-01-08 11:15:43 +01:00
Daan De Meyer 0a85b37579 fmf: Fix dist-git example
All that's needed is dist-git-source: true so remove the other settings
that aren't required.
2025-01-08 10:25:50 +01:00
Daan De Meyer 0250db0139 fmf: Don't fail if we can't put selinux in permissive mode
The tests might be running unprivileged or in an environment without
selinux so let's not fail if we can't put it in permissive mode.
2025-01-08 10:25:05 +01:00
Luca Boccassi 6b61f34a46 Stop installing some markdown docs/ files
These files are rendered on systemd.io and targeted at contributors, not
users, so it's not really useful to install them on a running system.
2025-01-08 09:45:09 +01:00
Lennart Poettering 344376adb8 namespace-util: two new operations (#35833)
(This is preparation for #35685, but since it comes with nice test cases
should be safe to add on their own)
2025-01-08 09:35:21 +01:00
Lennart Poettering 2ade821859 namespace-util: add process_is_owned_by_uid() helper 2025-01-07 23:55:34 +01:00
Lennart Poettering 3d57b6692f namespace-util: add helper to get base UID from userns 2025-01-07 23:55:34 +01:00
Lennart Poettering 5b14690a39 namespace-util: slightly tweak proc_mounted() handling in namespace_is_init()
Let's not sloppily eat up errors here.
2025-01-07 23:51:28 +01:00
Lennart Poettering adcc805929 namespace-util: return recognizable error if namespace_open_by_type() fails because ns type not supported
This makes sure the the codepath that derives an nsfd from a pid works
the same for the pidfd case and the non-pidfd case: if we can verify
that /proc/ is mounted but the /proc/$PID/ns/ files are missing, we can
assume the ns type is not supported by the kernel. Hence return the same
ENOPKG error in this case as we already do in the pidfd ioctl based
codepath.
2025-01-07 23:51:28 +01:00
Mike Yuan 16ac586e5a Bump minimum kernel baseline to 5.4, recommended version to 5.7
As requested, a list of kernel version to feature mapping
for kernels older than minimum baseline is also included,
in order to ease potential backport work.
2025-01-07 22:43:45 +01:00
Lennart Poettering 0dfd89fa32 udev: introduce io.systemd.Udev varlink interface (#35721)
Replaces #25523.
2025-01-07 16:49:37 +01:00
Tobias Klauser 9379b23be3 resolve: fix typo in DNS_EDE_RCODE_PROHIBITIED constant name
Drop the extra `I` and rename the constant to DNS_EDE_RCODE_PROHIBITED
in accordance with the error code string.
2025-01-07 16:48:44 +01:00
Daan De Meyer 6640466cec mkosi: Bump device timeout back to default value
Hopefully fixes #35302
2025-01-07 16:20:35 +01:00
Jacob McNamee 9d1c28b2d8 stdio-bridge: fix polled fds
Poll fds associated with the bus instead of hardcoding stdin/stdout.

This is consequential under socket activation, when the provided fd
should be used instead of stdin/stdout.
2025-01-07 15:51:16 +01:00
Daan De Meyer 3c9ffd2e4b fmf: Check out target branch in packit 2025-01-07 15:27:19 +01:00
Daan De Meyer 86a6d7cc5a packit: Simplify configuration 2025-01-07 15:18:50 +01:00
Luca Boccassi 5c4cb68390 obs: also trigger Fedora package builds
The package is logistically separated, as the rpm sources conflict from Fedora
conflict with the rpm sources from SUSE (some files have the same name and
location but different, incompatible content), so Fedora builds can't be
triggered from the same package. The result is the same.
2025-01-07 13:56:52 +01:00
Yu Watanabe 05db3fe7f9 ask-password: req must be non-NULL
After #35074, the parameter 'req' must be non-NULL.

Fixes CID#1586101, CID#1586102, and CID#1586103.
2025-01-07 13:12:08 +01:00
Daan De Meyer 414fe9629c mkosi: Install which in build image
Required by gdb-add-index to find gdb and not declared as a dependency
of the package.
2025-01-07 12:39:46 +01:00
Luca Boccassi f2b34ce7f3 test: add test case for AddDependencyUnitFiles assert
Follow-up for d87dc74e8f
2025-01-07 11:35:03 +00:00
Yu WatanabeandDavid Tardon 2bc733d9b0 units: introduce systemd-udevd-varlink.socket
Co-authored-by: David Tardon <dtardon@redhat.com>
2025-01-07 20:31:15 +09:00
Yu Watanabe 3fed28b8cb udevadm: use varlink connection to send ping 2025-01-07 20:31:15 +09:00
Yu Watanabe 4e4c2fcfb6 udevadm-control: use varlink to send commands 2025-01-07 20:31:15 +09:00
Yu WatanabeandDavid Tardon 2f0aa9a804 udev-varlink: introduce io.systemd.Udev varlink interface
Co-authored-by: David Tardon <dtardon@redhat.com>
2025-01-07 20:31:15 +09:00
Yu Watanabe d5c4c4d45c TEST-17-UDEV: wait for udevd being restarted after exit control command
Also wait for created devices being processed before running tests.
2025-01-07 20:31:15 +09:00
Daan De Meyer 83c0b95f63 docs: Remove VIRTUALIZED_TESTING.md
Let's nuke this out-of-date doc in favor of HACKING.md.
2025-01-07 11:13:31 +01:00
Daan De Meyer ffcdaec632 repart: Use streq_ptr()
p->format is not guaranteed to be initialized.
2025-01-07 09:11:30 +01:00
Yu Watanabe 2bef5d187d machine: update log message and comments
Follow-up for 9af9d66184 and
453f2359ff.
2025-01-07 09:11:09 +01:00
Lennart Poettering 56a07d10a5 xopenat(): introduce new XO_REGULAR flag (#35834)
This is something I think we should have added a long time ago: a
flavour of open() that safely ensures the inode we are opening is a
regular file, before we open it. It does this by means of pinning the
inode via O_PATH first, and after verification actually opening it.

This ports some code over to this, but sooner or later we should
probably use this a lot more, so that we don't accidentally open weird
stuff such as device nodes or pipes, where we should not.
2025-01-07 08:55:56 +01:00
Lennart Poettering 20785351b1 pretty-print: drop extra ';' from progress reporting end sequence
This corrects the closing sequence for the ConEmu progress reporting
final sequence. We by mistake sent two final ;;, where only one was
expected. The terminals I tested this with didn't care, but Ghostty
apparently does. Let's fix things and generate the closing sequence as
per doc:

https://conemu.github.io/en/AnsiEscapeCodes.html#ConEmu_specific_OSC
2025-01-07 08:55:36 +01:00
Lennart Poettering 9ed2725867 process-util: a process from a foreign pidns is definitely not our child
Addresses: https://github.com/systemd/systemd/pull/35242#pullrequestreview-2531712318
2025-01-07 08:55:21 +01:00
Yu Watanabe 62e9cd6b09 basic/linux: update kernel headers from v6.13-rc6
This also removes README and moves the explanation about the header
modification to the script.
2025-01-06 23:35:14 +00:00
Lennart Poettering bcd2764960 update TODO 2025-01-06 23:37:45 +01:00