Commit Graph

48239 Commits

Author SHA1 Message Date
Lennart Poettering 38abd1bfc5 Update TODO 2020-12-14 13:51:10 +01:00
Yu Watanabe 28423d9a75 tree-wide: fix typo 2020-12-14 12:05:55 +00:00
Ilya Dmitrichenko 65af8442df nspawn: remove outdated comment regarding bpffs
bpffs fully respects mount namespaces since kernel version 4.7

References:

- e27f4a942a
- 612bacad78
2020-12-14 10:50:42 +01:00
Yu Watanabe 8d80f27530 sd-device: make TAGS= property prefixed and suffixed with ":"
The commit 6f3ac0d517 drops the prefix and
suffix in TAGS= property. But there exists several rules that have like
`TAGS=="*:tag:*"`. So, the property must be always prefixed and suffixed
with ":".

Fixes #17930.
2020-12-14 14:04:53 +09:00
Yu Watanabe ba9385d91f
Merge pull request #17928 from keszybz/nss-logging
Enable logging in nss modules
2020-12-14 09:48:23 +09:00
Jameer Pathan 292420ce4b Add Pull Request Labeler 2020-12-14 09:43:38 +09:00
Vito Caputo 258190a0d5 mmap-cache: drop ret_size from mmap_cache_get()
The ret_size result is a bit of an awkward optimization that in a
sense enables bypassing the mmap-cache API, while encouraging
duplication of logic it already implements.

It's only utilized in one place; journal_file_move_to_object(),
apparently to avoid the overhead of remapping the whole object
again once its header, and thus its actual size, is known.

With mmap-cache's context cache, the overhead of simply
re-getting the object with the now known size should already be
negligible.  So it's not clear what benefit this brings, unless
avoiding some function calls that do very little in the hot
context-cache hit case is of such a priority.

There's value in having all object-sized gets pass through
mmap_cache_get(), as it provides a single entrypoint for
instrumentation in profiling/statistics gathering.  When
journal_file_move_to_object() bypasses getting the full object
size, you don't capture the full picture on the mmap-cache side
in terms of object sizes explicitly loaded from a journal file.

I'd like to see additional accounting in mmap_cache_get() in a
future commit, taking advantage of this change.
2020-12-13 11:14:43 +00:00
dropsignal 52fc66635d Update 60-keyboard.hwdb
added support for samsung series 3 np355v4c laptop keyboard
2020-12-13 10:49:46 +00:00
Khem Raj 5bb20fd3d3 meson: Fix reallocarray check
reallocarray() is defined in stdlib.h, so that would be right header to
check for its presense.

Signed-off-by: Khem Raj <raj.khem@gmail.com>
2020-12-13 09:44:29 +01:00
Zbigniew Jędrzejewski-Szmek 4eb105fa4a pid1: stop making /dev noexec
Quoting Andy Lutomirski:
> The upcoming Linux SGX driver has a device node /dev/sgx.  User code opens
> it, does various setup things, mmaps it, and needs to be able to create
> PROT_EXEC mappings.  This gets quite awkward if /dev is mounted noexec.

We already didn't use noexec in spawn, and this extends this behaviour to other
systems.

Afaik, the kernel would refuse execve() on a character or block device
anyway. Thus noexec on /dev matters only for actual binaries copied to /dev,
which requires root privileges in the first place.

We don't do noexec on either /tmp or /dev/shm (because that causes immediate
problems with stuff like Java and cffi). And if you have those two at your
disposal anyway, having noexec on /dev doesn't seem important. So the 'noexec'
attribute on /dev doesn't really mean much, since there are multiple other
similar directories which don't require root privileges to write to.

C.f. 33c10ef43b.
2020-12-12 10:56:48 +00:00
Karel Zak 25b514cd00 udev-builtin-blkid: add VOLUME_ID, LOGICAL_VOLUME_ID, VOLUME_SET_ID and DATA_PREPARER_ID
The new libblkid release will provide these variables. Let's keep is
accessible also from udev-db for the rest of the system.
2020-12-12 13:21:55 +09:00
Luca Boccassi 213b8ebe43
Merge pull request #17921 from yuwata/network-drop-assertion-17920
network: drop assertions to check link state in netlink callback handlers
2020-12-11 22:53:33 +00:00
Zbigniew Jędrzejewski-Szmek 5916c54a8d
Merge pull request #17935 from yuwata/network-fix-another-race-in-link-reconfigure-17929
network: do not reconfigure interface when the link gains carrier but udev not initialized it yet
2020-12-11 11:39:44 +01:00
Zbigniew Jędrzejewski-Szmek f8dd40779a
network: adjust comments
Co-authored-by: Carlo Teubner <435950+c4rlo@users.noreply.github.com>
2020-12-11 11:39:16 +01:00
Yu Watanabe bd4733da64 network: do not configure static configs more than once simultaneously 2020-12-11 14:39:46 +09:00
Yu Watanabe b788a429d1 network: do not assume address ready callback is always set to static addresses 2020-12-11 14:22:35 +09:00
Yu Watanabe b2219cc4b6 network: drop assertions to check link state in netlink callback handlers
As, the link may be dropped while configuring addresses or routes.

Fixes #17920.
2020-12-11 13:47:24 +09:00
Yu Watanabe 8bceafa777 network: do not reconfigure interface when the link gains carrier but udev not initialized it yet
When an interface gains carrier but udev have not initialized the
interface or link_initialized_handler() has not been called yet,
then link_configure will be called twice. Thus LLDP client will be
configured twice, and triggers assertion.

Fixes #17929.
2020-12-11 12:27:27 +09:00
Zbigniew Jędrzejewski-Szmek e5d5edc3ff nss-mymachines: initialize logging
No logging is done directly by nss-mymachines.c code, but we call into sd-bus,
which will log.
2020-12-10 20:52:03 +01:00
Zbigniew Jędrzejewski-Szmek 3339381f22 nss-systemd: initialize logging 2020-12-10 20:51:59 +01:00
Zbigniew Jędrzejewski-Szmek 55679e291c nss-resolve: initialize logging, log json errors
When the .so module is loaded, it gets a separate copy of stuff in src/basic,
including the log level variables. So any logging settings are unaffected by
the loading program calling log_parse_environment() or such. Let's also parse
the environment here so that we can have nice logging.

Initialization is done from each exported function, and pthread_once_t is used
to avoid duplicate initialization. I didn't merge PROTECT_ERRNO into
NSS_ENTRYPOINT_BEGIN because UNPROTECT_ERRNO is called in a bunch of places
and it would feel strange to have PROTECT_ERRNO hidden, but not UNPROTECT_ERRNO.

The most interesting stuff in this module is the varlink messages, and any
potential errors in json. So let's enable json logging when debug messages are
enabled.

With those changes, figuring out the issue in
https://github.com/systemd/systemd/pull/17823 is trivial:

$ LD_LIBRARY_PATH=build/ SYSTEMD_LOG_COLOR=1 SYSTEMD_LOG_LOCATION=1 SYSTEMD_LOG_LEVEL=debug getent hosts mirrors.fedoraproject.org
src/shared/varlink.c:237: n/a: varlink: setting state idle-client
src/shared/varlink.c:1240: n/a: Sending message: {"method":"io.systemd.Resolve.ResolveHostname","parameters":{"name":"mirrors.fedoraproject.org","family":10}}
src/shared/varlink.c:240: n/a: varlink: changing state idle-client → calling
src/shared/varlink.c:588: n/a: New incoming message: {"parameters":{"addresses":[{"ifindex":0,"family":10,"address":[42,5,208,20,0,16,120,3,247,116,77,124,226,119,164,87]},{"ifindex":0,"family":10,"address":[42,5,208,28,12,106,204,3,38,58,132,9,185,97,126,2]},{"ifindex":0,"family":10,"address":[38,32,0,82,0,3,0,1,222,173,190,239,202,254,254,215]},{"ifindex":0,"family":10,"address":[38,5,188,128,48,16,6,0,222,173,190,239,202,254,254,217]},{"ifindex":0,"family":10,"address":[38,4,21,128,254,0,0,0,222,173,190,239,202,254,254,209]},{"ifindex":0,"family":10,"address":[38,32,0,82,0,3,0,1,222,173,190,239,202,254,254,214]},{"ifindex":0,"family":10,"address":[38,16,0,40,48,144,48,1,222,173,190,239,202,254,254,211]},{"ifindex":0,"family":10,"address":[32,1,65,120,0,2,18,105,0,0,0,0,0,0,254,210]}],"name":"wildcard.fedoraproject.org","flags":1}}
src/shared/varlink.c:240: n/a: varlink: changing state calling → called
src/shared/varlink.c:240: n/a: varlink: changing state called → idle-client
src/nss-resolve/nss-resolve.c:84: (string):1:40: JSON field 'ifindex' is out of bounds for an interface index.
2020-12-10 20:50:01 +01:00
Jinyuan Si 239952e890 cryptsetup: Fix crypto device missing issue after bootup
Normally, the udev rules operate on "change" events. But when
coldplugging, there's an "add" event present. The udev rules have to
recognize this and do some actions in this particular situation, too.
Also, we don't want the nodes to be created prematurely on "add"
events while not coldplugging. The udev rules will check
DM_UDEV_PRIMARY_SOURCE_FLAG to see if the device was activated
correctly before and if not, it ignore the "add" event totally.
This way the udev rules can support udev triggers generating "add"
events (e.g. "udevadm trigger --action=add" or
"echo add > /sys/block/<dm_device>/uevent").

In this case, the udevd service is started after
systemd-cryptsetup@config.service, is started, which will cause udevd
service to miss the "change" uevent with DM_UDEV_PRIMARY_SOURCE_FLAG
flag generated by systemd-cryptsetup@config.service. To solve this
issue, we let the cryptsetup service be started after the udevd
service.
2020-12-10 20:46:00 +01:00
Lennart Poettering 4add63c79e
Merge pull request #17903 from yuwata/udev-options-log-level
udev: introduce OPTIONS="log_level=xxx" rule
2020-12-10 20:45:32 +01:00
Zbigniew Jędrzejewski-Szmek 3c94f71472 Drop compat "gateway" name
Back in 5248e7e1f1 (July 2017) we moved over to
"_gateway", with the old name declared to be temporary measure. Since we're
doing a bunch of changes to resolved now, it seems to be a good moment to make
this simplification and not add support for the compat name in new code.
2020-12-10 20:44:41 +01:00
Lennart Poettering 8374bf4fa2 veritysetup: also place udev socket dep
In light of #17848, also place udev socket dep in veritysetup, it's the
same issue after all.
2020-12-10 20:44:12 +01:00
Greg Depoire--Ferrer 6597686865 seccomp: don't install filters for archs that can't use syscalls
When seccomp_restrict_archs is called, architectures that are blocked
are replaced by the SECCOMP_LOCAL_ARCH_BLOCKED marker so that they are
not disabled again and filters are not installed for them.

This can make some service that use SystemCallArchitecture= and
SystemCallFilter= start faster.
2020-12-10 16:13:02 +01:00
Vito Caputo 104fc4be11 mmap-cache: bind prot(ection) to MMapFileDescriptor
There are no mmap_cache_get() users that actually deviate prot
from the JournalFile's f->prot.

So there's no point in making this a separate parameter to
mmap_cache_get(), nor is there any need to store it in
JournalFile's f->prot.

Instead just pass it to mmap_cache_add_fd() at MMapFileDescriptor
creation, storing it in there for the mmap() callers, which
already receive MMapFileDescriptor *.

For functions receiving both an MMapFileDescriptor * and prot,
the prot argument has been simply removed and call sites updated.

Formalizing this fd:prot binding at the public API also enables
discarding the prot check in window_matches(), which is a hot
function on long window lists, so a minor CPU efficiency gain
should be had there as seen with the past removal of the fd
check.  Unnoticable for uncached journals, but maybe a little
runtime improvement when cached in specific circumstances.

window_matches_fd() has also been simplified to treat the
MMapFileDescrptor * as equivalent to its fd and prot.
2020-12-10 13:03:31 +01:00
Lennart Poettering cca2da15c8 three spdx header fixes 2020-12-10 13:03:11 +01:00
Zbigniew Jędrzejewski-Szmek 1f568ba13f basic/static-destruct: fix grammar in comment 2020-12-10 13:00:14 +01:00
Zbigniew Jędrzejewski-Szmek d401a5e411 json: log location also when there is no file
E.g. in nss-resolve it is still useful to print the location of the error:
src/test/test-nss.c:231: dlsym(0x0x1dc6fb0, _nss_resolve_gethostbyname2_r) → 0x0x7fdbfc53f626
(string):1:40: JSON field ifindex is out of bounds for an interface index.

I opted to use a partially duplicated if condition to avoid nesting. It's nice
to have the log calls vertically aligned. The compiler will optimize this nicely.
2020-12-10 13:00:02 +01:00
Lennart Poettering 8620022f28
Merge pull request #17851 from yuwata/network-address-compare-func
network: revert previous changes to address_compare_func()
2020-12-10 10:43:47 +01:00
Vito Caputo 073f50a099 mmap-cache: separate context and window list cache hit accounting
Account and log these statistics separately since their overheads
are potentially quite different when the window lists are large.

There should probably be a histogram of window list traversal
counts too.
2020-12-10 10:23:01 +01:00
Zbigniew Jędrzejewski-Szmek 6bfbfce795 networkd-test: add final newlines in generated files, use .format() 2020-12-10 14:31:39 +09:00
Takashi Iwai 5926e592fa udev: Fix sound.target dependency
The recent bug report indicated a race at device creation and the
sound.target dependencies, and the cause turned out to be the condition
of the sound.target trigger.  Currently it's set for "card*", but this
is actually the parent object; i.e. the sound.target is triggered before
the sound devices are created.

For assuring the whole sound device creations beforehand, we need to use
"controlC*" instead of "card*"; as already described in
78-sound-card.rules, this is guaranteed to be the last device, and can
be used as a synchronization point.

BugLink: https://bugzilla.suse.com/show_bug.cgi?id=1179363
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-12-10 14:29:50 +09:00
Yu Watanabe 44cc6bfef0
Merge pull request #17877 from yuwata/missing-syscall-sort
missing: sort architectures in missing_syscall.h
2020-12-10 12:42:35 +09:00
Yu Watanabe 563a94d080 man: mention new OPTIONS=log_level= udev rule 2020-12-10 12:33:34 +09:00
Yu Watanabe 1a0bd01529 udev: introduce new OPTIONS="log_level=" udev rule 2020-12-10 12:31:45 +09:00
Yu Watanabe b2d9e58f78 udev: introduce log_device_uevent() helper function
And this drops duplicated check for seqnum and device action.
2020-12-10 12:26:19 +09:00
Yu Watanabe 481f24d1f6 udev: drop meaningless size optimization
These objects are not allocated multiple times simultaneously per
single process.
2020-12-10 12:18:30 +09:00
Lennart Poettering 19d43808bd
Merge pull request #17869 from DaanDeMeyer/mkosi-gdb
mkosi: Add gdb to final images
2020-12-09 21:09:59 +01:00
Lennart Poettering 733558adef
Merge pull request #17884 from poettering/test-dlopen
tests: add test that dlopen()s our weak shared library deps once
2020-12-09 21:09:33 +01:00
Franck Bui 4e1db59274 udev: link_update() should fail if the entry in symlink dir couldn't have been created
Follow-up for 30f6dce62c
2020-12-09 21:08:53 +01:00
Lennart Poettering 5e3effb1f3 virt: drop /proc/1/sched hack
On really old kernels (< 4.14+) a bug in /proc/1/sched handling in the
kernel could be used to determine whether we are running in a PID
namespace. This hasn't worked for a long time, and there's little point
in making things work on old kernels we can't make work on current
kernels, hence let's drop that old cruft.

See: #8153
2020-12-09 21:07:46 +01:00
Daan De Meyer c6ab308767 mkosi: Add strace to final images
Useful for debugging purposes.
2020-12-09 17:34:45 +00:00
Daan De Meyer ae4f44a94e mkosi: Add gdb to final images
Let's add a debugger to the mkosi images so we can debug coredumps
from inside mkosi qemu VMs (and hopefully in the future from
mkosi systemd-nspawn containers as well).
2020-12-09 17:30:41 +00:00
Lennart Poettering 1c36b8bf53 log: add helper set sets log level in all realms
Prompted-by: #17903
2020-12-09 18:26:17 +01:00
Lennart Poettering eef34a1d8f man: document that automount units are privileged
Fixes: #17886
2020-12-09 18:25:32 +01:00
Luca Boccassi 0727a75a3b
Merge pull request #17911 from yuwata/log-cli-program-use-journal
log: open journal when cli program run in a service unit
2020-12-09 14:30:32 +00:00
Luca Boccassi 141d3a14d4
Merge pull request #17882 from poettering/logind-async-close
logind: fix closing of button input devices
2020-12-09 14:27:03 +00:00
Daan De Meyer ecd3c86b60 Silence cgroups v1 read-only filesystem warning
Avoid warning messages when booting systemd-nspawn containers and using
hybrid or legacy cgroups. systemd-nspawn mounts the cgroups v1 controller
tree as read-only so these errors are expected and not problematic.
Partially fixes #17862.

Test plan:

- Before: `mkosi --default .mkosi/mkosi.fedora boot`

```
‣ Processing default...
Spawning container image on /home/daan/projects/systemd/image.raw.
Press ^] three times within 1s to kill container.
systemd 247 running in system mode. (+PAM +AUDIT +SELINUX -APPARMOR +IMA +SMACK +SECCOMP +GCRYPT +GNUTLS +OPENSSL +ACL +BLKID +CURL +ELFUTILS +FIDO2 +IDN2 -IDN +IPTC +KMOD +LIBCRYPTSETUP +LIBFDISK +PCRE2 +PWQUALITY +P11KIT +QRENCODE +BZIP2 +LZ4 +XZ +ZLIB +ZSTD +XKBCOMMON +UTMP +SYSVINIT default-hierarchy=unified)
Detected virtualization systemd-nspawn.
Detected architecture x86-64.

Welcome to Fedora 33 (Thirty Three)!

Queued start job for default target Graphical Interface.
-.slice: Failed to migrate controller cgroups from , ignoring: Read-only file system
system.slice: Failed to delete controller cgroups /system.slice, ignoring: Read-only file system
[  OK  ] Created slice system-getty.slice.
[  OK  ] Created slice system-modprobe.slice.
user.slice: Failed to delete controller cgroups /user.slice, ignoring: Read-only file system
[  OK  ] Created slice User and Session Slice.
[  OK  ] Started Dispatch Password Requests to Console Directory Watch.
[  OK  ] Started Forward Password Requests to Wall Directory Watch.
[  OK  ] Reached target Local Encrypted Volumes.
[  OK  ] Reached target Paths.
[  OK  ] Reached target Remote File Systems.
[  OK  ] Reached target Slices.
[  OK  ] Reached target Swap.
[  OK  ] Listening on Process Core Dump Socket.
[  OK  ] Listening on initctl Compatibility Named Pipe.
[  OK  ] Listening on Journal Socket (/dev/log).
[  OK  ] Listening on Journal Socket.
[  OK  ] Listening on User Database Manager Socket.
dev-hugepages.mount: Failed to delete controller cgroups /dev-hugepages.mount, ignoring: Read-only file system
         Mounting Huge Pages File System...
sys-fs-fuse-connections.mount: Failed to delete controller cgroups /sys-fs-fuse-connections.mount, ignoring: Read-only file system
         Mounting FUSE Control File System...
         Starting Journal Service...
         Starting Remount Root and Kernel File Systems...
system.slice: Failed to delete controller cgroups /system.slice, ignoring: Read-only file system
```

After: `mkosi --default .mkosi/mkosi.fedora boot`

```
‣ Processing default...
Spawning container image on /home/daan/projects/systemd/mkosi.output/image.raw.
Press ^] three times within 1s to kill container.
systemd 247 running in system mode. (+PAM +AUDIT +SELINUX -APPARMOR +IMA +SMACK +SECCOMP +GCRYPT +GNUTLS +OPENSSL +ACL +BLKID +CURL +ELFUTILS +FIDO2 +IDN2 -IDN +IPTC +KMOD +LIBCRYPTSETUP +LIBFDISK +PCRE2 +PWQUALITY +P11KIT +QRENCODE +BZIP2 +LZ4 +XZ +ZLIB +ZSTD +XKBCOMMON +UTMP +SYSVINIT default-hierarchy=unified)
Detected virtualization systemd-nspawn.
Detected architecture x86-64.

Welcome to Fedora 33 (Thirty Three)!

Queued start job for default target Graphical Interface.
[  OK  ] Created slice system-getty.slice.
[  OK  ] Created slice system-modprobe.slice.
[  OK  ] Created slice User and Session Slice.
[  OK  ] Started Dispatch Password Requests to Console Directory Watch.
[  OK  ] Started Forward Password Requests to Wall Directory Watch.
[  OK  ] Reached target Local Encrypted Volumes.
[  OK  ] Reached target Paths.
[  OK  ] Reached target Remote File Systems.
[  OK  ] Reached target Slices.
[  OK  ] Reached target Swap.
[  OK  ] Listening on Process Core Dump Socket.
[  OK  ] Listening on initctl Compatibility Named Pipe.
[  OK  ] Listening on Journal Socket (/dev/log).
[  OK  ] Listening on Journal Socket.
[  OK  ] Listening on User Database Manager Socket.
         Mounting Huge Pages File System...
         Mounting FUSE Control File System...
         Starting Journal Service...
         Starting Remount Root and Kernel File Systems...
[  OK  ] Mounted Huge Pages File System.
[  OK  ] Mounted FUSE Control File System.
[  OK  ] Finished Remount Root and Kernel File Systems.
         Starting Create Static Device Nodes in /dev...
[  OK  ] Finished Create Static Device Nodes in /dev.
[  OK  ] Reached target Local File Systems (Pre).
[  OK  ] Reached target Local File Systems.
         Starting Restore /run/initramfs on shutdown...
[  OK  ] Finished Restore /run/initramfs on shutdown.
[  OK  ] Started Journal Service.
         Starting Flush Journal to Persistent Storage...
[  OK  ] Finished Flush Journal to Persistent Storage.
         Starting Create Volatile Files and Directories...
[  OK  ] Finished Create Volatile Files and Directories.
         Starting Network Name Resolution...
         Starting Update UTMP about System Boot/Shutdown...
[  OK  ] Finished Update UTMP about System Boot/Shutdown.
[  OK  ] Reached target System Initialization.
[  OK  ] Started Daily Cleanup of Temporary Directories.
[  OK  ] Reached target Timers.
[  OK  ] Listening on D-Bus System Message Bus Socket.
[  OK  ] Reached target Sockets.
[  OK  ] Reached target Basic System.
         Starting Home Area Manager...
         Starting User Login Management...
         Starting Permit User Sessions...
[  OK  ] Finished Permit User Sessions.
[  OK  ] Started Console Getty.
[  OK  ] Reached target Login Prompts.
         Starting D-Bus System Message Bus...
[  OK  ] Started D-Bus System Message Bus.
[  OK  ] Started Home Area Manager.
[  OK  ] Started User Login Management.
[  OK  ] Reached target Multi-User System.
[  OK  ] Reached target Graphical Interface.
         Starting Update UTMP about System Runlevel Changes...
[  OK  ] Finished Update UTMP about System Runlevel Changes.
[  OK  ] Started Network Name Resolution.
[  OK  ] Reached target Host and Network Name Lookups.

Fedora 33 (Thirty Three) (built from systemd tree)
Kernel 5.9.11-arch2-1 on an x86_64 (console)
```
2020-12-09 12:37:16 +00:00