Commit Graph

5145 Commits

Author SHA1 Message Date
Lennart Poettering
32e7970304 Merge pull request #26800 from t-8ch/memfd_create
memfd: add support for exec flags
2023-03-15 09:28:09 +01:00
Lennart Poettering
264c267686 Merge pull request #26794 from bluca/log_extra_fields
core: append LogExtraFields= values to log_unit* messages
2023-03-15 09:27:47 +01:00
Thomas Weißschuh
c29715a8f7 treewide: memfd_create: use exec flags
Use the flags MEMFD_EXEC or MEMFD_NOEXEC_SEAL as applicable.

These warnings instruct the kernel wether the memfd is executable or
not.

Without specifying those flags the kernel will emit the following
warning since version 6.3,
commit 105ff5339f49 ("mm/memfd: add MFD_NOEXEC_SEAL and MFD_EXEC"):

    kernel: memfd_create() without MFD_EXEC nor MFD_NOEXEC_SEAL, pid=1 'systemd'
2023-03-15 01:18:59 +00:00
Thomas Weißschuh
ad62530ebb memfd-util: add wrapper for memfd_create
The wrapper removes the flags MFD_EXEC and MFD_NOEXEC_SEAL when running
on kernels not understanding those flags.
2023-03-15 01:18:59 +00:00
Thomas Weißschuh
8cb0a001d8 missing: add memfd exec flags 2023-03-15 01:18:59 +00:00
Luca Boccassi
2461943b84 log: add iov helpers for log_context 2023-03-14 16:37:03 +00:00
Lennart Poettering
b6904196a6 namespace-util: set mounts back to MS_SHARED in detach_mount_namespace()
For nspawn and services we first turn off two-way propagation of mounts
from host to sandbox via MS_SLAVE, and then set MS_SHARED again, so that
we create a new mount prop peer group again, and that we provide
behaviour similar to what we provide on the host further down the tree.

Let's do the same in detach_mount_namespace(), which we use for the
temporary mounts in the implementation of --image= in various tools.

This doesn't fix any immediate issue, but ensures we expose somewhat
systematic behaviour: whenever we detach mount namespaces we always set
things back to MS_SLAVE in the child.
2023-03-14 13:02:51 +09:00
Topi Miettinen
7a114ed4b3 execute: use prctl(PR_SET_MDWE) for MemoryDenyWriteExecute=yes
On some ARM platforms, the dynamic linker could use PROT_BTI memory protection
flag with `mprotect(..., PROT_BTI | PROT_EXEC)` to enable additional memory
protection for executable pages. But `MemoryDenyWriteExecute=yes` blocks this
with seccomp filter denying all `mprotect(..., x | PROT_EXEC)`.

Newly preferred method is to use prctl(PR_SET_MDWE) on supported kernels. Then
in-kernel implementation can allow PROT_BTI as necessary, without weakening
MDWE. In-kernel version may also be extended to more sophisticated protections
in the future.
2023-03-13 18:44:36 +00:00
Yu Watanabe
cbcdc582f3 Merge pull request #26749 from DaanDeMeyer/more-cleanups
execute: Some modernizations
2023-03-14 03:34:37 +09:00
Franck Bui
07e0ffc823 conf: replace config_parse_many_nulstr() with config_parse_config_file()
All daemons use a similar scheme to read their main config files and theirs
drop-ins. The main config files are always stored in /etc/systemd directory and
it's easy enough to construct the name of the drop-in directories based on the
name of the main config file.

Hence the new helper does that internally, which allows to reduce and simplify
the args passed previously to config_parse_many_nulstr().

Besides the overall code simplification it results:

  16 files changed, 87 insertions(+), 159 deletions(-)

it allows to identify clearly the locations in the code where configuration
files are parsed.
2023-03-14 03:31:21 +09:00
Daan De Meyer
846c9c12e7 lock-util: Add posix_lock()
POSIX locks with the same interface as flock().
2023-03-13 13:04:08 +01:00
Yu Watanabe
37c6a3dc1a time-util: add note about on DST change 2023-03-13 04:43:51 +09:00
Yu Watanabe
bd5770da76 time-util: make USEC_TIMESTAMP_FORMATTABLE_MAX for 32bit system off by one day
As the same reason why we take one day off for 64bit case.

This also makes both upper bounds always defined for testing.
2023-03-13 04:43:19 +09:00
Yu Watanabe
c9501b03cd Merge pull request #26641 from medhefgo/boot-elf2efi
boot: Drop gnu-efi / Add elf2efi.py
2023-03-11 17:15:01 +09:00
Daan De Meyer
aa41079175 Merge pull request #26726 from DaanDeMeyer/cleanups
Various small cleanups
2023-03-10 14:22:53 +01:00
Lennart Poettering
d0ed83f3ae Merge pull request #26737 from poettering/runtime-scope
add RuntimeScope enum, replacing LookupScope and various booleans indicating whether we are called in a per-system or per-user context
2023-03-10 13:09:40 +01:00
Daan De Meyer
37c485482f lock-util: Use unposix_lock() in make_lock_file() and release_lock_file() 2023-03-10 11:57:43 +01:00
Daan De Meyer
460accdf3d user-util: Use unposix_lock() in take_etc_passwd_lock() 2023-03-10 11:57:43 +01:00
Daan De Meyer
4dd888dc92 lock-util: Move to src/basic 2023-03-10 11:57:43 +01:00
Jan Janssen
9214828313 meson: Introduce userspace dep
This will help in a later commit to separate userspace from EFI builds.
2023-03-10 11:40:14 +01:00
Lennart Poettering
f69edd6faf Merge pull request #26331 from ddstreet/tpm2_pcr_read
Tpm2 pcr read
2023-03-10 10:24:39 +01:00
Lennart Poettering
40d73340fa runtime-scope: add helper that turns RuntimeScope enum into --system/--user string 2023-03-10 09:47:58 +01:00
Lennart Poettering
4870133bfa basic: add RuntimeScope enum
In various tools and services we have a per-system and per-user concept.
So far we sometimes used a boolean indicating whether we are in system
mode, or a reversed boolean indicating whether we are in user mode, or
the LookupScope enum used by the lookup path logic.

Let's address that, in introduce a common enum for this, we can use all
across the board.

This is mostly just search/replace, no actual code changes.
2023-03-10 09:47:39 +01:00
Lennart Poettering
5f64d2bf33 socket-util: fix socket_get_family()
Function didn't actually return anything useful. Quite a shame.
2023-03-10 09:36:18 +01:00
Lennart Poettering
96c96fb250 Merge pull request #26704 from poettering/mnt-nosymlinks
Set MS_NOSYMFOLLOW for ESP + XBOOTLDR and many mount option clean-ups
2023-03-10 09:34:04 +01:00
Lennart Poettering
92c6f73cc5 fd-util: move ACQUIRE_NO_XYZ flags to the header the function using them is in
Follow-up for: b25a930f0e
2023-03-09 22:56:30 +01:00
Lennart Poettering
a617007417 mempress: change default PSI window duration to 2s
This changes the PSI window duration we default to for watching memory
pressure events from 1s to 2s. This is because apparently the kernel
will soon disallow window durations other than 2s for unprivileged
processes.

Hence, we'll bump the threshold from 100m to 200ms, and the window from
1s to 2s.
2023-03-09 22:31:20 +01:00
Lennart Poettering
e1349c045e mountpoint-util: add comment explaining why fstype_can_discard() can't use mount_option_supported() 2023-03-09 21:56:42 +01:00
Lennart Poettering
6eda6f7e51 mountpoint-util: add new fstype_can_umask() helper 2023-03-09 21:56:42 +01:00
Lennart Poettering
034ebc47a2 mountpoint-util: move 'norecovery' detection into its own helper call
And let's also ask the kernel explicitly for support.
2023-03-09 21:56:42 +01:00
Lennart Poettering
4e6d305ae2 mountpoint-util: use mount_option_supported() to detect if 'discard' is support for an fs 2023-03-09 21:56:42 +01:00
Lennart Poettering
117e703447 mountpoint-util: generalize mount_option_supported() 2023-03-09 21:56:42 +01:00
Lennart Poettering
7d3b157b77 mountpoint-util: add helper that checks if MS_NOSYMFOLLOW is supported 2023-03-09 16:14:29 +01:00
Lennart Poettering
c115e1615b missing: add more defines to fsopen() definitions 2023-03-09 16:13:42 +01:00
Lennart Poettering
34a9da0d8e missing: add fsmount() syscall fallback definition 2023-03-09 16:12:37 +01:00
Dan Streetman
33d9beed07 basic/bitfield: add bitfield operations
Add macros to manage bits in a bitfield (e.g. uint32_t, uint64_t, etc),
such as setting, clearing, checking bits, and iterating all set bits.

These are similiar to the bitmap operations, but operate on basic types
instead of requiring a Bitmap object.
2023-03-09 09:58:32 -05:00
Daan De Meyer
44777d7ad6 memfd-util: Add memfd_new_and_seal() 2023-03-09 13:46:55 +01:00
Dan Streetman
e179f2d89c basic/macro: add macro to iterate variadic args 2023-03-09 07:11:04 -05:00
Yu Watanabe
b9872fe1dd macro: support the case that the number of elements has const qualifier
Follow-up for 5716c27e1f.

Addresses https://github.com/systemd/systemd/pull/26303#issuecomment-1460712007.
2023-03-09 08:41:43 +01:00
Luca Boccassi
2ca6f09b30 Merge pull request #26656 from yuwata/mkdir-error-code
mkdir: fix error code
2023-03-08 21:23:07 +00:00
Zbigniew Jędrzejewski-Szmek
ad078f59fa Merge pull request #26678 from yuwata/foreach_array
macro: introduce FOREACH_ARRAY() macro
2023-03-08 19:06:20 +01:00
Jan Engelhardt
18fe76eba5 doc: correct wrong use "'s" contractions 2023-03-07 13:39:31 +01:00
Yu Watanabe
9d0d39ee53 conf-files: fix potential memleak in conf_files_list_strv_internal() on failure
This also changes the used hash_ops from path_hash_ops to
string_hash_ops, as the key is not a path, but a filename.
2023-03-07 18:43:34 +09:00
Yu Watanabe
5716c27e1f macro: introduce FOREACH_ARRAY() macro
The pattern that runs all array element is quite common.
But, sometimes, the number of element may be in a signed integer, or the
array may be NULL.
2023-03-07 13:27:16 +09:00
Luca Boccassi
df40b7ef5a Merge pull request #26686 from yuwata/iovec
tree-wide: replace IOVEC_INIT with IOVEC_MAKE
2023-03-06 21:00:04 +00:00
Luca Boccassi
db73b9d2ab Merge pull request #26502 from DaanDeMeyer/chase-symlinks-additions
Several chase_symlinks() additions
2023-03-06 20:51:06 +00:00
Luca Boccassi
52bdfbf7d7 Merge pull request #26687 from yuwata/c2x
C2X support
2023-03-06 20:50:17 +00:00
Yu Watanabe
84d0dc53ac time-util: drop redundant call of tzset()
It is also called at the beginning of `parse_timestamp_maybe_with_tz()`.
2023-03-06 20:39:37 +00:00
Daan De Meyer
9a98c0f2b1 chase-symlinks: Add chase_symlinks_at_and_open() 2023-03-06 13:53:01 +01:00
Daan De Meyer
e864dfa671 chase-symlinks: Add CHASE_MKDIR_0755 2023-03-06 13:42:43 +01:00