From 0e18724eb1baf251c3fa66144ef721726a00cbe9 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 29 Oct 2018 20:45:04 +0100 Subject: [PATCH] man: emphasize the ReadOnlyPaths= mount propagation "hole" This changes the ProtectSystem= documentation to refer in more explicit words to the restrictions of ReadOnlyPath=, as sugegsted in #9857. THis also extends the paragraph in ReadOnlyPath= that explains the hole. Fixes: #9857 --- man/systemd.exec.xml | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/man/systemd.exec.xml b/man/systemd.exec.xml index d6f1427dcc..3f0535726b 100644 --- a/man/systemd.exec.xml +++ b/man/systemd.exec.xml @@ -781,9 +781,9 @@ CapabilityBoundingSet=~CAP_B CAP_C recommended to enable this setting for all long-running services, unless they are involved with system updates or need to modify the operating system in other ways. If this option is used, ReadWritePaths= may be used to exclude specific directories from being made read-only. This - setting is implied if DynamicUser= is set. For this setting the same restrictions regarding - mount propagation and privileges apply as for ReadOnlyPaths= and related calls, see - below. Defaults to off. + setting is implied if DynamicUser= is set. This setting cannot ensure protection in all + cases. In general it has the same limitations as ReadOnlyPaths=, see below. Defaults to + off. @@ -802,11 +802,11 @@ CapabilityBoundingSet=~CAP_B CAP_C ReadOnlyPaths=, and tmpfs is mostly equivalent to TemporaryFileSystem=. - It is recommended to enable this setting for all long-running services (in particular network-facing ones), - to ensure they cannot get access to private user data, unless the services actually require access to the user's - private data. This setting is implied if DynamicUser= is set. For this setting the same - restrictions regarding mount propagation and privileges apply as for ReadOnlyPaths= and related - calls, see below. + It is recommended to enable this setting for all long-running services (in particular network-facing + ones), to ensure they cannot get access to private user data, unless the services actually require access to + the user's private data. This setting is implied if DynamicUser= is set. This setting cannot + ensure protection in all cases. In general it has the same limitations as ReadOnlyPaths=, + see below. @@ -974,8 +974,7 @@ StateDirectory=aaa/bbb ccc BindPaths=, or BindReadOnlyPaths= inside it. For a more flexible option, see TemporaryFileSystem=. - Note that restricting access with these options does not extend to submounts of a directory that are - created later on. Non-directory paths may be specified as well. These options may be specified more than once, + Non-directory paths may be specified as well. These options may be specified more than once, in which case all paths listed will have limited access from within the namespace. If the empty string is assigned to this option, the specific list is reset, and all prior assignments have no effect. @@ -987,11 +986,19 @@ StateDirectory=aaa/bbb ccc + on the same path make sure to specify - first, and + second. - Note that using this setting will disconnect propagation of mounts from the service to the host - (propagation in the opposite direction continues to work). This means that this setting may not be used for - services which shall be able to install mount points in the main mount namespace. Note that the effect of these - settings may be undone by privileged processes. In order to set up an effective sandboxed environment for a - unit it is thus recommended to combine these settings with either + Note that these settings will disconnect propagation of mounts from the unit's processes to the + host. This means that this setting may not be used for services which shall be able to install mount points in + the main mount namespace. For ReadWritePaths= and ReadOnlyPaths= + propagation in the other direction is not affected, i.e. mounts created on the host generally appear in the + unit processes' namespace, and mounts removed on the host also disappear there too. In particular, note that + mount propagation from host to unit will result in unmodified mounts to be created in the unit's namespace, + i.e. writable mounts appearing on the host will be writable in the unit's namespace too, even when propagated + below a path marked with ReadOnlyPaths=! Restricting access with these options hence does + not extend to submounts of a directory that are created later on. This means the lock-down offered by that + setting is not complete, and does not offer full protection. + + Note that the effect of these settings may be undone by privileged processes. In order to set up an + effective sandboxed environment for a unit it is thus recommended to combine these settings with either CapabilityBoundingSet=~CAP_SYS_ADMIN or SystemCallFilter=~@mount.