]> git.ipfire.org Git - thirdparty/rspamd.git/commit
[Fix] re_cache: detect and handle stale hyperscan files with mismatched regexp IDs
authorVsevolod Stakhov <vsevolod@rspamd.com>
Wed, 28 Jan 2026 18:44:18 +0000 (18:44 +0000)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Wed, 28 Jan 2026 18:44:18 +0000 (18:44 +0000)
commit7557cf859d5cfd06ee76eb002a2d6fe84a29488e
treede0ba6213b48de758707058aa9ebdb7b22cfc618
parent9608160b1aeb85737c490b8fd31263e6933a9b52
[Fix] re_cache: detect and handle stale hyperscan files with mismatched regexp IDs

When the re_class hash doesn't include global regexp indices, regexps can
be reordered while the class hash stays the same. This causes old hyperscan
files to be loaded with stale position IDs that point to wrong regexps
(possibly in different re_classes with no hyperscan loaded), leading to
assertion failures when hs_scratch is NULL.

Fix:
- Reset match_type to PCRE during cleanup before freeing hs_ids, preventing
  stale HYPERSCAN flags if reload fails
- Validate that each stored ID points to a regexp belonging to the current
  re_class before setting match_type
- Delete stale hyperscan files to trigger recompilation by hs_helper
- For Redis cache, stale entries will expire or be overwritten

Both file-based and Redis-based loading paths are fixed.
src/libserver/re_cache.c