]> git.ipfire.org Git - thirdparty/pdns.git/commit
authoritative: Prevent a potential race condition in cache cleaning 16359/head
authorDeyan Doychev <deyan@siteground.com>
Fri, 17 Oct 2025 11:37:32 +0000 (14:37 +0300)
committerMiod Vallat <miod.vallat@powerdns.com>
Thu, 23 Oct 2025 09:33:59 +0000 (11:33 +0200)
commit434b134aa786711fbbc2e83362c28e11bb5acbc2
tree71ff6ddeef9ad4aae7f50073ee6dab5bb63b325f
parentfeeb246720e24b65f64dd0c302cde3049cda5fed
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>
(cherry picked from commit fdcc9ab427f8deb73a4b5603ec2cb5233ec8bd78)
pdns/auth-caches.cc