From 40652ca4791fc3ae8f55c74b16227c0682b287b9 Mon Sep 17 00:00:00 2001 From: Topi Miettinen Date: Wed, 8 Jun 2016 12:23:37 +0000 Subject: units: enable MemoryDenyWriteExecute (#3459) Secure daemons shipped by systemd by enabling MemoryDenyWriteExecute. Closes: #3459 --- units/systemd-timesyncd.service.in | 1 + 1 file changed, 1 insertion(+) (limited to 'units/systemd-timesyncd.service.in') diff --git a/units/systemd-timesyncd.service.in b/units/systemd-timesyncd.service.in index a856dad709..caf1dc132f 100644 --- a/units/systemd-timesyncd.service.in +++ b/units/systemd-timesyncd.service.in @@ -28,6 +28,7 @@ PrivateDevices=yes ProtectSystem=full ProtectHome=yes WatchdogSec=3min +MemoryDenyWriteExecute=yes [Install] WantedBy=sysinit.target -- cgit v1.2.3-54-g00ecf From 40093ce5dd4446c011377de6ec74d12a5b8a95b9 Mon Sep 17 00:00:00 2001 From: Topi Miettinen Date: Thu, 9 Jun 2016 07:32:04 +0000 Subject: units: add a basic SystemCallFilter (#3471) Add a line SystemCallFilter=~@clock @module @mount @obsolete @raw-io ptrace for daemons shipped by systemd. As an exception, systemd-timesyncd needs @clock system calls and systemd-localed is not privileged. ptrace(2) is blocked to prevent seccomp escapes. --- units/systemd-hostnamed.service.in | 1 + units/systemd-importd.service.in | 1 + units/systemd-journald.service.in | 1 + units/systemd-localed.service.in | 1 + units/systemd-logind.service.in | 1 + units/systemd-machined.service.in | 1 + units/systemd-networkd.service.m4.in | 1 + units/systemd-resolved.service.m4.in | 1 + units/systemd-timedated.service.in | 1 + units/systemd-timesyncd.service.in | 1 + 10 files changed, 10 insertions(+) (limited to 'units/systemd-timesyncd.service.in') diff --git a/units/systemd-hostnamed.service.in b/units/systemd-hostnamed.service.in index fc43b2c4a6..d8f18bed53 100644 --- a/units/systemd-hostnamed.service.in +++ b/units/systemd-hostnamed.service.in @@ -21,3 +21,4 @@ PrivateNetwork=yes ProtectSystem=yes ProtectHome=yes MemoryDenyWriteExecute=yes +SystemCallFilter=~@clock @module @mount @obsolete @raw-io ptrace diff --git a/units/systemd-importd.service.in b/units/systemd-importd.service.in index 2f8138e88e..a3d1a1519b 100644 --- a/units/systemd-importd.service.in +++ b/units/systemd-importd.service.in @@ -18,3 +18,4 @@ NoNewPrivileges=yes WatchdogSec=3min KillMode=mixed MemoryDenyWriteExecute=yes +SystemCallFilter=~@clock @module @mount @obsolete @raw-io ptrace diff --git a/units/systemd-journald.service.in b/units/systemd-journald.service.in index 06abe04861..58808d4f8c 100644 --- a/units/systemd-journald.service.in +++ b/units/systemd-journald.service.in @@ -25,6 +25,7 @@ CapabilityBoundingSet=CAP_SYS_ADMIN CAP_DAC_OVERRIDE CAP_SYS_PTRACE CAP_SYSLOG C WatchdogSec=3min FileDescriptorStoreMax=1024 MemoryDenyWriteExecute=yes +SystemCallFilter=~@clock @module @mount @obsolete @raw-io ptrace # Increase the default a bit in order to allow many simultaneous # services being run since we keep one fd open per service. Also, when diff --git a/units/systemd-localed.service.in b/units/systemd-localed.service.in index 743221472c..5efa677548 100644 --- a/units/systemd-localed.service.in +++ b/units/systemd-localed.service.in @@ -21,3 +21,4 @@ PrivateNetwork=yes ProtectSystem=yes ProtectHome=yes MemoryDenyWriteExecute=yes +SystemCallFilter=~@clock @module @mount @obsolete @privileged @raw-io ptrace diff --git a/units/systemd-logind.service.in b/units/systemd-logind.service.in index 67e2c34482..a9598760e2 100644 --- a/units/systemd-logind.service.in +++ b/units/systemd-logind.service.in @@ -26,6 +26,7 @@ BusName=org.freedesktop.login1 CapabilityBoundingSet=CAP_SYS_ADMIN CAP_MAC_ADMIN CAP_AUDIT_CONTROL CAP_CHOWN CAP_KILL CAP_DAC_READ_SEARCH CAP_DAC_OVERRIDE CAP_FOWNER CAP_SYS_TTY_CONFIG WatchdogSec=3min MemoryDenyWriteExecute=yes +SystemCallFilter=~@clock @module @mount @obsolete @raw-io ptrace # Increase the default a bit in order to allow many simultaneous # logins since we keep one fd open per session. diff --git a/units/systemd-machined.service.in b/units/systemd-machined.service.in index 1517068ecd..82dca05338 100644 --- a/units/systemd-machined.service.in +++ b/units/systemd-machined.service.in @@ -18,6 +18,7 @@ BusName=org.freedesktop.machine1 CapabilityBoundingSet=CAP_KILL CAP_SYS_PTRACE CAP_SYS_ADMIN CAP_SETGID CAP_SYS_CHROOT CAP_DAC_READ_SEARCH CAP_DAC_OVERRIDE CAP_CHOWN CAP_FOWNER CAP_FSETID CAP_MKNOD WatchdogSec=3min MemoryDenyWriteExecute=yes +SystemCallFilter=~@clock @module @mount @obsolete @raw-io ptrace # Note that machined cannot be placed in a mount namespace, since it # needs access to the host's mount namespace in order to implement the diff --git a/units/systemd-networkd.service.m4.in b/units/systemd-networkd.service.m4.in index 3c9970fa48..3feb2b84f5 100644 --- a/units/systemd-networkd.service.m4.in +++ b/units/systemd-networkd.service.m4.in @@ -32,6 +32,7 @@ ProtectSystem=full ProtectHome=yes WatchdogSec=3min MemoryDenyWriteExecute=yes +SystemCallFilter=~@clock @module @mount @obsolete @raw-io ptrace [Install] WantedBy=multi-user.target diff --git a/units/systemd-resolved.service.m4.in b/units/systemd-resolved.service.m4.in index 07c7658bcc..4a94f747e2 100644 --- a/units/systemd-resolved.service.m4.in +++ b/units/systemd-resolved.service.m4.in @@ -28,6 +28,7 @@ ProtectSystem=full ProtectHome=yes WatchdogSec=3min MemoryDenyWriteExecute=yes +SystemCallFilter=~@clock @module @mount @obsolete @raw-io ptrace [Install] WantedBy=multi-user.target diff --git a/units/systemd-timedated.service.in b/units/systemd-timedated.service.in index 3636091472..1bdbe65aad 100644 --- a/units/systemd-timedated.service.in +++ b/units/systemd-timedated.service.in @@ -19,3 +19,4 @@ PrivateTmp=yes ProtectSystem=yes ProtectHome=yes MemoryDenyWriteExecute=yes +SystemCallFilter=~@module @mount @obsolete @raw-io ptrace diff --git a/units/systemd-timesyncd.service.in b/units/systemd-timesyncd.service.in index caf1dc132f..8c86021f5e 100644 --- a/units/systemd-timesyncd.service.in +++ b/units/systemd-timesyncd.service.in @@ -29,6 +29,7 @@ ProtectSystem=full ProtectHome=yes WatchdogSec=3min MemoryDenyWriteExecute=yes +SystemCallFilter=~@module @mount @obsolete @raw-io ptrace [Install] WantedBy=sysinit.target -- cgit v1.2.3-54-g00ecf From 4e069746fe0de1f60bd1b75c113b0f40ffe86736 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 10 Jun 2016 18:00:12 +0200 Subject: units: tighten system call filters a bit Take away kernel keyring access, CPU emulation system calls and various debug system calls from the various daemons we have. --- units/systemd-hostnamed.service.in | 2 +- units/systemd-importd.service.in | 2 +- units/systemd-journald.service.in | 2 +- units/systemd-localed.service.in | 2 +- units/systemd-logind.service.in | 2 +- units/systemd-machined.service.in | 2 +- units/systemd-networkd.service.m4.in | 2 +- units/systemd-resolved.service.m4.in | 2 +- units/systemd-timedated.service.in | 2 +- units/systemd-timesyncd.service.in | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) (limited to 'units/systemd-timesyncd.service.in') diff --git a/units/systemd-hostnamed.service.in b/units/systemd-hostnamed.service.in index d8f18bed53..0b03a589ea 100644 --- a/units/systemd-hostnamed.service.in +++ b/units/systemd-hostnamed.service.in @@ -21,4 +21,4 @@ PrivateNetwork=yes ProtectSystem=yes ProtectHome=yes MemoryDenyWriteExecute=yes -SystemCallFilter=~@clock @module @mount @obsolete @raw-io ptrace +SystemCallFilter=~@clock @cpu-emulation @debug @keyring @module @mount @obsolete @raw-io diff --git a/units/systemd-importd.service.in b/units/systemd-importd.service.in index a3d1a1519b..0f5489e7e3 100644 --- a/units/systemd-importd.service.in +++ b/units/systemd-importd.service.in @@ -18,4 +18,4 @@ NoNewPrivileges=yes WatchdogSec=3min KillMode=mixed MemoryDenyWriteExecute=yes -SystemCallFilter=~@clock @module @mount @obsolete @raw-io ptrace +SystemCallFilter=~@clock @cpu-emulation @debug @keyring @module @mount @obsolete @raw-io diff --git a/units/systemd-journald.service.in b/units/systemd-journald.service.in index 58808d4f8c..08ace8ae44 100644 --- a/units/systemd-journald.service.in +++ b/units/systemd-journald.service.in @@ -25,7 +25,7 @@ CapabilityBoundingSet=CAP_SYS_ADMIN CAP_DAC_OVERRIDE CAP_SYS_PTRACE CAP_SYSLOG C WatchdogSec=3min FileDescriptorStoreMax=1024 MemoryDenyWriteExecute=yes -SystemCallFilter=~@clock @module @mount @obsolete @raw-io ptrace +SystemCallFilter=~@clock @cpu-emulation @debug @keyring @module @mount @obsolete @raw-io # Increase the default a bit in order to allow many simultaneous # services being run since we keep one fd open per service. Also, when diff --git a/units/systemd-localed.service.in b/units/systemd-localed.service.in index 5efa677548..1f3151c2b5 100644 --- a/units/systemd-localed.service.in +++ b/units/systemd-localed.service.in @@ -21,4 +21,4 @@ PrivateNetwork=yes ProtectSystem=yes ProtectHome=yes MemoryDenyWriteExecute=yes -SystemCallFilter=~@clock @module @mount @obsolete @privileged @raw-io ptrace +SystemCallFilter=~@clock @cpu-emulation @debug @keyring @module @mount @obsolete @raw-io diff --git a/units/systemd-logind.service.in b/units/systemd-logind.service.in index a9598760e2..bee08d011f 100644 --- a/units/systemd-logind.service.in +++ b/units/systemd-logind.service.in @@ -26,7 +26,7 @@ BusName=org.freedesktop.login1 CapabilityBoundingSet=CAP_SYS_ADMIN CAP_MAC_ADMIN CAP_AUDIT_CONTROL CAP_CHOWN CAP_KILL CAP_DAC_READ_SEARCH CAP_DAC_OVERRIDE CAP_FOWNER CAP_SYS_TTY_CONFIG WatchdogSec=3min MemoryDenyWriteExecute=yes -SystemCallFilter=~@clock @module @mount @obsolete @raw-io ptrace +SystemCallFilter=~@clock @cpu-emulation @debug @keyring @module @obsolete @raw-io # Increase the default a bit in order to allow many simultaneous # logins since we keep one fd open per session. diff --git a/units/systemd-machined.service.in b/units/systemd-machined.service.in index 82dca05338..cd4a097f5a 100644 --- a/units/systemd-machined.service.in +++ b/units/systemd-machined.service.in @@ -18,7 +18,7 @@ BusName=org.freedesktop.machine1 CapabilityBoundingSet=CAP_KILL CAP_SYS_PTRACE CAP_SYS_ADMIN CAP_SETGID CAP_SYS_CHROOT CAP_DAC_READ_SEARCH CAP_DAC_OVERRIDE CAP_CHOWN CAP_FOWNER CAP_FSETID CAP_MKNOD WatchdogSec=3min MemoryDenyWriteExecute=yes -SystemCallFilter=~@clock @module @mount @obsolete @raw-io ptrace +SystemCallFilter=~@clock @cpu-emulation @debug @keyring @module @mount @obsolete @raw-io # Note that machined cannot be placed in a mount namespace, since it # needs access to the host's mount namespace in order to implement the diff --git a/units/systemd-networkd.service.m4.in b/units/systemd-networkd.service.m4.in index 3feb2b84f5..38d967d2d1 100644 --- a/units/systemd-networkd.service.m4.in +++ b/units/systemd-networkd.service.m4.in @@ -32,7 +32,7 @@ ProtectSystem=full ProtectHome=yes WatchdogSec=3min MemoryDenyWriteExecute=yes -SystemCallFilter=~@clock @module @mount @obsolete @raw-io ptrace +SystemCallFilter=~@clock @cpu-emulation @debug @keyring @module @mount @obsolete @raw-io [Install] WantedBy=multi-user.target diff --git a/units/systemd-resolved.service.m4.in b/units/systemd-resolved.service.m4.in index 4a94f747e2..a9cc3988ed 100644 --- a/units/systemd-resolved.service.m4.in +++ b/units/systemd-resolved.service.m4.in @@ -28,7 +28,7 @@ ProtectSystem=full ProtectHome=yes WatchdogSec=3min MemoryDenyWriteExecute=yes -SystemCallFilter=~@clock @module @mount @obsolete @raw-io ptrace +SystemCallFilter=~@clock @cpu-emulation @debug @keyring @module @mount @obsolete @raw-io [Install] WantedBy=multi-user.target diff --git a/units/systemd-timedated.service.in b/units/systemd-timedated.service.in index 1bdbe65aad..bc1795d747 100644 --- a/units/systemd-timedated.service.in +++ b/units/systemd-timedated.service.in @@ -19,4 +19,4 @@ PrivateTmp=yes ProtectSystem=yes ProtectHome=yes MemoryDenyWriteExecute=yes -SystemCallFilter=~@module @mount @obsolete @raw-io ptrace +SystemCallFilter=~@cpu-emulation @debug @keyring @module @mount @obsolete @raw-io diff --git a/units/systemd-timesyncd.service.in b/units/systemd-timesyncd.service.in index 8c86021f5e..df1e339196 100644 --- a/units/systemd-timesyncd.service.in +++ b/units/systemd-timesyncd.service.in @@ -29,7 +29,7 @@ ProtectSystem=full ProtectHome=yes WatchdogSec=3min MemoryDenyWriteExecute=yes -SystemCallFilter=~@module @mount @obsolete @raw-io ptrace +SystemCallFilter=~@cpu-emulation @debug @keyring @module @mount @obsolete @raw-io [Install] WantedBy=sysinit.target -- cgit v1.2.3-54-g00ecf