Commit Graph
45929 Commits
Author SHA1 Message Date
Lennart Poettering 0adb58c3f1 sd-netlink: add call to query sd_event object an sd_netlink object is attached to
This mimics a similar call sd_bus_get_event() that already exists for
sd-bus.
2023-11-02 14:19:32 +01:00
Lennart Poettering 50ab93eb0e blockdev-util: export block_device_get_originating() 2023-11-02 14:19:32 +01:00
Lennart Poettering de7e033286 udevadm-lock: switch things over to lock_generic_with_timeout()
This replaces the local implementation of a timeout file lock with our
new generic one.

Note that a comment in the old code claimed we couldn't use alarm()-like timeouts,
but htat's not entirely true: we can if we use SIGKILL, and thus know
for sure that the process will be dead in case the timer is hit before
we actually enter the file lock syscall. But we also know it will be
delivered if we hit after.
2023-11-02 14:19:32 +01:00
Lennart Poettering e5f1e8b894 lock-util: add a new lock_generic_with_timeout() helper
This is just like lock_generic(), but applies the lock with a timeout.
This requires jumping through some hoops by executing things in a child
process, so that we can abort if necessary via a timer. Linux after all
has no native way to take file locks with a timeout.
2023-11-02 14:19:32 +01:00
Lennart Poettering e9ccae3135 process-util: add new FORK_DEATHSIG_SIGKILL flag, rename FORK_DEATHSIG → FORK_DEATHSIG_SIGTERM
Sometimes it makes sense to hard kill a client if we die. Let's hence
add a third FORK_DEATHSIG flag for this purpose: FORK_DEATHSIG_SIGKILL.

To make things less confusing this also renames FORK_DEATHSIG to
FORK_DEATHSIG_SIGTERM to make clear it sends SIGTERM. We already had
FORK_DEATHSIG_SIGINT, hence this makes things nicely symmetric.

A bunch of users are switched over for FORK_DEATHSIG_SIGKILL where we
know it's safe to abort things abruptly. This should make some kernel
cases more robust, since we cannot get confused by signal masks or such.

While we are at it, also fix a bunch of bugs where we didn't take
FORK_DEATHSIG_SIGINT into account in safe_fork()
2023-11-02 14:09:23 +01:00
Lennart Poettering 61c062f896 fd-util: add new FORMAT_PROC_PID_FD_PATH() helper
This is just like FORMAT_PROC_FD_PATH() but goes via the PID number
rather than the "self" symlink.

This is useful whenever we want to generate a path that is useful
outside of our local scope.
2023-11-02 14:09:23 +01:00
Lennart Poettering f1b622a00c varlink,json: introduce new varlink_dispatch() helper
varlink_dispatch() is a simple wrapper around json_dispatch() that
returns clean, standards-compliant InvalidParameter error back to
clients, if the specified JSON cannot be parsed properly.

For this json_dispatch() is extended to return the offending field's
name. Because it already has quite a few parameters, I then renamed
json_dispatch() to json_dispatch_full() and made json_dispatch() a
wrapper around it that passes the new argument as NULL. While doing so I
figured we should also get rid of the bad= argument in the short
wrapper, since it's only used in the OCI code.

To simplify the OCI code this adds a second wrapper oci_dispatch()
around json_dispatch_full(), that fills in bad= the way we want.

Net result: instead of one json_dispatch() call there are now:

1. json_dispatch_full() for the fully feature mother of all dispathers.
2. json_dispatch() for the simpler version that you want to use most of
   the time.
3. varlink_dispatch() that generates nice Varlink errors
4. oci_dispatch() that does the OCI specific error handling

And that's all there is.
2023-11-02 01:19:21 +00:00
Frantisek Sumsal d0404391e5 fuzz: limit the size of the input
To avoid timeouts in oss-fuzz. The timeout reported in #29736 happened
with a ~500K test case, so with a conservative 128K limit we should
still be well within a range for any reasonable-ish generated input to
get through, while avoiding timeouts.

Resolves: #29736
2023-11-01 23:08:19 +00:00
Luca Boccassi 79e1f7091f Merge pull request #29816 from bluca/rel
Busywork for RC1
2023-11-01 20:14:11 +00:00
Yu Watanabe f5a0831c32 Merge pull request #29817 from YHNdnzj/fchmodat2
Add support for fchmodat2 and use it where appropriate
2023-11-02 04:56:29 +09:00
Lennart Poettering b71a721fbc parse-util: add parse_tristate() and use it everywhere
We parse tristates all the time, let's add an explicit parser for them.
2023-11-02 04:52:16 +09:00
Lennart Poettering 423e2400af sort-util: make bsearch_safe() actually typesafe, by returning the right type 2023-11-01 17:18:15 +00:00
Arseny MaslennikovandMike Yuan 30462563b1 nspawn-patch-uid: try fchmodat2() to restore mode of symlink
Prior to this commit, if the target had been a symlink, we did nothing
with it. Let's try with fchmodat2() and skip gracefully if not supported.

Co-authored-by: Mike Yuan <me@yhndnzj.com>
2023-11-02 00:29:09 +08:00
Arseny MaslennikovandMike Yuan adecfb3bc0 basic/fs-util: prefer fchmodat2 in fchmod_opath
Co-authored-by: Mike Yuan <me@yhndnzj.com>
2023-11-02 00:26:22 +08:00
Arseny MaslennikovandMike Yuan c21566d90b basic/missing_syscall: add missing_fchmodat2()
Follow-up for 8b45281daa
and preparation for later commits.

Since libcs are more interested in the POSIX `fchmodat(3)`, they are
unlikely to provide a direct wrapper for this syscall. Thus, the headers
we examine to set `HAVE_*` are picked somewhat arbitrarily.

Also, hook up `try_fchmodat2()` in `test-seccomp.c`. (Also, correct that
function's prototype, despite the fact that mistake would not matter in
practice)

Co-authored-by: Mike Yuan <me@yhndnzj.com>
2023-11-02 00:23:12 +08:00
Lukas Nykryn 2b5b25f123 udev: add new builtin net_driver
Currently the ID_NET_DRIVER is set in net_setup_link builtin.
But this is called pretty late in the udev processing chain.

Right now in some custom rules it was workarounded by calling ethtool
binary directly, which is ugly.

So let's split this code to a separate builtin.
2023-11-01 16:00:19 +00:00
Lennart Poettering 9c21cfdd7d chase: fix corner case when using CHASE_PARENT with a path ending in ".."
If we use CHASE_PARENT on a path ending in ".." then things are a bit
weird, because we the last path we look at is actually the *parent* and not
the *child* of the preceeding path. Hence we cannot just return the 2nd
to last fd we look at. We have to correct it, by going *two* levels up,
to get to the actual parent, and make sure CHASE_PARENT does what it
should.

Example: for the path /a/b/c chase() with CHASE_PARENT will return
/a/b/c as path, and the fd returned points to /a/b. All good.  But now,
for the path /a/b/c/.. chase() with CHASE_PARENT would previously return
/a/b as path (which is OK) but the fd would point to /a/b/c, which is
*not* the parent of /a/b, after all! To get to the actual parent of
/a/b we have to go *two* levels up to get to /a.

Very confusing. But that's what we here for, no?

@mrc0mmand ran into this in https://github.com/systemd/systemd/pull/28891#issuecomment-1782833722
2023-11-01 14:43:24 +00:00
Luca Boccassi 7c2fd96dba Merge pull request #29764 from dtardon/varlink-io.systemd.service
Add varlink interface io.systemd.service
2023-11-01 14:41:58 +00:00
Luca Boccassi df594373a4 Merge pull request #29691 from yuwata/dissect
udev: update devlink with the newer device node even when priority is equivalent
2023-11-01 14:36:28 +00:00
Lennart Poettering ac110243a8 bsod,loop-util: fix fd validity check 2023-11-01 15:21:20 +01:00
Lennart Poettering 943aca96f7 proc-cmdline: use read_virtual_file() for /proc/cmdline 2023-11-01 15:20:54 +01:00
Lennart Poettering 5c2597ab07 Merge pull request #29788 from poettering/nspawn-barrier-fix
nspawn: fix barriers when wiping fully visible procfs/sysfs
2023-11-01 15:20:15 +01:00
Lennart Poettering a3b46c6bf6 cryptenroll: use erase_and_free() at two more places 2023-11-01 15:19:10 +01:00
Luca Boccassi 6636cc54e5 Update syscalls table 2023-11-01 14:07:54 +00:00
Yu Watanabe 4314abf6d4 sd-netlink: res_id is 16bit but serial is 32bit
The explicit value here is not so important.
Let's chop off the higher bits.

Fixes the issue reported at
https://github.com/systemd/systemd/pull/29802#issuecomment-1788637950.
2023-11-01 14:02:49 +00:00
Luca Boccassi 070243ecda Merge pull request #29803 from poettering/coredump-message-tweaks
coredump: tweaks to log message & more
2023-11-01 13:20:11 +00:00
Yu Watanabe 498a6de596 dhcp6: enterprise ID is 32bit
Follow-up for 6b44099b3b.

Fixes #29800.
2023-11-01 13:19:59 +00:00
David Tardon 1263055121 varlink: add generic impl. of io.systemd.service.SetLogLevel() 2023-11-01 12:50:52 +01:00
Yu Watanabe 7ec5ce5673 udev: update devlink with the newer device node even when priority is equivalent
Several udev rules depends on the previous behavior, i.e. that udev
replaces the devlink with the newer device node when the priority is
equivalent. Let's relax the optimization done by
331aa7aa15.

Follow-up for 331aa7aa15.

Note, the offending commit drops O(N) of file reads per uevent, and this
commit does not change the computational order. So, hopefully the
performance impact of this change is small enough.

Fixes #28141.
2023-11-01 19:46:03 +09:00
Peter Hutterer 4f7a629e6c analyze: handle CAP_BPF support 2023-11-01 10:25:59 +00:00
Yu Watanabe ba87a61d05 network: support ID_NET_MANAGED_BY udev property
If the property is set, networkd manages the interface only when its
value is "io.systemd.Network".

Closes #29768.
2023-11-01 10:14:27 +01:00
Lennart Poettering c8e9476386 coredump: let's always drop privileges
Let's unconditionally drop privileges before submitting the coredump log
message.

Let's make the codepaths where we acquired a coredump and where we
didn't more alike: let's drop privs in both cases.

This is not only safer, but means that the coredump messages are always
accessible by the owner of the aborted process.
2023-11-01 10:02:04 +01:00
Lennart Poettering 6fea39bacc coredump: tweak coredump log message
Let's not claim a process dumped core if that was disabled via resource
limits.

While we are at it, switch from stack to heap allocation for the log
message, as it includes a stack trace which can be arbitrarily large.

Fixes: #28559
2023-11-01 10:02:04 +01:00
Yu Watanabe 7122bd12fd Merge pull request #29786 from mrc0mmand/more-executor-stuff
test: exercise more systemd-executor related stuff
2023-11-01 12:51:08 +09:00
Marc Pervaz Boocha abca74cb48 Fixed a typo in kernel-install/60-ukify.install.in for globing microcode
searches in a non-existent micocode/* dir instead of micocode* due a typo in #28592
2023-11-01 12:44:52 +09:00
Luca Boccassi fba173ff6a core: rename and add comment to ExecParameters cleanup functions 2023-11-01 12:43:22 +09:00
Lennart Poettering dba4fa8910 nspawn: make sure idmapped logic works if DDI contains only /usr/ tree
If we have a DDI that contains only a /usr/ tree (and which is thus
combined with a tmpfs for root on boot) we previously would try to apply
idmapping to the tmpfs, but not the /usr/ mount. That's broken of
course.

Fix this by applying it to both trees.
2023-11-01 00:50:43 +00:00
Frantisek Sumsal 6634e66ded core: fix a couple of typos 2023-10-31 18:52:00 +01:00
Lennart Poettering 30e68bbba6 barrier: use EBADF where appropriate 2023-10-31 18:32:13 +01:00
Frantisek Sumsal 6f93eb159a core: check if we got a valid personality during deserialization 2023-10-31 17:34:37 +01:00
Lennart Poettering 1a8d781495 nspawn: fix barriers when wiping fully visible procfs/sysfs
Let's wait until the child is fully done with mounting it's own
instances of procfs/sysfs before we destroy our fully visible copies of
it.

This borrows heavily from Christian Brauners fix #29521, but splits the
place + sync into two steps so that the child payload is not started
before the parent has destroyed the procfs instance.

Alternative to: #29521
Fixes: #28157
2023-10-31 15:33:49 +01:00
Lennart Poettering 553a596ad9 Merge pull request #29763 from yuwata/vconsole-conf
locale,firstboot: add comments to vconsole.conf
2023-10-31 14:37:47 +01:00
Yu Watanabe 2b43c5cb7a udev: fix device name shown in the log message on failure
Prompted by #29500.
2023-10-31 14:37:10 +01:00
Yu Watanabe b1cfc95ff9 udevadm-trigger: mention --type=all in help
Follow-up for 1baeee5784.

Fixes #29779.
2023-10-31 14:36:22 +01:00
Lennart Poettering d6d9bc01cb Merge pull request #29769 from poettering/network-generator-ll
network-generator: add new mode ip=link-local
2023-10-31 14:35:49 +01:00
Lennart Poettering db8618ee82 Merge pull request #29776 from jinliu/pam_kernel_keyring
New PAM module: pam_systemd_loadkey
2023-10-31 14:34:47 +01:00
David Tardon ca46756cd8 varlink: add generic impl. of io.systemd.varlink.Ping() 2023-10-31 12:49:17 +01:00
David Tardon 4ffe0aedf9 varlink: define interface io.systemd.service 2023-10-31 12:49:16 +01:00
Yu Watanabe 758a3aeb4c dissect: reenable automatic removal before trying again
The device node may be different from we want to activate, and we may
try to activate different device in the subsequent loop. In such case,
we should enable the automatic removal for the unexpected device.
Otherwise, it will not be removed even when not necessary anymore.
2023-10-31 10:30:30 +00:00
Jin Liu a28b7310ee New PAM module: pam_systemd_loadkey
This module reads password from kernel keyring and sets it as PAM authtok.
It's inspired by gdm's pam_gdm, which reads the LUKS password stored by
systemd-cryptsetup, so Gnome Keyring can be automatically unlocked if set
to the same password (when autologin is enabled so the user doesn't enter
a password in gdm).
2023-10-31 18:20:23 +08:00