]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
TEST-21-DFUZZER: first test session bus, then service bus, finally system bus
authorYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 19 Jun 2025 10:01:57 +0000 (19:01 +0900)
committerLuca Boccassi <luca.boccassi@gmail.com>
Mon, 4 Aug 2025 15:23:35 +0000 (16:23 +0100)
(cherry picked from commit 5e2b606e4e3939b057395feaadee01ef68b43286)

test/units/TEST-21-DFUZZER.sh

index 11fc3b85c72964947348db217060541ad62b4457..cc02956ac36bc8593d0a93d56f6faee82e2514a5 100755 (executable)
@@ -135,7 +135,6 @@ BUS_LIST=(
     org.freedesktop.machine1
     org.freedesktop.portable1
     org.freedesktop.resolve1
-    org.freedesktop.systemd1
     org.freedesktop.timedate1
 )
 
@@ -160,10 +159,6 @@ elif busctl introspect org.freedesktop.network1 / &>/dev/null; then
     )
 fi
 
-SESSION_BUS_LIST=(
-    org.freedesktop.systemd1
-)
-
 # Maximum payload size generated by dfuzzer (in bytes) - default: 50K
 PAYLOAD_MAX=50000
 # Tweak the maximum payload size if we're running under sanitizers, since
@@ -172,33 +167,37 @@ if [[ -v ASAN_OPTIONS || -v UBSAN_OPTIONS ]]; then
     PAYLOAD_MAX=10000 # 10K
 fi
 
+test_systemd() {
+    systemd-run "$@" --pipe --wait \
+                -- dfuzzer -b "$PAYLOAD_MAX" -n org.freedesktop.systemd1
+
+    # Let's reload the systemd user daemon to test (de)serialization as well
+    systemctl "$@" daemon-reload
+    # FIXME: explicitly trigger reexecute until systemd/systemd#27204 is resolved
+    systemctl "$@" daemon-reexec
+}
+
+# Let's first test the session bus before the system one, as it may be in a
+# spurious state after fuzzing the system bus or login bus.
+echo "Bus: org.freedesktop.systemd1 (session)"
+test_systemd --machine 'testuser@.host' --user
+
 # Overmount /var/lib/machines with a size-limited tmpfs, as fuzzing
 # the org.freedesktop.machine1 stuff makes quite a mess
 mount -t tmpfs -o size=50M tmpfs /var/lib/machines
 
-# Fuzz both the system and the session buses (where applicable)
+# Next, test the system service buses, as the services may be in a spurious
+# state after fuzzing the system service manager bus.
 for bus in "${BUS_LIST[@]}"; do
-    echo "Bus: $bus (system)"
+    echo "Bus: $bus"
     systemd-run --pipe --wait \
                 -- dfuzzer -b "$PAYLOAD_MAX" -n "$bus"
-
-    # Let's reload the systemd daemon to test (de)serialization as well
-    systemctl daemon-reload
-    # FIXME: explicitly trigger reexecute until systemd/systemd#27204 is resolved
-    systemctl daemon-reexec
 done
 
 umount /var/lib/machines
 
-for bus in "${SESSION_BUS_LIST[@]}"; do
-    echo "Bus: $bus (session)"
-    systemd-run --machine 'testuser@.host' --user --pipe --wait \
-                -- dfuzzer -b "$PAYLOAD_MAX" -n "$bus"
-
-    # Let's reload the systemd user daemon to test (de)serialization as well
-    systemctl --machine 'testuser@.host' --user daemon-reload
-    # FIXME: explicitly trigger reexecute until systemd/systemd#27204 is resolved
-    systemctl --machine 'testuser@.host' --user daemon-reexec
-done
+# Finally, test the system bus.
+echo "Bus: org.freedesktop.systemd1 (system)"
+test_systemd
 
 touch /testok