Skip to content

net: mdns_responder: Use static storage for listener poll arrays (cherry-pick) - #2

Open
mikeysklar wants to merge 1 commit into
adafruit:zephyr_260803from
mikeysklar:fix/mdns-responder-poll-array-lifetime
Open

net: mdns_responder: Use static storage for listener poll arrays (cherry-pick)#2
mikeysklar wants to merge 1 commit into
adafruit:zephyr_260803from
mikeysklar:fix/mdns-responder-poll-array-lifetime

Conversation

@mikeysklar

@mikeysklar mikeysklar commented Aug 25, 2026

Copy link
Copy Markdown

Cherry-picks upstream ba0bd94d4e9 onto zephyr_260803, unchanged. Authorship and sign-off preserved.

The socket service dispatcher keeps the poll fd array pointer it was given at registration, but init_listener() passed arrays with automatic storage, so the pointer dangles once it returns. Upstream moved them to file scope.

This branch still has the bug, and the CircuitPython zephyr-cp manifest pins 3c402d80bd8 from it:

subsys/net/lib/dns/mdns_responder.c:1753:	struct zsock_pollfd ipv4_fds[MAX_IPV4_IFACE_COUNT];

Symptom is intermittent <hostname>.local failures with nothing logged. On a SiWx917-DK2605A one probe window answered and a later one gave 0 of 6 rounds; with the fix, 5 reset cycles x 3 rounds all answered. Any zephyr-cp board with CONFIG_MDNS_RESPONDER=y is exposed.

Once this lands the revision: in zephyr-config/west.yml can move.

On the two red checks, both are pre-existing and not from this patch:

  • Manifest fails with "Refusing to check out fork pull request code from a pull_request_target workflow", so it fails for any fork PR here.
  • compliance fails only on subsys/tracing/perfetto/decode_trace.py (ruff E501 and E722). This patch touches one file, subsys/net/lib/dns/mdns_responder.c.

Neither is fixable from a fork.

The socket service dispatcher stores the pointer to the poll fd array
passed at registration and reuses it later (e.g. when a peer
dispatcher on the same service is unregistered). The IPv6 and IPv4
poll arrays in init_listener() had automatic storage, so this stored
pointer dangled once the function returned, leading to a
stack-use-after-return. Move the arrays to file scope so they outlive
the registration, as the LLMNR responder already does.

Assisted-by: Cursor:claude-opus-4.8
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
(cherry picked from commit ba0bd94)
Signed-off-by: Mikey Sklar <mikeysklar@gmail.com>
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.

2 participants