]> git.ipfire.org Git - thirdparty/systemd.git/commit
core: do not leak mount for credentials directory if mount namespace is enabled
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 12 Aug 2023 06:18:41 +0000 (15:18 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 22 Aug 2023 02:50:16 +0000 (11:50 +0900)
commit94fe4cf2557d1f70f20ee02d32f4c2ae6bc1fb3f
tree18f374ba064ad7a3b53976ec2678564b520f7fe6
parent7241b9cd72d6e6079d5140cf24c34e78d3cf43cc
core: do not leak mount for credentials directory if mount namespace is enabled

Since kernel v5.2, open_tree() and move_mount() are added. If a service
loads or sets credentials, then let's try to clone the mount that contains
credentials with open_tree(), then mount it after a (private) mount
namespace is initialized for the service. Then, we can setup a mount for
credentials directory without leaking it to the main shared mount
namespace.

With this change, the credentials for services that request their own
private mount namespace become much much safer. And, the number of mount
events triggered by setting up credential directories can be decreased.

Unfortunately, this does not 'fix' the original issue #25527, as the
reported service does not requests private mount namespace, but the
situation should be better now.
src/core/credential.c
src/core/credential.h
src/core/execute.c
src/core/namespace.c
src/core/namespace.h
src/test/test-namespace.c
src/test/test-ns.c