Skip to content

[25.12] backport fixes from master#389

Merged
openwrt-bot merged 6 commits intoopenwrt:openwrt-25.12from
Noltari:openwrt-25.12-next
Mar 16, 2026
Merged

[25.12] backport fixes from master#389
openwrt-bot merged 6 commits intoopenwrt:openwrt-25.12from
Noltari:openwrt-25.12-next

Conversation

@Noltari
Copy link
Copy Markdown
Member

@Noltari Noltari commented Mar 16, 2026

  • odhcpd: ensure zero padding on DNSSL
  • odhcpd: ignore NULL in dhcpv4_free_lease() stub
  • ubus: fix truncated field in DHCPv6 lease query
  • dhcpv4: fix avl_delete on leases not in avl tree
  • dhcpv4: fix segfault when disabling interface
  • dhcpv6-ia: dhcpv6_log_ia_addr(): parse return of snprintf

CC @lynxis @aparcar

snprintf() returns also in the failure case how many characters would have been required
to print the full string.
Check return of snprintf() and ensure the log_ctxt->buf_idx never points
outside of the given log_ctxt->buf.

(cherry picked from commit 13cec01)
Fixes: TOB-OWRT-5
Reported-by: Trail of Bits
Signed-off-by: Alexander Couzens <lynxis@fe80.eu>
Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
@Noltari Noltari self-assigned this Mar 16, 2026
@aparcar
Copy link
Copy Markdown
Member

aparcar commented Mar 16, 2026

Nice, thanks!

@Noltari Noltari changed the title [25.12] dhcpv6-ia: dhcpv6_log_ia_addr(): parse return of snprintf [25.12] backport fixes from master Mar 16, 2026
mmmspatz and others added 5 commits March 16, 2026 18:53
dhcpv4_free_lease already calls avl_delete() on the node it's freeing,
and thus shouldn't be called inside an avl_remove_all_elements() loop.

Use avl_for_each_element_safe() instead. Its documentation says:
"This loop can be used if the current element might be removed from the
tree during the loop."

(cherry picked from commit ea5af5b)
Closes: openwrt#371
Signed-off-by: Mark H. Spatz <mark.h.spatz@gmail.com>
Link: openwrt#381
Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
dhcpv4_free_lease() unconditionally calls avl_delete() to remove the
lease from the avl tree at lease->iface->dhcpv4_leases. This corrupts
the tree if the lease is not in it, which happens if dhcpv4_assign()
returns false during address reassignment (line ~611) or assignment
(line ~630).

The check for (lease->iface == NULL) before avl_delete() does not guard
against this and is not necessary, because lease->iface is populated by
dhcpv4_alloc_lease() and never cleared.

Fix by explicitly checking that the lease is in the tree before deleting
it.

(cherry picked from commit 4e26e13)
Fixes: aa6870b ("dhcpv4: use an AVL to store leases")
Signed-off-by: Mark H. Spatz <mark.h.spatz@gmail.com>
Link: openwrt#381
Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
The assigned_subnet_id field in struct dhcpv6_lease is uint32_t, not
uint16_t.

Unlikely to matter in practice, since the number of meaningful bits in
the field is (assignment size) - (interface assignemt size), so largest
typically be 64 - 48 = 16. But it is possible to assign a /32 to an
interface in openwrt.

(cherry picked from commit b960d4c)
Signed-off-by: Mark H. Spatz <mark.h.spatz@gmail.com>
Link: openwrt#383
Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
When DHCPV4_SUPPORT is not defined, a stub implementation of
dhcpv4_free_lease() is provided that logs an error when it's called. A
couple sites in config.c unconditionally free the dhcpv4_lease field of
struct lease_cfg, causing log spam like:
| Trying to free IPv4 assignment 0x(nil)

Silence by making the stub a noop if the argument is NULL, just like the
actual implementation.

(cherry picked from commit 2a316db)
Closes: openwrt#382
Signed-off-by: Mark H. Spatz <mark.h.spatz@gmail.com>
Link: openwrt#384
Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
From https://www.rfc-editor.org/rfc/rfc8106#section-5.2 regarding
the DNSSL field:

  Because the size of this field MUST be a multiple of
  8 octets, for the minimum multiple including the domain
  name representations, the remaining octets other than the
  encoding parts of the domain name representations MUST be
  padded with zeros.

The current code leaves the trailing octets in uninitialized state,
resulting in parsing errors on (at least) systemd RA clients.
This commit restores the explicit zeroing of the trailing octets.

(cherry picked from commit 160e5fa)
Closes: openwrt/openwrt#22351
Fixes: 0a54ce0 ("odhcpd: rename iface->search -> iface->dns_search")
Signed-off-by: Eric Fahlgren <ericfahlgren@gmail.com>
Link: openwrt#386
Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
@openwrt-bot openwrt-bot merged commit edf2e52 into openwrt:openwrt-25.12 Mar 16, 2026
9 checks passed
@Noltari Noltari deleted the openwrt-25.12-next branch March 16, 2026 17:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants