mirror of
https://github.com/coredns/coredns.git
synced 2026-07-11 10:10:10 -04:00
LookupStaticHostV4/V6 dereferenced h.hmap and h.inline as call arguments, which are evaluated before lookupStaticHostFamily takes the read lock. The reload path (readHosts) swaps h.hmap under h.Lock() on every reload, so the field read raced the swap for every A/AAAA lookup. This was introduced when wildcard support (#8185) refactored these methods to pass the maps as parameters; LookupStaticAddr still reads the fields inside the lock and was unaffected. Read h.hmap/h.inline inside the RLock by selecting the address family with a bool instead of passing pre-dereferenced maps. Also read h.mtime under the existing RLock in readHosts: it was read without a lock while the reload writes it under h.Lock(), and readHosts runs from both the OnStartup handler and the reload ticker goroutine. Both races are confirmed by go test -race. Signed-off-by: Pavel Lazureykis <pavel@lazureykis.dev>
6.6 KiB
6.6 KiB