]> git.ipfire.org Git - thirdparty/systemd.git/commit
core/unit: make JoinsNamespaceOf= implies the inverse dependency
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 22 May 2023 21:36:44 +0000 (06:36 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 26 May 2023 02:50:08 +0000 (11:50 +0900)
commita60f96fcf55c3452e5b13d6daec537af1909eda3
treea9d1d2ccbc3bcc8dae98443b4cb613c109a00ff6
parent512df9de23890fcfd5fdbfe633250fe848195d4b
core/unit: make JoinsNamespaceOf= implies the inverse dependency

Previously, even if a.service has JoinsNamespaceOf=b.service, the
inverse direction of reference was not introduced.
Hence, a.service is started earlier than b.service, the namespace will
not shared with b.service.
Also, even if a.service had the reference to b.service, b.service did not.
If b.service is freed earlier, then unit_clear_dependencies() does not clear
the reference from a to b, and will cause use-after-free on unit_free() for
a.service.

Let's make JoinsNamespaceOf=b.service in a.service implies the inverse
dependency, i.e. JoinsNamespaceOf=a.service for b.service. Then, we can safely
free b.service.
man/systemd.unit.xml
src/core/unit.c
test/testsuite-23.units/testsuite-23-joins-namespace-of-5.service
test/testsuite-23.units/testsuite-23-joins-namespace-of-8.service
test/testsuite-23.units/testsuite-23-joins-namespace-of-9.service