libvirt/src/network
Michal Privoznik 212dfa94ee networkUpdateState: do not assume dnsmasq_caps
Assume there's a dnsmasq running (because there's an active
virtual network that spawned it). Now, shut down the daemon,
remove the dnsmasq binary and start the daemon again. At this
point, networkUpdateState() is called, but dnsmasq_caps is NULL
(because networkStateInitialize() called earlier failed to set
them, rightfully though).

Now, the networkUpdateState() tries to read the dnsmasq's PID
file using virPidFileReadIfAlive() which takes a path to the
corresponding binary as one of its arguments. To provide that
path, dnsmasqCapsGetBinaryPath() is called, but since
dnsmasq_caps is NULL, it dereferences it and thus causes a crash.

It's true that virPidFileReadIfAlive() can deal with a removed
binary (well virPidFileReadPathIfAlive() which it calls can), but
iff the binary path is provided in its absolute form. Otherwise,
virFileResolveAllLinks() fails to canonicalize the path
(expected, the path doesn't exist anyway).

Therefore, reading dnsmasq's PID file didn't work before
v8.1.0-rc1~401 which introduced this crash. It was always set to
-1. But passing NULL as binary path instead, makes
virPidFileReadIfAlive() return early, right after the PID file is
read and it's confirmed the PID exists.

Yes, this may yield wrong results, as the PID might be of a
completely different binary. But this problem is preexistent and
until we start locking PID files, there's nothing we can do about
it. IOW, it would require rework of dnsmasq PID file handling.

Fixes: 4b68c982e2
Resolves: https://gitlab.com/libvirt/libvirt/-/issues/456
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2023-04-19 14:58:33 +02:00
..
bridge_driver_conf.c network: Update format strings in translated messages 2023-04-01 11:40:33 +02:00
bridge_driver_conf.h network: create separate config object for virNetworkDriverState 2022-08-24 12:22:47 -04:00
bridge_driver_linux.c virStringParseVersion: Parse into 'unsigned long long' 2023-04-03 09:19:06 +02:00
bridge_driver_nop.c lib: Drop internal virXXXPtr typedefs 2021-04-13 17:00:38 +02:00
bridge_driver_platform.c Remove all Author(s): lines from source file headers 2018-12-13 16:08:38 +00:00
bridge_driver_platform.h network: move driver state struct into bridge_driver_conf.h 2022-08-24 12:22:47 -04:00
bridge_driver.c networkUpdateState: do not assume dnsmasq_caps 2023-04-19 14:58:33 +02:00
bridge_driver.h network: Remove unused includes 2022-06-16 06:43:57 +02:00
default.xml.in network: Use single quotes in default network configuration 2020-08-04 15:12:18 +02:00
leaseshelper.c network: Update format strings in translated messages 2023-04-01 11:40:33 +02:00
libvirt-routed-in.policy network: firewalld: add policies for routed networks 2022-11-05 14:40:26 -04:00
libvirt-routed-out.policy network: firewalld: add policies for routed networks 2022-11-05 14:40:26 -04:00
libvirt-routed.zone network: firewalld: add zone for routed networks 2022-11-05 14:34:47 -04:00
libvirt-to-host.policy network: firewalld: add policies for routed networks 2022-11-05 14:40:26 -04:00
libvirt.zone network: explicitly allow icmp/icmpv6 in libvirt zonefile 2019-02-14 15:06:42 -05:00
meson.build network: firewalld: add policies for routed networks 2022-11-05 14:40:26 -04:00
virtnetworkd.init.in configure: Provide OpenRC scripts for sub-daemons 2019-12-16 10:11:22 +01:00
virtnetworkd.service.in systemd: Use correct man page name in modular daemon service files 2022-02-01 13:20:11 +01:00