mirror of
https://github.com/morgan9e/systemd
synced 2026-04-14 08:25:20 +09:00
TEST-21-DFUZZER: enable services to be tested
Since e19e17df57, timesyncd is disabled by
default, and fuzzing for timesyncd failed.
```
[ 754.247451] TEST-21-DFUZZER.sh[658]: Bus: org.freedesktop.timesync1 (system)
[ 754.247725] TEST-21-DFUZZER.sh[658]: + systemd-run --pipe --wait -- dfuzzer -b 10000 -n org.freedesktop.timesync1
[ 754.282237] TEST-21-DFUZZER.sh[3236]: Running as unit: run-p3236-i3237.service
[ 754.348983] TEST-21-DFUZZER.sh[3238]: [SESSION BUS]
[ 754.350443] TEST-21-DFUZZER.sh[3238]: Bus not found.
[ 754.350705] TEST-21-DFUZZER.sh[3238]: [SYSTEM BUS]
[ 754.359249] TEST-21-DFUZZER.sh[3238]: Error while calling method 'GetConnectionUnixProcessID': GDBus.Error:org.freedesktop.DBus.Error.NameHasNoOwner: The connection does not exist
[ 754.359520] TEST-21-DFUZZER.sh[3238]: Couldn't get the PID of the tested process
[ 754.359764] TEST-21-DFUZZER.sh[3238]: Exit status: 4
[ 754.386721] TEST-21-DFUZZER.sh[3236]: Finished with result: exit-code
[ 754.387331] TEST-21-DFUZZER.sh[3236]: Main processes terminated with: code=exited, status=4/NOPERMISSION
[ 754.387537] TEST-21-DFUZZER.sh[3236]: Service runtime: 74ms
[ 754.387706] TEST-21-DFUZZER.sh[3236]: CPU time consumed: 21ms
[ 754.389210] TEST-21-DFUZZER.sh[3236]: Memory peak: 12.9M (swap: 0B)
```
Also, create dummy interface for networkd and resolved.
Fixes #37834.
This commit is contained in:
@@ -126,37 +126,51 @@ cat /etc/dfuzzer.conf
|
||||
|
||||
# TODO
|
||||
# * check for possibly newly introduced buses?
|
||||
BUS_LIST=(
|
||||
org.freedesktop.home1
|
||||
org.freedesktop.hostname1
|
||||
org.freedesktop.import1
|
||||
org.freedesktop.locale1
|
||||
org.freedesktop.login1
|
||||
org.freedesktop.machine1
|
||||
org.freedesktop.portable1
|
||||
org.freedesktop.resolve1
|
||||
org.freedesktop.timedate1
|
||||
NAME_LIST=(
|
||||
home
|
||||
hostname
|
||||
import
|
||||
locale
|
||||
login
|
||||
machine
|
||||
portable
|
||||
resolve
|
||||
timedate
|
||||
)
|
||||
|
||||
# systemd-oomd requires PSI
|
||||
if tail -n +1 /proc/pressure/{cpu,io,memory}; then
|
||||
BUS_LIST+=(
|
||||
org.freedesktop.oom1
|
||||
)
|
||||
fi
|
||||
|
||||
# Some services require specific conditions:
|
||||
# - systemd-oomd requires PSI
|
||||
# - systemd-timesyncd can't run in a container
|
||||
# - systemd-networkd can run in a container if it has CAP_NET_ADMIN capability
|
||||
if tail -n +1 /proc/pressure/{cpu,io,memory}; then
|
||||
NAME_LIST+=( oom )
|
||||
fi
|
||||
|
||||
if ! systemd-detect-virt --container; then
|
||||
BUS_LIST+=(
|
||||
org.freedesktop.network1
|
||||
org.freedesktop.timesync1
|
||||
)
|
||||
elif busctl introspect org.freedesktop.network1 / &>/dev/null; then
|
||||
BUS_LIST+=(
|
||||
org.freedesktop.network1
|
||||
)
|
||||
NAME_LIST+=( timesync )
|
||||
fi
|
||||
|
||||
if ip link add dummy-fuzz type dummy; then
|
||||
# if a dummy interface is created, then let's also setup it for resolved
|
||||
ip link set dummy-fuzz up
|
||||
ip address add 192.0.2.1/24 dev dummy-fuzz
|
||||
|
||||
# When we can create a dummy interface, we definitely have CAP_NET_ADMIN
|
||||
NAME_LIST+=( network )
|
||||
|
||||
# Create unit files for another dummy interface for networkd
|
||||
mkdir -p /run/systemd/network
|
||||
cat >/run/systemd/network/10-dummy-fuzz2.netdev <<EOF
|
||||
[NetDev]
|
||||
Kind=dummy
|
||||
Name=dummy-fuzz2
|
||||
EOF
|
||||
cat >/run/systemd/network/10-dummy-fuzz2.network <<EOF
|
||||
[Match]
|
||||
Name=dummy-fuzz2
|
||||
[Network]
|
||||
Address=192.0.2.2/24
|
||||
EOF
|
||||
fi
|
||||
|
||||
# Maximum payload size generated by dfuzzer (in bytes) - default: 50K
|
||||
@@ -188,10 +202,24 @@ mount -t tmpfs -o size=50M tmpfs /var/lib/machines
|
||||
|
||||
# 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
|
||||
for name in "${NAME_LIST[@]}"; do
|
||||
bus="org.freedesktop.${name}1"
|
||||
service="systemd-${name}d.service"
|
||||
|
||||
echo "Bus: $bus"
|
||||
|
||||
# Unmask and enable the service.
|
||||
systemctl unmask "$service"
|
||||
systemctl enable "$service"
|
||||
|
||||
# enable debugging logs
|
||||
systemctl service-log-level "$service" debug || :
|
||||
|
||||
systemd-run --pipe --wait \
|
||||
-- dfuzzer -b "$PAYLOAD_MAX" -n "$bus"
|
||||
|
||||
# disable debugging logs
|
||||
systemctl service-log-level "$service" info || :
|
||||
done
|
||||
|
||||
umount /var/lib/machines
|
||||
|
||||
Reference in New Issue
Block a user