Hello Ben, thanks for this report, we actually know about this bug and just have not had the time to patch it/review the patches yet. Nice catch either way and thanks for confirming this! Happy routing, David David Petera (he/him) | BIRD Tech Support | CZ.NIC, z.s.p.o. On 10/30/26 22:24, bird-users_mana-toast--- via Bird-users wrote:
Hi,
I ran into this building BIRD 3.3.3 on Alpine 3.24. With Alpine's stock toolchain (GCC 15.2, musl and fortify-headers 3.0.1, which turns on _FORTIFY_SOURCE=2 by default) and BIRD's usual -O2 -flto, the daemon gets SIGILL as soon as the first route goes into a table. One static route is enough.
I tracked it down with gdb. With LTO, rt_exporter_push() is inlined into rte_announce_to(), so the fortified memcpy() can see that its source is a local variable. The copy is longer than what's left of that variable, so the check calls __builtin_trap(). These were the values at the crash:
e->journal.item_size 48 sizeof(struct rt_pending_export) 40 OFFSETOF(struct rt_export_item, data) 8
So memcpy() copies 40 bytes starting 8 bytes into a 40-byte struct, and reads 8 bytes past the end of it.
On Debian the same code runs without any visible problem. Even with _FORTIFY_SOURCE, glibc only checks the destination size in memcpy(), so it wouldn't notice this. ASan does catch it. I used current thread-next (3e4e50a54cc9) with this config:
log stderr all; router id 192.0.2.1; protocol device {} protocol static { ipv4; route 203.0.113.0/24 blackhole; }
Built with -fsanitize=address and run with ASAN_OPTIONS=detect_leaks=0, it reports:
ERROR: AddressSanitizer: stack-buffer-overflow on address ... READ of size 40 at ... thread T0 #0 ... in memcpy #1 ... in rt_exporter_push nest/rt-export.c:487 #2 ... in rte_announce_to nest/rt-table.c:2054 #3 ... in rte_announce nest/rt-table.c:2091 #4 ... in rte_recalculate nest/rt-table.c:2627 #5 ... in rte_import nest/rt-table.c:2843 [48, 88) 'rpe' (line 2047) <== Memory access at offset 88 overflows this variable
With the patch, the same ASan build runs clean. The patch applies as-is to v3.4.0 and v3.3.3 too. I've been running it on 3.3.3 on a handful of Debian-based BGP routers since mid-October with no problems, and the Alpine build works now. I've only tested on x86_64.
It's always the same 8 bytes of BIRD's own stack, any route triggers it (static ones included), so a peer has no control over it, and the bytes end up in padding in the journal entry.
I kept the fix in the one caller to keep it small. It could also be fixed in the journal, for example by remembering the unaligned item size and copying only that much. I'm happy to redo it that way if you'd prefer.
The patch is attached, made with git format-patch against current thread-next (3e4e50a54cc9).
Thanks, Ben