coredns
coredns copied to clipboard
data-race: `filterRRSlice` function mutates original which it got from the shared cache
So the chain goes like this:
- In
cache.Cache.getIgnoreTTLgoroutine gets a pointer to a shared object which contains previous response. - In
cache.Cache.ServeDNSgoroutine calls atoMsgmethod onitemto transform shared object into unique response. - And then
cache.filterRRSlicemutates shared object without synchronization.
My best guess is that:
r.Header().Ttl = ttl
if dup {
rs[j] = dns.Copy(r)
} else {
rs[j] = r
}
should be
if dup {
copied := dns.Copy(r)
copied.Header().Ttl = ttl
rs[j] = copied
} else {
r.Header().Ttl = ttl
rs[j] = r
}