Commit Graph

81277 Commits

Author SHA1 Message Date
Yu Watanabe
ef12eadfc8 core/bpf: drop old kernels support (#37151) 2025-05-10 03:13:42 +09:00
Yu Watanabe
b112a676d5 udev: several cleanups for managing events (#37384)
Mostly no functional changes, just refactoring.
2025-05-10 02:30:25 +09:00
Luca Boccassi
b6c3fc750a boot: skip shim-specific logic when running with new shim
Since shim 16 the plain BS->LoadImage() will just work (TM), we do not need
anymore to set up manual overrides and manually call in the shim-specific
lock protocol or to set shim-specific EFIVAR to make addons work or to load
shim-signed kernels.

Check if the new protocol added in v16 is present, and if so, skip
all that. Once versions < 16 are no longer supported/revoked, all
the code can be dropped entirely.
2025-05-09 17:07:14 +01:00
Yu Watanabe
dcd2ad2314 udev: move error handling in event_requeue() to caller
Also, remove udev database on failure.
2025-05-10 00:26:32 +09:00
Yu Watanabe
f694a527ac udev: split out device_broadcast_on_error() 2025-05-10 00:26:32 +09:00
Yu Watanabe
e969ec1d51 sd-device: rename arguments
To make it consistent with its declaration and other function
prototypes.
2025-05-10 00:26:32 +09:00
Yu Watanabe
dc231d66ac udev: move timeout event sources from struct Event to struct Worker
The timeout event sources are enabled only when the event is being
processed by a worker, hence they are not necessary to be owned by the
event.

No effective functional change, just refactoring.
2025-05-10 00:26:32 +09:00
Yu Watanabe
e1ae931064 udev: list up all dependencies of an event when the first time it is examined
No functional change, just refactoring.
2025-05-10 00:26:32 +09:00
Yu Watanabe
0cde671c29 udev: check earlier if there is a free room for processing an event 2025-05-10 00:26:32 +09:00
Yu Watanabe
4478546649 udev: cache last queued event entry
When we have N queued events, LIST_APPEND() takes O(N).
Let's cache the last event to optimize queueing.
2025-05-10 00:26:32 +09:00
Yu Watanabe
e962ebbe72 udev: introduce event_freep() and use it as cleanup attribute
No functional change, just refactoring and preparation for later change.
2025-05-10 00:26:32 +09:00
Daan De Meyer
180ea8b3ab More header cleanups (#37381) 2025-05-09 17:22:33 +02:00
Yu Watanabe
7ded1bcf04 test: allow to allocate test scope even running with unprivileged user 2025-05-10 00:17:52 +09:00
Yu Watanabe
ad446c8ceb core/bpf-devices: use bpf_program_supported()
Note, BPF_PROG_TYPE_CGROUP_DEVICE is supported since kernel v4.15.
As our baseline on the kernel is v5.4, we can assume the bpf type is
always supported.
2025-05-10 00:17:52 +09:00
Yu Watanabe
ec3c5cfac7 core/bpf-firewall: replace bpf_firewall_supported() with bpf_program_supported()
Note, BPF_PROG_TYPE_CGROUP_SKB is supported since kernel v4.10, and
BPF_F_ALLOW_MULTI and program name is supported since kernel v4.15.
As our baseline on the kernel is v5.4, we can assume that the type,
flag, and naming is supported when bpf_program_supported() succeeds.
2025-05-10 00:17:52 +09:00
Yu Watanabe
22e2f06428 core/cgroup: foreign bpf programs needs to pass bpf_program_supported()
As CONFIG_CGROUP_BPF may be disabled on the kernel or we are running on
sanitizers. See comments in bpf_program_supported().

Follow-up for 3fcb98cbff.
2025-05-10 00:17:52 +09:00
Yu Watanabe
71be1f3875 bpf-program: introduce bpf_program_supported() helper function
It checks if the kernel is built with CONFIG_CGROUP_BPF.
It is currently unused, but will be used later.
2025-05-10 00:17:52 +09:00
Yu Watanabe
df80d728be bpf-compat: drop unused compat_libbpf_probe_bpf_prog_type() 2025-05-10 00:17:52 +09:00
Yu Watanabe
fb9991962d core/bpf: drop unnecessary check for probing program type
BPF_PROG_TYPE_CGROUP_SKB is supported since kernel v4.10
(0e33661de493db325435d565a4a722120ae4cbf3) and
BPF_PROG_TYPE_CGROUP_SOCK_ADDR is supported since kernel v4.17
(4fbac77d2d092b475dda9eea66da674369665427).

Our baseline on the kernel is v5.4. The check is not necessary.
2025-05-10 00:17:52 +09:00
Yu Watanabe
4d2b9abbe1 core: replace cgroup_bpf_supported() with dlopen_bpf_full()
After 3988e2489a, the function is a simple
wrapper of bpf_dlopen() with logging. Let's introduce dlopen_bpf_full()
that takes log level, and replace cgroup_bpf_supported() with it.
2025-05-10 00:17:52 +09:00
Yu Watanabe
e06e34a3b6 udev: replace get_user/group_creds() with userdb/groupdb_by_name() (#37304)
This also makes networkd not refuse User=/Group=root.
2025-05-09 20:54:16 +09:00
Kurt Borja
15450ba214 hwdb: keyboard: Add Alienware special keys
Add Alienware *Performance mode* toggle key and *Macro* keys.

Signed-off-by: Kurt Borja <kuurtb@gmail.com>
2025-05-09 20:42:00 +09:00
Marcos Alano
fb8149234a Add emulated release to G-Mode key 2025-05-09 20:41:45 +09:00
Daan De Meyer
5f142e01d0 strv: Move STRV_FOREACH() to strv-fundamental.h 2025-05-09 11:33:33 +02:00
Daan De Meyer
56c710ce37 alloc-util: Remove unneeded stdlib.h include 2025-05-09 11:33:33 +02:00
Daan De Meyer
2782dae50f compress: Drop lz4 includes from compress.h
The lz4 functions are only used in test-compress.c, so let's just
put the declarations and includes in there instead of having everyone
including compress.h pull in the lz4 headers.
2025-05-09 11:33:33 +02:00
Daan De Meyer
7227d5bfff terminal-util: Move various functions to ansi-color.c 2025-05-09 11:33:33 +02:00
Daan De Meyer
c992250c24 basic: Move parts of audit-util.{c,h} to libaudit-util.{c,h} in shared/ 2025-05-09 11:33:33 +02:00
Daan De Meyer
3b7d332047 macro: Reduce transitive includes 2025-05-09 11:33:31 +02:00
Daan De Meyer
3b58245624 basic: Override glibc's sys/param.h header with an empty file
Instead of unconditionally including sys/param.h in
macro-fundamental.h which itself includes a bunch of other unnecessary
headers, let's override it with an empty file to avoid it from overriding
our MAX() macro. We can't make including it an error as it's included (
for seemingly no good reason) by <resolv.h>.
2025-05-09 11:23:14 +02:00
Yu Watanabe
37c8a03ebf udevadm-info: parse all arguments before doing anything (#37292) 2025-05-09 14:09:45 +09:00
David Tardon
6cdc63d120 udevadm-info: use string table to parse query type 2025-05-09 12:14:21 +09:00
David Tardon
4ef3019ceb udevadm-info: drop args of stat_device()
They are all static vars now, so can be used directly.
2025-05-09 12:14:21 +09:00
David Tardon
8ea3c1fb9e udevadm-info: shorten the code a bit 2025-05-09 12:14:21 +09:00
David Tardon
31767b92a0 udevadm-info: reject devices passed via opts too
Follow-up-for a6b4b2fa01
2025-05-09 12:14:21 +09:00
David Tardon
d89b3004da udevadm-info: split arg. parsing into a separate function 2025-05-09 12:14:16 +09:00
David Tardon
86ff972ac3 udevadm-info: drop superfluous pager_open() call
It's already called in advance in info_main().
2025-05-09 12:10:51 +09:00
David Tardon
5b4d73208e udevadm-info: make arg_pager_flags static 2025-05-09 12:10:51 +09:00
David Tardon
cb3f6c9e0d udevadm-info: move static dtor closer to args 2025-05-09 12:10:51 +09:00
Yu Watanabe
0c93e66386 udev: use userdb_by_name()/groupdb_by_name()
Prompted by https://github.com/systemd/systemd/pull/37294#discussion_r2068141968.
2025-05-09 12:10:28 +09:00
Yu Watanabe
e4d07d1a2d userdb: introduce USERDB_SYNTHESIZE_NUMERIC flag
When the flag is set, even if the specified UID/GID does not exist,
create a synthetic user record for the UID/GID.
Currently, only system UID/GID are supported.
2025-05-09 12:10:28 +09:00
Yu Watanabe
6d30c11a0a network/tuntap: allow to specify root to User=/Group=
Follow-up for 940441b44c.

With the commit, User=/Group=root was refused and warned that the root
is not a system user. Typically it is not necessary to specify such, but
let's not log confusing warning and honor the setting.
2025-05-09 12:10:28 +09:00
Yu Watanabe
6377f40d26 user-record: introduce USERDB_MATCH_ROOT_AND_SYSTEM
It may be useful when we want to resolve root and system user/group
but want to refuse nobody user/group.
2025-05-09 12:10:28 +09:00
Yu Watanabe
4dcc308fba userdb: introduce user/group_record_buildo() helper macros 2025-05-09 12:10:28 +09:00
Yu Watanabe
64fc712fe7 user-util,user-record-nss: initialize buffer before calling getpwnam_r() and friends
The buffer will be used by a library outside of our code base,
and may not be initialized even on success. Let's initialize
them for safety.

Hopefully fixes the following fuzzer warning:
```
==2039==WARNING: MemorySanitizer: use-of-uninitialized-value
    #0 0x7f9ad8be3ae6 in _nss_files_getsgnam_r (/lib/x86_64-linux-gnu/libnss_files.so.2+0x8ae6) (BuildId: 013bf05b4846ebbdbebdb05585acc9726c2fabce)
    #1 0x7f9ad93e5902 in getsgnam_r (/lib/x86_64-linux-gnu/libc.so.6+0x126902) (BuildId: 0323ab4806bee6f846d9ad4bccfc29afdca49a58)
    #2 0x7f9ad9b98153 in nss_sgrp_for_group /work/build/../../src/systemd/src/shared/user-record-nss.c:357:21
    #3 0x7f9ad9b98926 in nss_group_record_by_gid /work/build/../../src/systemd/src/shared/user-record-nss.c:431:21
    #4 0x7f9ad9bcebd7 in groupdb_by_gid_fallbacks /work/build/../../src/systemd/src/shared/userdb.c:1372:29

  Uninitialized value was created by a heap allocation
    #0 0x556fd5294302 in malloc /src/llvm-project/compiler-rt/lib/msan/msan_interceptors.cpp:1021:3
    #1 0x7f9ad9b9811d in nss_sgrp_for_group /work/build/../../src/systemd/src/shared/user-record-nss.c:353:23
    #2 0x7f9ad9b98926 in nss_group_record_by_gid /work/build/../../src/systemd/src/shared/user-record-nss.c:431:21
    #3 0x7f9ad9bcebd7 in groupdb_by_gid_fallbacks /work/build/../../src/systemd/src/shared/userdb.c:1372:29
```
2025-05-09 12:10:28 +09:00
Yu Watanabe
1e35d21ab0 udevadm-trigger: parse all arguments before doing anything (#37293) 2025-05-09 12:09:18 +09:00
Yu Watanabe
fe927f3dbb udev: enable kill workers timer when processing events stopped (#37382)
This also extends test cases for
`udevadm control --start-exec-queue/--stop-exec-queue`.
2025-05-09 10:42:48 +09:00
David Tardon
a63822a7e3 udevadm-trigger: use string table to parse scan type 2025-05-09 09:54:27 +09:00
David Tardon
bc995d6764 udevadm-trigger: add prefix to enumeration values 2025-05-09 09:54:27 +09:00
David Tardon
a07f40e264 udevadm-trigger: replace home-made key/value splitting function 2025-05-09 09:54:25 +09:00