]> git.ipfire.org Git - thirdparty/pdns.git/commit
authoritative: Prevent a potential race condition in cache cleaning 16287/head
authorDeyan Doychev <deyan@siteground.com>
Fri, 17 Oct 2025 11:37:32 +0000 (14:37 +0300)
committerDeyan Doychev <deyan@siteground.com>
Mon, 20 Oct 2025 11:01:57 +0000 (14:01 +0300)
commitfdcc9ab427f8deb73a4b5603ec2cb5233ec8bd78
tree3d1ff4a0783b68086631228884fbcb9cd1279edc
parent0c511faccb4aac5d6db8f2a26ad467bb259601b1
authoritative: Prevent a potential race condition in cache cleaning

Clean query cache before cleaning packet cache. Otherwise the following
situation is possible:

* thread A cleans packet cache
* thread B answers a question for the same name that is being cleaned by A
* since there is no packet cache it populates a packet cache entry from the
  query cache (which has not yet been cleaned by thread A
* thread A cleans query cache
* the server will return the old packet cache entry until its TTL expires or
  cache is cleaned again

Switching which cache is cleaned first fixes this race condition.

Signed-off-by: Deyan Doychev <deyan@siteground.com>
pdns/auth-caches.cc