Commit 9057f2d
committed
fix(mdns): Don't free a browse result already freed by an earlier sync batch
browse_sync() frees sync_result->result whenever result->ttl is 0 at
processing time, but sync entries only borrow the node: one packet
produces one mdns_browse_sync_t, each queued as its own
ACTION_BROWSE_SYNC, and add_browse_result() dedupes within a single
batch only. mdns_priv_query_update_result_ttl() takes the minimum, so a
goodbye lowers a cached node's TTL to 0 and re-adds it to a fresh batch
while an older batch still references it. Processing the older batch
frees the node; processing the newer one reads result->ttl from freed
memory and frees it again:
assert failed: tlsf_free ... block already marked as free
mdns_mem_free mdns_mem_caps.c
mdns_priv_query_results_free mdns_querier.c
browse_sync mdns_browser.c
mdns_priv_browse_action mdns_browser.c
execute_action mdns_service.c
Skip sync entries whose node is no longer linked in browse->result. That
covers both the use-after-free read and the second free, and needs no
change to the result lifetime or to the sync batch layout.1 parent cf3f8ef commit 9057f2d
1 file changed
Lines changed: 23 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
59 | 77 | | |
60 | 78 | | |
61 | 79 | | |
| |||
70 | 88 | | |
71 | 89 | | |
72 | 90 | | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
73 | 96 | | |
74 | 97 | | |
75 | 98 | | |
| |||
0 commit comments