execute: use prctl(PR_SET_MDWE) for MemoryDenyWriteExecute=yes
authorTopi Miettinen <toiwoton@gmail.com>
Sun, 6 Nov 2022 19:12:45 +0000 (21:12 +0200)
committerTopi Miettinen <topimiettinen@users.noreply.github.com>
Mon, 13 Mar 2023 18:44:36 +0000 (18:44 +0000)
commit7a114ed4b39e9670f6a511f3eecb6fd58274d27b
tree72914d8845216087ad2983e13ce036c0518ba205
parentcbcdc582f3b219818728e81ccfc443790fafbdff
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.
man/systemd.exec.xml
src/basic/missing_prctl.h
src/core/execute.c