[Dnsmasq-discuss] [PATCH] DBus watchers change can trigger crash

Petr Menšík pemensik at redhat.com
Mon Apr 17 11:30:09 UTC 2023


Hi!

Interesting crash in dnsmasq were reported to me. I can reproduce it 
reliably on RHEL9, but not anymore on the most recent Fedora. But the 
difference seems to be based on used dbus library, not depending on 
dnsmasq code. RHEL9 dbus libraries installs 2 daemon->watchers, Fedora 
rawhide version does not. If those watchers are present and dbus system 
instance is restarted, dnsmasq crashes. RHEL9 uses 
dbus-libs-1.12.20-7.el9_1.x86_64.

If I configure dnsmasq to use dbus and then restart dbus.service with 
watchers present, it crashes dnsmasq. The reason is simple, it uses loop 
to walk over watchers to call dbus handling code. But from that code the 
same list can be modified and watchers removed. But the list iteration 
continues anyway.

In my first patch I fixed that problem by restarting the loop if list 
were modified.

Second patch is just optimization of socket events handling of dbus. 
Reduces calls to locate the file descriptor structure. Should lower CPU 
usage when monitoring dbus watches. It is not directly related to the 
issue, I just noticed repeated function calls where just one were needed.

Red Hat bug: https://bugzilla.redhat.com/show_bug.cgi?id=2185878

Cheers,
Petr

-- 
Petr Menšík
Software Engineer, RHEL
Red Hat, https://www.redhat.com/
PGP: DFCF908DB7C87E8E529925BC4931CA5B6C9FC5CB
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-Small-optimization-around-dbus-socket-events.patch
Type: text/x-patch
Size: 1714 bytes
Desc: not available
URL: <http://lists.thekelleys.org.uk/pipermail/dnsmasq-discuss/attachments/20230417/cc5563a0/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Watch-modification-of-dbus-watches-list.patch
Type: text/x-patch
Size: 2338 bytes
Desc: not available
URL: <http://lists.thekelleys.org.uk/pipermail/dnsmasq-discuss/attachments/20230417/cc5563a0/attachment-0001.bin>


More information about the Dnsmasq-discuss mailing list