New directives NoExecPaths= ExecPaths=

Implement directives `NoExecPaths=` and `ExecPaths=` to control `MS_NOEXEC`
mount flag for the file system tree. This can be used to implement file system
W^X policies, and for example with allow-listing mode (NoExecPaths=/) a
compromised service would not be able to execute a shell, if that was not
explicitly allowed.

Example:
[Service]
NoExecPaths=/
ExecPaths=/usr/bin/daemon /usr/lib64 /usr/lib

Closes: #17942.
This commit is contained in:
Topi Miettinen
2021-01-29 12:40:52 +00:00
committed by Topi Miettinen
parent 78dff3f3d7
commit ddc155b2fd
15 changed files with 240 additions and 37 deletions
@@ -85,6 +85,7 @@ DirectoryMode=
DirectoryNotEmpty=
Documentation=
DynamicUser=
ExecPaths=
ExecReload=
ExecCondition=
ExecStart=
@@ -147,6 +148,7 @@ MessageQueueMaxMessages=
MessageQueueMessageSize=
MountAPIVFS=
NoDelay=
NoExecPaths=
NoNewPrivileges=
NonBlocking=
NotifyAccess=