BIRD 3.3/3.4: crashes on reconfigure and other memory errors, downstream patches
Hi, at Freifunk Berlin we run BIRD 3 with the babel patch on OpenWrt. Since 3.3 our core routers crashed regularly on reconfiguration, so I used an LLM to build BIRD with AddressSanitizer, and that turned up a few more bugs. We carry the fixes as downstream patches on top of 3.4.0: https://github.com/freifunk-berlin/falter-packages/tree/3f20752d1a2be04088d3... 0001 and 0002 are our own changes (birdc history file, babel route selection). 0003 to 0011 fix bugs in BIRD itself and apply cleanly to thread-next (dcf094d3f). Each patch explains its trigger in more detail in its header. 0003 CLI: Free a failed session from its own event Trigger: a birdc client hangs up while a long "show route" still writes to it. The CLI gets freed under the running command, and bird crashes with a NULL dereference in cli_get_command(). 0004 Conf: Free a dropped config instead of finishing reconfiguration Trigger: "configure" while another config is already queued ("Queueing new configuration, ignoring the one already queued") and a "show route" still holds the old config. bird dies on "Assertion 'configuring' failed" or on the obstacle count assertion. 0005 BGP: Fix use-after-free of listen requests on protocol cleanup Trigger: "configure" removing or restarting a BGP protocol, and shutdown. Since 21637833e (3.3.0) the default listen request is freed with the protocol's pool, after the protocol and its loop, and bgp_listen_free() still uses both. On musl this segfaults. This is what crashed our routers, as our tool that generates BGP sessions reloads BIRD on every babel neighbor change. The patch adds a protocol hook called from proto_cleanup() while the protocol is still alive. 0006 IO Loop: Fix off-by-one in socket info buffer Trigger: the last socket leaving a loop other than the main loop, e.g. a BGP session closing. socket_changed() writes the terminating zero one byte past the buffer (since 3.2.0). 0007 Nest: Fix over-read when copying attribute data Trigger: every BGP connection. ea_list_copy() copies ADATA_SIZE() bytes, but the source is often only sizeof(adata) + length long, here struct bgp_conn_sk_ad on the stack of bgp_setup_sk(). 0008 Nest: Fix use-after-free when reconfiguring a protocol that is down Trigger: "configure" enabling, changing or removing a disabled protocol that runs in the main loop (static, kernel, device, ...). proto_rethink_goal() frees it right away, and protos_do_commit() then calls proto_announce_state() on it. 0009 BGP: Fix crash on start with interface range Trigger: any BGP protocol with "interface range". bgp_init() passes the NULL default listen request to bgp_listen_register() (also since 21637833e). 0010 BGP: Fix dangling NOTIFICATION data from OPEN errors Trigger: an OPEN with a version other than 4, or a Bad Peer AS. The NOTIFICATION data points to a local variable of bgp_rx_open() and is only read when the deferred TX builds the message, so the peer gets stale stack bytes. The version is now also sent in network byte order; it went out as 04 00 on little endian. 0011 Nest: Fix over-read when pushing route exports Trigger: every route change on x86_64 (anywhere alignof(max_align_t) is 16). lfjour_init() rounds item_size up to 48, so rt_exporter_push() copies 8 bytes past the 40 byte rt_pending_export on the stack of rte_announce_to(). We observed issues 0003 and 0004 with concurrent birdc clients. The LLM reproduced the others with ASan builds of 3.3.3 and 3.4.0, using two BIRD instances on 127.0.0.x and configure loops; with the patches these runs are clean. Feel free to pick the patches. Thanks for BIRD! Simon
Hii Simon, thanks a lot for the reports and patches! We fixed two of the issues based on your reports (0003, 0009): https://gitlab.nic.cz/labs/bird/-/commit/d51f09e285143b2eb7c37ed94b6ddbf510a... https://gitlab.nic.cz/labs/bird/-/commit/e9f4e14436b0a272135a85f2fbb66e738b0... Another two provided more context for know bugs. The rest we know about and are already fixed or are going to be fixed soon. Thanks for making BIRD better! Happy routing, David David Petera (he/him) | BIRD Tech Support | CZ.NIC, z.s.p.o. On 10/23/26 22:44, Simon Polack via Bird-users wrote:
Hi,
at Freifunk Berlin we run BIRD 3 with the babel patch on OpenWrt. Since 3.3 our core routers crashed regularly on reconfiguration, so I used an LLM to build BIRD with AddressSanitizer, and that turned up a few more bugs. We carry the fixes as downstream patches on top of 3.4.0:
https://github.com/freifunk-berlin/falter-packages/tree/3f20752d1a2be04088d3...
0001 and 0002 are our own changes (birdc history file, babel route selection). 0003 to 0011 fix bugs in BIRD itself and apply cleanly to thread-next (dcf094d3f). Each patch explains its trigger in more detail in its header.
0003 CLI: Free a failed session from its own event Trigger: a birdc client hangs up while a long "show route" still writes to it. The CLI gets freed under the running command, and bird crashes with a NULL dereference in cli_get_command().
0004 Conf: Free a dropped config instead of finishing reconfiguration Trigger: "configure" while another config is already queued ("Queueing new configuration, ignoring the one already queued") and a "show route" still holds the old config. bird dies on "Assertion 'configuring' failed" or on the obstacle count assertion.
0005 BGP: Fix use-after-free of listen requests on protocol cleanup Trigger: "configure" removing or restarting a BGP protocol, and shutdown. Since 21637833e (3.3.0) the default listen request is freed with the protocol's pool, after the protocol and its loop, and bgp_listen_free() still uses both. On musl this segfaults. This is what crashed our routers, as our tool that generates BGP sessions reloads BIRD on every babel neighbor change. The patch adds a protocol hook called from proto_cleanup() while the protocol is still alive.
0006 IO Loop: Fix off-by-one in socket info buffer Trigger: the last socket leaving a loop other than the main loop, e.g. a BGP session closing. socket_changed() writes the terminating zero one byte past the buffer (since 3.2.0).
0007 Nest: Fix over-read when copying attribute data Trigger: every BGP connection. ea_list_copy() copies ADATA_SIZE() bytes, but the source is often only sizeof(adata) + length long, here struct bgp_conn_sk_ad on the stack of bgp_setup_sk().
0008 Nest: Fix use-after-free when reconfiguring a protocol that is down Trigger: "configure" enabling, changing or removing a disabled protocol that runs in the main loop (static, kernel, device, ...). proto_rethink_goal() frees it right away, and protos_do_commit() then calls proto_announce_state() on it.
0009 BGP: Fix crash on start with interface range Trigger: any BGP protocol with "interface range". bgp_init() passes the NULL default listen request to bgp_listen_register() (also since 21637833e).
0010 BGP: Fix dangling NOTIFICATION data from OPEN errors Trigger: an OPEN with a version other than 4, or a Bad Peer AS. The NOTIFICATION data points to a local variable of bgp_rx_open() and is only read when the deferred TX builds the message, so the peer gets stale stack bytes. The version is now also sent in network byte order; it went out as 04 00 on little endian.
0011 Nest: Fix over-read when pushing route exports Trigger: every route change on x86_64 (anywhere alignof(max_align_t) is 16). lfjour_init() rounds item_size up to 48, so rt_exporter_push() copies 8 bytes past the 40 byte rt_pending_export on the stack of rte_announce_to().
We observed issues 0003 and 0004 with concurrent birdc clients. The LLM reproduced the others with ASan builds of 3.3.3 and 3.4.0, using two BIRD instances on 127.0.0.x and configure loops; with the patches these runs are clean.
Feel free to pick the patches.
Thanks for BIRD!
Simon
participants (2)
-
David Petera -
Simon Polack