Commit Graph
81078 Commits
Author SHA1 Message Date
Yu Watanabe e95aebef1f network,udev: several fixlets for setting up SR-IOV VFs (#37269)
Closes #37257 and #37275.
2025-04-30 22:14:41 +09:00
Yu Watanabe 8305cd5640 network/tuntap: verify User=/Group= earlier and refuse non-system users/groups (#37294)
Similar to #36123.
Closes #37279.
2025-04-30 22:12:56 +09:00
Yu Watanabe 940441b44c network/tuntap: deny non-system users/groups from owning Tun/Tap interfaces
This is analogous to #36123, but for Tun/Tap interfaces created by
systemd-networkd.

If a regular user account want to control a Tun/Tap interface, then
assign the interface to a system group, e.g., vpn, and add the user
to the group.

Closes #37279.
2025-04-30 20:31:00 +09:00
Yu Watanabe 1fae13fbec network/tuntap: verify User=/Group= settings earlier
and ignore the settings if we cannot find the specified user/group.

This also replaces get_user_creds()/get_group_creds() with
userdb_by_name()/groupdb_by_name().
2025-04-30 20:30:34 +09:00
Nick Labich 52e2a24216 sysext: Include index=off in overlay mount options
Enable reuse of upper/work dirs with different lower layer paths.

Fixes https://github.com/systemd/systemd/issues/37245
2025-04-30 13:14:42 +02:00
Lennart Poettering 71c4b42efc sd-varlink: enforce some queuing limits + document associated api functions (#37289) 2025-04-30 12:19:21 +02:00
Daan De Meyer d62017b5a1 Add our own <netinet/in.h> and <net/if.h> headers and sort includes tree-wide with clang-format (#37278) 2025-04-30 10:42:57 +02:00
Lennart Poettering 82da05e7ef TODO 2025-04-30 10:34:44 +02:00
Lennart Poettering 034c5ac01f man: fix include line in sd_varlink_set_description() man page 2025-04-30 10:34:44 +02:00
Lennart Poettering 5b5c6826ba man: document sd_varlink_send() 2025-04-30 10:34:44 +02:00
Lennart Poettering 667fd5a9ec sd-varlink: put a limit on queued outgoing messages
This is only a safety net for runaway programs: it puts a limit on
outgoing messages, i.e. not on resources accessible directly from
outside, but only on resources taken by trusted local code.
2025-04-30 10:34:44 +02:00
Lennart Poettering b302a6bae5 man: document sd_varlink_push_fd() 2025-04-30 10:34:44 +02:00
Lennart Poettering 92c52a9ba6 sd-varlink: refuse accepting more than 253 fds to send along with a Varlink message
253 is the max number of fds one can send at once on a Linux AF_UNIX
socket. Hence refuse to send more early.
2025-04-30 10:34:44 +02:00
Lennart Poettering a4c81a6509 docs: add more markdown markup to UIDS_GIDS.md 2025-04-30 10:33:53 +02:00
Daan De Meyer 1cf40697e3 tree-wide: Sort includes
This was done by running a locally built clang-format with
https://github.com/llvm/llvm-project/pull/137617 and
https://github.com/llvm/llvm-project/pull/137840 applied on all .c
and .h files.
2025-04-30 09:30:51 +02:00
Daan De Meyer b773143708 clang-format: Disable for src/basic/include/linux
We shouldn't try to format these headers, so add a custom .clang-format
that disables formatting for the directory.
2025-04-30 09:30:33 +02:00
Daan De Meyer 5eaf4c1006 clang-format: Add include sorting directives
Let's make sure clang-format sorts includes according to our style
guide.
2025-04-30 09:30:33 +02:00
Daan De Meyer becc0256d8 resolve: Remove unnecessary ENABLE_DNS_OVER_TLS check 2025-04-30 09:30:14 +02:00
Yu Watanabe 371005ac98 network,udev: configure SR-IOV VF attribute one-by-one
When a [SR-IOV] section has no setting, e.g.
```ini
[SR-IOV]
VirtualFunction=0
```
then the kernel previously replied -EINVAL, as we send a rtnl message
with an empty IFLA_VF_INFO container.
See See do_setvfinfo() in net/core/rtnetlink.c of the kernel.

When a [SR-IOV] section that has an unsupported settings by the
interface driver, then previously the kernel partially applied
settings and returned -EOPNOTSUPP. E.f.
```ini
[SR-IOV]
VirtualFunction=0
LinkState=auto
Trust=true
MACAddress=02:01:00:3e:61:34
```
and the interface does not support configuring the link state, then
the MAC address is assigned, but the trust is not applied:
```
enp3s0f0: Failed to configure SR-IOV virtual function 0, ignoring: Operation not supported
    vf 0     link/ether 02:01:00:3e:61:34 brd ff:ff:ff:ff:ff:ff, spoof checking on, link-state auto, trust off
```

To fix such issues, this makes networkd/udevd send each attribute
for VF one-by-one.

Fixes #37257 and #37275.
2025-04-30 15:47:19 +09:00
Yu Watanabe c8b3f1d47d netif-sriov: align table 2025-04-30 15:47:19 +09:00
Yu Watanabe 9cb6017e6f network,udev: reword log messages in setting SR-IOV VFs 2025-04-30 15:47:19 +09:00
Yu Watanabe 45114e3999 network: ignore error in configuring SR-IOV VFs
The configuration can easily fail when the target virtual function
does not exist, and there is nothing networkd can do in such case.
Also, it is overkill to make the physical interface entered to the
failed state in such case. Let's warn but ignore the failure.
2025-04-30 15:47:19 +09:00
Tim Small 8e24558e61 man/network: clarify SR-IOV section description and usage
Document effect of the SR-IOV section in .link vs .network files and
restructure the SR-IOV section introduction for clarity.
2025-04-30 15:47:19 +09:00
Daan De Meyer 6be15dce13 basic: Remove assertions from missing_fs.h
These assertions impose an include order between <linux/fs.h> and
"missing_fs.h", specifically <linux/fs.h> can't be included before
"missing_fs.h". This makes automated include refactoring very painful,
so let's get rid of these assertions and instead assume that linux/fs.h
does the right thing.
2025-04-30 07:50:10 +02:00
Daan De Meyer 54f6bc152f basic: Add macro.h include to missing_syscall_def.h
Required for assert_cc()
2025-04-30 07:50:10 +02:00
Daan De Meyer d559f46384 basic: Add our own <netinet/in.h> and <net/if.h> headers
These glibc headers conflicts with the corresponding linux headers
(<linux/in.h> and <linux/if.h>) and impose an include order (the glibc one
has to be included before any linux header is included). This makes sorting
includes a royal pain so let's define our own versions of these headers using
various linux headers to do all the work and filling in the missing bits
ourselves.
2025-04-30 07:50:03 +02:00
Yu Watanabe 0dc09ccba7 linux: include sys/socket.h in linux/vm_sockets.h
The header requires struct sockaddr declared. So, otherwise, we need to
include sys/socket.h earlier than linux/vm_sockets.h.
Let's make the header includable at any place.
2025-04-30 07:37:34 +02:00
Yu Watanabe 3a03b97d6f tree-wide: drop unnecessary inclusion of tmpfile-util.h 2025-04-30 05:38:48 +09:00
Daan De Meyer 29257d927d udev: Enable delegation without delegating any controllers
Delegation is enabled for udev so that it can mess around with the
cgroup hierarchy to avoid killing control processes when it calls
cg_kill in on_post() when it goes idle. We don't actually care about
any specific cgroup controllers in udev, so set Delegate= to enable
delegation without delegating any controllers

Follow up for https://github.com/systemd/systemd/pull/22752
2025-04-29 20:03:34 +02:00
Luca Boccassi e7ddaf3bbc udev: Make Storage Tests Stable Again ! (#37262) 2025-04-29 14:37:20 +01:00
Zbigniew Jędrzejewski-Szmek 7dcbb48e46 various: do not use assert_se as a workaround in non-test code
This partially reverts 5332be60d3. I expect that
there is no practical difference, but it seems philosophically wrong to use
assert_se(), i.e. for the generation of the code in non-debug builds, just to
suppress a warning. We have _unused_ for that, use it.

I verified that we don't get warnings with clang and -DNDEBUG=1 with this patch.
2025-04-29 21:59:32 +09:00
Yu Watanabe bd4ab24f49 basic/include/linux: update kernel headers from v6.15-rc4 2025-04-29 21:58:25 +09:00
Daan De Meyer 4cf30a318a cleanup: update bug prone argument comments (#37281)
@DaanDeMeyer Obviously this doesn't fix nearly everything, so gradually
moving things over is probably a smart thing? It seems clang-tidy does
support drop in configs for example:

```
# SPDX-License-Identifier: LGPL-2.1-or-later
---
Checks: '
    -*,
    bugprone-argument-comment
'
WarningsAsErrors: '*'
```

Its a bit strange that `WarningsAsErrors` isn't propagated, but dropping
this file in src/report/.clang-tiday invokes:

```
[1314/1543][1.5s] /usr/bin/clang-tidy --use-color -extra-arg=-fno-caret-diagnostics -p=/home/jelle/projects/systemd/build -quiet /home/jelle/projec
ts/systemd/src/repart/repart.c
../src/repart/repart.c:4715:41: error: argument name 'pubkey' in comment does not match parameter name 'public' [bugprone-argument-comment,-warning
s-as-errors]
 4715 |                                         /* pubkey= */ NULL,      /* Turn this one off for the 2nd shard */
      |                                         ^
../src/shared/tpm2-util.h:281:108: note: 'public' declared here
  281 | int tpm2_calculate_sealing_policy(const Tpm2PCRValue *pcr_values, size_t n_pcr_values, const TPM2B_PUBLIC *public, bool use_pin, const Tpm2
PCRLockPolicy *policy, TPM2B_DIGEST *digest);
      |                                                                                                            ^
```

So that seems to behave as intended :)

And in some cases I am not sure if switching to the correct argument is
an improvement ie.:
```
../src/bootctl/bootctl-reboot-to-firmware.c:66:51: [38;2;190;132;255m0;1;31merror: argument name 'dispatch_table' in comment does not match paramet
er name 'table' [bugprone-argument-comment,-warnings-as-errors]
   66 |         r = sd_varlink_dispatch(link, parameters, /* dispatch_table = */ NULL, /* userdata = */ NULL);
      | [38;2;190;132;255m0;1;32m                                                  ^
../src/systemd/sd-varlink.h:187:98: [38;2;190;132;255m0;1;36mnote: 'table' declared here
  187 | int sd_varlink_dispatch(sd_varlink *v, sd_json_variant *parameters, const sd_json_dispatch_field table[], void *userdata);
      | [38;2;190;132;255m0;1;32m                                                                                                 ^
```

or
```
../src/validatefs/validatefs.c:274:83: [38;2;190;132;255m0;1;31merror: argument name 'ret_len' in comment does not match parameter name 'len' [bugprone-argument-comment,-warnings-as-errors]
  274 |                         (void) blkid_probe_lookup_value(b, "PART_ENTRY_TYPE", &v, /* ret_len= */ NULL);
      | [38;2;190;132;255m0;1;32m                                                                                  ^
/usr/include/blkid/blkid.h:455:52: [38;2;190;132;255m0;1;36mnote: 'len' declared here
  455 |                         const char **data, size_t *len)
      | [38;2;190;132;255m0;1;32m                                                   ^
```

But that's also half a style thing with `len` winning over `ret_len`.
2025-04-29 14:34:37 +02:00
joo es 7d65961629 po: Translated using Weblate (Arabic)
Currently translated at 100.0% (257 of 257 strings)

po: Translated using Weblate (Arabic)

Currently translated at 93.7% (241 of 257 strings)

Co-authored-by: joo es <johndevand@tutanota.com>
Translate-URL: https://translate.fedoraproject.org/projects/systemd/main/ar/
Translation: systemd/main
2025-04-29 09:31:26 +09:00
David Rheinsberg 8166075498 basic/time-util: fix error handling of clock_nanosleep()
`clock_nanosleep()` returns error codes directly, rather than using
`errno`. Ensure that we use those codes, rather than checking for `<0`.
2025-04-28 19:31:16 +02:00
Jelle van der Waa 2517262d17 ssh-generator: update argument comments 2025-04-28 17:20:13 +02:00
Jelle van der Waa 50829577ea network: update argument comments 2025-04-28 17:15:55 +02:00
Mike Yuan f0deccd0c5 socket-activate: various modernizations (#37267) 2025-04-28 14:28:22 +02:00
joo es 3e9c399465 po: Translated using Weblate (Arabic)
Currently translated at 50.1% (129 of 257 strings)

Co-authored-by: joo es <johndevand@tutanota.com>
Translate-URL: https://translate.fedoraproject.org/projects/systemd/main/ar/
Translation: systemd/main
2025-04-28 08:31:05 +09:00
Mike Yuan 93fcf15ae4 socket-activate: set up SIGCHLD handler only in --accept mode 2025-04-27 20:32:36 +02:00
Mike Yuan 3bff4701d8 socket-activate: signal READY=1 once sockets are open for --accept mode 2025-04-27 20:26:42 +02:00
Mike Yuan 8a157f78f2 socket-activate: clean up control flow a bit 2025-04-27 20:21:10 +02:00
Mike Yuan 0964b022fa socket-activate: remove effectively unused 'name' param for exec_process() 2025-04-27 20:21:10 +02:00
Mike Yuan 7e672795be socket-activate: drop arg_args
To follow our usual coding style.
2025-04-27 20:21:10 +02:00
Mike Yuan bce295ef00 journald-server: use generic NOTIFY_READY message 2025-04-27 20:21:09 +02:00
Yu Watanabe 531cf425e8 man/busctl: many other commands can take --json=/-j
Also, in a futre remaining commands may also support the option.
Let's not mention which command support the options.

Closes #37210.
2025-04-27 10:41:34 +09:00
Yu Watanabe 4db8663b81 tree-wide: fix typo 2025-04-27 10:36:12 +09:00
Yu Watanabe 905a89a219 udev: readjust priorities of event sources
Follow-up for 511619087b.

Notable changes are
- SIGTERM is the highest among others, to make not udevd queue too
  many events, as we need to serialize them anyway.
- device monitor has the second highest priority, to make 'remove'
  uevents received earlier than IN_IGNORED inotify events. Otherwise,
  after IN_IGNORED is received, if there is no queued event,
  /run/udev/queue file will be removed by the post-event source of the
  inotify event, and 'udevadm settle' or friends may wrongly finish,
  even we will soon queue 'remove' uevents for the device.
  This change should fix the recent instability of TEST-64-UDEV-STORAGE.

For other changes, see the comments in the code.
2025-04-27 09:47:07 +09:00
Yu Watanabe 5de236bd07 udev: do not remove /run/udev/queue file when we are synthesizing events
Note, it should be safe even if we synthesize no event, e.g. when the
device has been already removed. In such case, the post event after
SIGCHLD will remove the file.
2025-04-27 09:47:07 +09:00
Yu Watanabe 17b43e213b udev: try again to create /run/udev/queue when queueing the next event
This is mostly a paranoia, but if we failed to create /run/udev/queue
for some reasons on queueing an event, previously we would never create
the file until once the queue became empty. This makes in such case we
try to create the file again when queueing the next event.
2025-04-27 09:45:39 +09:00