[packages/bird] Rel 2. Backport few upstream fixes

arekm arekm at pld-linux.org
Sun Nov 8 00:29:54 CET 2026


commit bd447640f105928a8fe4518ff22b596d381cbc96
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date:   Sun Nov 8 00:28:59 2026 +0100

    Rel 2. Backport few upstream fixes

 bird-bgp-hostname-leak.patch      | 93 +++++++++++++++++++++++++++++++++++++++
 bird-bgp-notify-data.patch        | 78 ++++++++++++++++++++++++++++++++
 bird-bgp-version-endianness.patch | 24 ++++++++++
 bird-bmp-zero-length.patch        | 24 ++++++++++
 bird-ea-list-copy-overread.patch  | 43 ++++++++++++++++++
 bird-socket-info-nul.patch        | 41 +++++++++++++++++
 bird-trie-bit-range.patch         | 64 +++++++++++++++++++++++++++
 bird.spec                         | 16 ++++++-
 8 files changed, 382 insertions(+), 1 deletion(-)
---
diff --git a/bird.spec b/bird.spec
index 3d4b900..bcb3973 100644
--- a/bird.spec
+++ b/bird.spec
@@ -6,7 +6,7 @@ Summary:	The BIRD Internet Routing Daemon
 Summary(pl.UTF-8):	Demon BIRD Internetowego Routingu Dynamicznego
 Name:		bird
 Version:	3.4.0
-Release:	1
+Release:	2
 License:	GPL v2+
 Group:		Networking/Daemons
 Source0:	https://bird.nic.cz/download/%{name}-%{version}.tar.gz
@@ -22,6 +22,13 @@ Patch1:		CVE-2026-112112.patch
 Patch2:		%{name}-rpki-aspa-length.patch
 Patch3:		%{name}-rpki-log-buffer.patch
 Patch4:		%{name}-strtoul-test-overflow.patch
+Patch5:		%{name}-bgp-notify-data.patch
+Patch6:		%{name}-bgp-hostname-leak.patch
+Patch7:		%{name}-bgp-version-endianness.patch
+Patch8:		%{name}-bmp-zero-length.patch
+Patch9:		%{name}-trie-bit-range.patch
+Patch10:	%{name}-ea-list-copy-overread.patch
+Patch11:	%{name}-socket-info-nul.patch
 URL:		https://bird.nic.cz/
 BuildRequires:	autoconf
 BuildRequires:	automake
@@ -68,6 +75,13 @@ filtrów o dużych możliwościach.
 %patch -P2 -p1
 %patch -P3 -p1
 %patch -P4 -p1
+%patch -P5 -p1
+%patch -P6 -p1
+%patch -P7 -p1
+%patch -P8 -p1
+%patch -P9 -p1
+%patch -P10 -p1
+%patch -P11 -p1
 
 %build
 cp -f /usr/share/automake/config.* tools
diff --git a/bird-bgp-hostname-leak.patch b/bird-bgp-hostname-leak.patch
new file mode 100644
index 0000000..7d27fb9
--- /dev/null
+++ b/bird-bgp-hostname-leak.patch
@@ -0,0 +1,93 @@
+From abab8b7ee7ecc5b5342786f8a449fc277ac4d252 Mon Sep 17 00:00:00 2001
+From: Erin Shepherd <erin.shepherd at e43.eu>
+Date: Wed, 4 Nov 2026 18:37:52 +0100
+Subject: [PATCH] BGP: Fix memory leaks of hostname capability
+
+The hostname capability is stored as a separate allocation owned by struct
+bgp_caps, but it was never freed, leaking memory in several situations:
+
+- A repeated hostname capability in a single OPEN message overwrote
+  caps->hostname without freeing the previous allocation.
+- The error path of bgp_read_capabilities() freed the caps structure but
+  not its hostname.
+- bgp_close_conn() freed both local_caps and remote_caps without their
+  hostname fields. Note that local_caps also owns a hostname allocation
+  when 'advertise hostname' is enabled.
+
+Add a bgp_free_capabilities() helper that frees the hostname together with
+the caps structure and use it on all these paths. The helper is NULL-safe,
+as bgp_close_conn() may be called before capabilities are allocated.
+
+Target: patch
+---
+ proto/bgp/bgp.c     |  4 ++--
+ proto/bgp/bgp.h     |  1 +
+ proto/bgp/packets.c | 13 ++++++++++++-
+ 3 files changed, 15 insertions(+), 3 deletions(-)
+
+diff --git a/proto/bgp/bgp.c b/proto/bgp/bgp.c
+index 087161b..94d6c14 100644
+--- a/proto/bgp/bgp.c
++++ b/proto/bgp/bgp.c
+@@ -1137,9 +1137,9 @@ bgp_close_conn(struct bgp_conn *conn)
+ 
+   proto_announce_state_later(&conn->bgp->p, pes);
+ 
+-  mb_free(conn->local_caps);
++  bgp_free_capabilities(conn->local_caps);
+   conn->local_caps = NULL;
+-  mb_free(conn->remote_caps);
++  bgp_free_capabilities(conn->remote_caps);
+   conn->remote_caps = NULL;
+ 
+   mb_free(conn->notify_data);
+diff --git a/proto/bgp/bgp.h b/proto/bgp/bgp.h
+index 5df3d05..fa8d6f3 100644
+--- a/proto/bgp/bgp.h
++++ b/proto/bgp/bgp.h
+@@ -884,6 +884,7 @@ struct ea_class *bgp_find_ea_class_by_id(uint id);
+ 
+ void bgp_dump_state_change(struct bgp_conn *conn, uint old, uint new);
+ void bgp_prepare_capabilities(struct bgp_conn *conn);
++void bgp_free_capabilities(struct bgp_caps *caps);
+ int bgp_check_capabilities(struct bgp_conn *conn);
+ const struct bgp_af_desc *bgp_get_af_desc(u32 afi);
+ const struct bgp_af_caps *bgp_find_af_caps(struct bgp_caps *caps, u32 afi);
+diff --git a/proto/bgp/packets.c b/proto/bgp/packets.c
+index e9d32fe..a52d739 100644
+--- a/proto/bgp/packets.c
++++ b/proto/bgp/packets.c
+@@ -245,6 +245,16 @@ bgp_alloc_capabilities(struct bgp_proto *p, int n)
+   return caps;
+ }
+ 
++void
++bgp_free_capabilities(struct bgp_caps *caps)
++{
++  if (!caps)
++    return;
++
++  mb_free((void *) caps->hostname);
++  mb_free(caps);
++}
++
+ void
+ bgp_prepare_capabilities(struct bgp_conn *conn)
+ {
+@@ -666,6 +676,7 @@ bgp_read_capabilities(struct bgp_conn *conn, byte *pos, int len)
+         if (hostname[i] < ' ')
+           hostname[i] = ' ';
+ 
++      mb_free((void *) caps->hostname);
+       caps->hostname = hostname;
+ 
+       /* We can safely ignore all other capabilities */
+@@ -691,7 +702,7 @@ bgp_read_capabilities(struct bgp_conn *conn, byte *pos, int len)
+   return 0;
+ 
+ err:
+-  mb_free(caps);
++  bgp_free_capabilities(caps);
+   bgp_error(conn, 2, err_subcode, NULL, 0);
+   return -1;
+ }
diff --git a/bird-bgp-notify-data.patch b/bird-bgp-notify-data.patch
new file mode 100644
index 0000000..1ad5760
--- /dev/null
+++ b/bird-bgp-notify-data.patch
@@ -0,0 +1,78 @@
+From b54b124fd44d67e1a32163aa62c4eab367acce65 Mon Sep 17 00:00:00 2001
+From: Ondrej Zajicek <santiago at crfreenet.org>
+Date: Wed, 4 Nov 2026 18:08:15 +0100
+Subject: [PATCH] BGP: Allocate buffer for notification data in bgp_error()
+
+Do not just keep a pointer to the rx buffer, that is too fragile. Helps
+with cases where notification data are not from the rx buffer. Also
+fixes a bug where pointer to stack was used when OPEN with bad ASN /
+bad version was received.
+
+Reported-By: AISLE and many others
+Target: patch
+Issue: #492
+---
+ proto/bgp/bgp.c     | 11 +++++++++--
+ proto/bgp/packets.c |  6 +++++-
+ 2 files changed, 14 insertions(+), 3 deletions(-)
+
+diff --git a/proto/bgp/bgp.c b/proto/bgp/bgp.c
+index 3894b43..087161b 100644
+--- a/proto/bgp/bgp.c
++++ b/proto/bgp/bgp.c
+@@ -1142,6 +1142,7 @@ bgp_close_conn(struct bgp_conn *conn)
+   mb_free(conn->remote_caps);
+   conn->remote_caps = NULL;
+ 
++  mb_free(conn->notify_data);
+   conn->notify_data = NULL;
+   conn->notify_size = 0;
+ }
+@@ -3890,8 +3891,14 @@ bgp_error(struct bgp_conn *c, uint code, uint subcode, byte *data, int len)
+ 
+   c->notify_code = code;
+   c->notify_subcode = subcode;
+-  c->notify_data = data;
+-  c->notify_size = (len > 0) ? len : 0;
++  c->notify_data = NULL;
++  c->notify_size = 0;
++
++  if (len > 0)
++  {
++    c->notify_data = memcpy(mb_alloc(p->p.pool, len), data, len);
++    c->notify_size = len;
++  }
+ 
+   bgp_conn_enter_close_state(c);
+   bgp_schedule_packet(c, NULL, PKT_NOTIFICATION);
+diff --git a/proto/bgp/packets.c b/proto/bgp/packets.c
+index ac1655d..e9d32fe 100644
+--- a/proto/bgp/packets.c
++++ b/proto/bgp/packets.c
+@@ -169,7 +169,7 @@ bgp_create_notification(struct bgp_conn *conn, byte *buf)
+   BGP_TRACE(D_PACKETS, "Sending NOTIFICATION(code=%d.%d)", conn->notify_code, conn->notify_subcode);
+   buf[0] = conn->notify_code;
+   buf[1] = conn->notify_subcode;
+-  memcpy(buf+2, conn->notify_data, conn->notify_size);
++  bmemcpy(buf+2, conn->notify_data, conn->notify_size);
+   return buf + 2 + conn->notify_size;
+ }
+ 
+@@ -3957,6 +3957,7 @@ bgp_rx_notification(struct bgp_conn *conn, byte *pkt, uint len)
+   bgp_log_error(p, BE_BGP_RX, "Received", code, subcode, pkt+21, len-21);
+   bgp_store_error(p, conn, BE_BGP_RX, (code << 16) | subcode);
+ 
++  /* Just pass is synchronously to bgp_conn_leave_established_state() */
+   conn->notify_code = code;
+   conn->notify_subcode = subcode;
+   conn->notify_data = pkt+21;
+@@ -3965,6 +3966,9 @@ bgp_rx_notification(struct bgp_conn *conn, byte *pkt, uint len)
+   bgp_conn_enter_close_state(conn);
+   bgp_schedule_packet(conn, NULL, PKT_SCHEDULE_CLOSE);
+ 
++  conn->notify_data = NULL;
++  conn->notify_size = 0;
++
+   if (err)
+   {
+     bgp_update_startup_delay(p);
diff --git a/bird-bgp-version-endianness.patch b/bird-bgp-version-endianness.patch
new file mode 100644
index 0000000..0a48135
--- /dev/null
+++ b/bird-bgp-version-endianness.patch
@@ -0,0 +1,24 @@
+From 55f320a01dc6627c026c6bd995c78b45b0a2faab Mon Sep 17 00:00:00 2001
+From: Ondrej Zajicek <santiago at crfreenet.org>
+Date: Fri, 6 Nov 2026 19:56:40 +0100
+Subject: [PATCH] BGP: Fix endianess in version mismatch error notification
+
+Reported-By: Xinrun Li
+Target: patch
+---
+ proto/bgp/packets.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/proto/bgp/packets.c b/proto/bgp/packets.c
+index a52d739..9db0c10 100644
+--- a/proto/bgp/packets.c
++++ b/proto/bgp/packets.c
+@@ -916,7 +916,7 @@ bgp_rx_open(struct bgp_conn *conn, byte *pkt, uint len)
+   { bgp_error(conn, 1, 2, pkt+16, 2); return; }
+ 
+   if (pkt[19] != BGP_VERSION)
+-  { u16 val = BGP_VERSION; bgp_error(conn, 2, 1, (byte *) &val, 2); return; }
++  { u16 val = htons(BGP_VERSION); bgp_error(conn, 2, 1, (byte *) &val, 2); return; }
+ 
+   asn = get_u16(pkt+20);
+   hold = get_u16(pkt+22);
diff --git a/bird-bmp-zero-length.patch b/bird-bmp-zero-length.patch
new file mode 100644
index 0000000..a74db15
--- /dev/null
+++ b/bird-bmp-zero-length.patch
@@ -0,0 +1,24 @@
+From 45744a2939606ac9bd319b8b5f4d22779c35877d Mon Sep 17 00:00:00 2001
+From: Ondrej Zajicek <santiago at crfreenet.org>
+Date: Fri, 6 Nov 2026 19:48:26 +0100
+Subject: [PATCH] BMP: Handle zero-length data properly
+
+Reported-By: Xinrun Li
+Target: patch
+---
+ proto/bmp/bmp.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/proto/bmp/bmp.c b/proto/bmp/bmp.c
+index 22eaf14..8776497 100644
+--- a/proto/bmp/bmp.c
++++ b/proto/bmp/bmp.c
+@@ -189,7 +189,7 @@ static inline void
+ bmp_put_data(buffer *b, const void *src, const size_t len)
+ {
+   ASSERT_DIE(b->pos + len <= b->end);
+-  memcpy(b->pos, src, len);
++  bmemcpy(b->pos, src, len);
+   b->pos += len;
+ }
+ 
diff --git a/bird-ea-list-copy-overread.patch b/bird-ea-list-copy-overread.patch
new file mode 100644
index 0000000..9bea781
--- /dev/null
+++ b/bird-ea-list-copy-overread.patch
@@ -0,0 +1,43 @@
+From cad13a8b4211fd43eeb6e06df6cf74d0607552b0 Mon Sep 17 00:00:00 2001
+From: Ondrej Zajicek <santiago at crfreenet.org>
+Date: Sat, 7 Nov 2026 16:56:26 +0100
+Subject: [PATCH] Nest: Fix over-read in ea_list_copy()
+
+ADATA_SIZE() returns aligned adata size, while source data length does
+not necessary contain alignment. This is already fixed in v2, but was
+somehow mismerged to v3.
+
+Note that cached ea_list alignment is confusing in v3. The code enforces
+CPU_STRUCT_ALIGN alignment, but the adata header is 4 bytes, therefore
+adata body is CPU_STRUCT_ALIGN aligned with 4B offset, and the whole
+structure is copied in ea_alloc_storage() to position with 24B offset.
+
+One would expect that adata bodies assume 4B alignment like in BIRD v2,
+but in struct nexthop_adata there is implicit padding before nexthop
+structure to enforce 8B alignment.
+
+Reported-By: Sebastien Wenske <sebastien at wenske.fr>
+Target: patch
+---
+ nest/rt-attr.c | 5 +++--
+ 1 file changed, 3 insertions(+), 2 deletions(-)
+
+diff --git a/nest/rt-attr.c b/nest/rt-attr.c
+index 1a6d0d8..05591fb 100644
+--- a/nest/rt-attr.c
++++ b/nest/rt-attr.c
+@@ -1235,11 +1235,12 @@ ea_list_copy(ea_list *n, ea_list *o, uint elen)
+       eattr *a = &n->attrs[i];
+       if (!a->undef && !(a->type & EAF_EMBEDDED))
+ 	{
+-	  unsigned size = ADATA_SIZE(a->u.ptr->length);
++	  uint size_u = sizeof(struct adata) + a->u.ptr->length;
++	  uint size = ADATA_SIZE(a->u.ptr->length);
+ 	  ASSERT_DIE(adpos + size <= elen);
+ 
+ 	  struct adata *d = ((void *) n) + adpos;
+-	  memcpy(d, a->u.ptr, size);
++	  memcpy(d, a->u.ptr, size_u);
+ 	  a->u.ptr = d;
+ 
+ 	  adpos += size;
diff --git a/bird-socket-info-nul.patch b/bird-socket-info-nul.patch
new file mode 100644
index 0000000..9cf0f9f
--- /dev/null
+++ b/bird-socket-info-nul.patch
@@ -0,0 +1,41 @@
+From f81b848ca8c6c5cdf925c2e8b23d35c1f2ddee52 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Arkadiusz=20Mi=C5=9Bkiewicz?= <arekm at maven.pl>
+Date: Sun, 8 Nov 2026 00:21:41 +0100
+Subject: [PATCH] IO: Fix off-by-one heap overflow in socket_changed()
+
+The sockets_info buffer is sized loop->sock_num * sk_max_dump_len + 17,
+which leaves no room for the NUL after the 17-char "%p " prefix. When
+the last socket of a loop is removed, buffer_print() truncates, sets
+buf.pos to buf.end and the final NUL is written one byte past the
+allocation (AddressSanitizer: heap-buffer-overflow in socket_changed()
+on every BGP connection close).
+---
+ sysdep/unix/io-loop.c | 8 ++++++--
+ 1 file changed, 6 insertions(+), 2 deletions(-)
+
+diff --git a/sysdep/unix/io-loop.c b/sysdep/unix/io-loop.c
+index 5d92613..1745063 100644
+--- a/sysdep/unix/io-loop.c
++++ b/sysdep/unix/io-loop.c
+@@ -404,7 +404,8 @@ socket_changed(struct birdsock *s, bool recalculate_sk_info)
+ 
+   if (loop != &main_birdloop && recalculate_sk_info)
+   {
+-    int size = loop->sock_num * sk_max_dump_len + 17;
++    /* "%p " is up to 17 chars, plus the terminating NUL */
++    int size = loop->sock_num * sk_max_dump_len + 18;
+     char *new_info = mb_alloc(loop->pool, size);
+ 
+     node *n;
+@@ -421,7 +422,10 @@ socket_changed(struct birdsock *s, bool recalculate_sk_info)
+       SKIP_BACK_DECLARE(sock, s, n, n);
+       sk_dump_to_buffer(&buf, s);
+     }
+-    buf.pos[0] = '\0';
++
++    /* buffer_print() leaves pos == end on truncation */
++    if (buf.pos < buf.end)
++      buf.pos[0] = 0;
+ 
+     char *old_info = NULL;
+     if (loop->sockets_info)
diff --git a/bird-trie-bit-range.patch b/bird-trie-bit-range.patch
new file mode 100644
index 0000000..a7448ce
--- /dev/null
+++ b/bird-trie-bit-range.patch
@@ -0,0 +1,64 @@
+From 896f96ac281978a474a20d3cbb876c04fcf3df83 Mon Sep 17 00:00:00 2001
+From: David Seddon <dave.seddon.ca at gmail.com>
+Date: Thu, 5 Nov 2026 02:55:20 +0100
+Subject: [PATCH] Filter: Fix out-of-range bit access in trie
+
+ip4_getbits()/ip6_getbits() with n == 0 shifted a u32 by 32, and
+ip6_getbits() read a.addr[4] when pos == 128. trie_local_mask6() calls
+them with a zero step whenever the prefix length equals the node length,
+so this runs for every IPv6 route whose prefix length is a multiple of
+32, e.g. from rt_notify_hostcache() via trie_match_net(). The result was
+masked to 0, so behaviour was unaffected. Return 0 for n == 0.
+
+trie_node_format() tested accept bit nlen + i - 1 for i up to
+TRIE_STEP - 1, i.e. bits 32..34 of an IPv4 /32 node and 128..130 of an
+IPv6 /128 node, past the end of the address. Stop at the address length.
+
+Similar patch was also posted by Sebastien Wenske <sebastien at wenske.fr>.
+
+Reported-By: Sergey L <sergeylobanov87nn at gmail.com> and others
+Target: patch
+Issue: #297
+---
+ filter/trie.c | 3 ++-
+ lib/ip.h      | 5 +++--
+ 2 files changed, 5 insertions(+), 3 deletions(-)
+
+diff --git a/filter/trie.c b/filter/trie.c
+index 2ffdf7b..84ad719 100644
+--- a/filter/trie.c
++++ b/filter/trie.c
+@@ -1082,9 +1082,10 @@ trie_node_format(const struct f_trie_node *n, buffer *buf, int v4)
+   }
+ 
+   int nlen = v4 ? n->v4.plen : n->v6.plen;
++  int max_len = v4 ? IP4_MAX_PREFIX_LENGTH : IP6_MAX_PREFIX_LENGTH;
+   uint local = v4 ? n->v4.local : n->v6.local;
+ 
+-  for (int i = (nlen ? 0 : 1); i < TRIE_STEP; i++)
++  for (int i = (nlen ? 0 : 1); (i < TRIE_STEP) && (nlen + i <= max_len); i++)
+     if (GET_ACCEPT_BIT(n, v4, nlen + i - 1))
+       local &= ~trie_level_mask(1, i);
+ 
+diff --git a/lib/ip.h b/lib/ip.h
+index 5fbfd68..cd81a80 100644
+--- a/lib/ip.h
++++ b/lib/ip.h
+@@ -327,14 +327,15 @@ static inline int ip6_prefix_equal(ip6_addr a, ip6_addr b, uint n)
+ static inline u32 ip4_getbit(ip4_addr a, uint pos)
+ { return (_I(a) >> (31 - pos)) & 1; }
+ 
++/* Read n < 32 bits within one word; n == 0 returns 0, including at the address end */
+ static inline u32 ip4_getbits(ip4_addr a, uint pos, uint n)
+-{ return (_I(a) >> ((32 - n) - pos)) & ((1u << n) - 1); }
++{ return n ? (_I(a) >> ((32 - n) - pos)) & ((1u << n) - 1) : 0; }
+ 
+ static inline u32 ip6_getbit(ip6_addr a, uint pos)
+ { return (a.addr[pos / 32] >> (31 - (pos % 32))) & 0x1; }
+ 
+ static inline u32 ip6_getbits(ip6_addr a, uint pos, uint n)
+-{ return (a.addr[pos / 32] >> ((32 - n) - (pos % 32))) & ((1u << n) - 1); }
++{ return n ? (a.addr[pos / 32] >> ((32 - n) - (pos % 32))) & ((1u << n) - 1) : 0; }
+ 
+ static inline u32 ip4_setbit(ip4_addr *a, uint pos)
+ { return _I(*a) |= (0x80000000 >> pos); }
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/bird.git/commitdiff/bd447640f105928a8fe4518ff22b596d381cbc96



More information about the pld-cvs-commit mailing list