buglwIP - A Lightweight TCP/IP stack - Bugs: bug #66144, mDNS may deadlock for delayed...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #66144: mDNS may deadlock for delayed unicast messages

Submitter:  Matthias Dietrich <matthiasdietrich>
Submitted:  Thu 29 Aug 2024 08:19:04 PM UTC
   
 
Category:  apps Severity:  3 - Normal
Item Group:  Faulty Behaviour Status:  None
Privacy:  Public Assigned to:  None
Open/Closed:  Open Planned Release:  None
lwIP version:  2.1.3

Thu 29 Aug 2024 08:19:04 PM UTC, original submission:  

When the mdns module responds with unicast messages, it may reach a state where it won't be able to send unicast messages anymore.

The issue was found with IPv4, but is most probably present for IPv6, although I did not have the appropriate setup to test it.

[Details for IPv4]
In mdns.c, line 1568, if a query requires a delayed unicast request, we will:
1. check whether a unicast message is already pending (only one can be stored), by checking mdns->ipv4.unicast_msg_in_use
2. if no unicast message is pending, we will add the message and load a timer, which will later call mdns_send_unicast_msg_delayed_ipv4().

Then in mdns_out.c, in mdns_send_unicast_msg_delayed_ipv4(), the variable mdns->ipv4.unicast_msg_in_use will be reset, but only if the packet transmission was successful. If the packet transmission fails (mdns_send_outpacket() returns an error), the variable will not be reset and no timer will be reloaded. As a consequence the variable will remain forever set and will prevent sending any new unicast message.

In my development network, the unicast packet transmission failed, because I have 2 IP subnets on the same physical network, hence sharing the same broadcast domain. My device received a mDNS query from the other subnet, and as there was no gateway configured, the mdns_send_outpacket() call ended in etharp throwing ERR_RTE since the destination was not reachable.

There are however many other cases where transmission could fail (e.g., the netif's linkoutput could return an error because of missing DMA buffers, a sudden link disconnection, etc.).

[Patch]
In the attached patch, the variable mdns->ipv4.unicast_msg_in_use is reset in any case. This solved my issue and the reception of mDNS queries from another subnet did not lead to deadlocks anymore. I applied the same change for IPv6 unicast messages, since the code looks identical. However I could not test it.

Matthias Dietrich <matthiasdietrich>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by matthiasdietrich (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follows 1 latest change.

    Date Changed by Updated Field Previous Value => Replaced by
    2024-08-29 matthiasdietrich Attached File- Added 0001-mdns-avoid-deadlock-in-delayed-unicast-messages.patch, #56395

    Back to the top

    Powered by Savane 3.15-e6e5.
    Corresponding source code