]> git.ipfire.org Git - thirdparty/rspamd.git/commit
[Fix] re_cache: fix stale hyperscan ID handling during config reload master
authorVsevolod Stakhov <vsevolod@rspamd.com>
Sat, 31 Jan 2026 22:17:31 +0000 (22:17 +0000)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Sat, 31 Jan 2026 22:18:12 +0000 (22:18 +0000)
commitdd95b7a56f9d653aa1ca6e52ac4a90e108563875
treefde7c8d9882dd54832fd67202a48ad74f6bdd12e
parent195e813672729e82523a5e8c5768e2b535580a6d
[Fix] re_cache: fix stale hyperscan ID handling during config reload

When hyperscan cache is reloaded, the old hs_ids array may contain indices
that now point to different regexps in cache->re due to regexp reordering
after config reload. This caused two issues:

1. Cleanup used stale hs_ids to reset match_type, potentially resetting
   wrong regexps while leaving the actual ones with match_type=HYPERSCAN
   but hs_scratch=NULL, causing assertion failures.

2. If validation failed mid-loop while setting match_types, some regexps
   would already have match_type=HYPERSCAN before we freed scratch,
   leaving them in an inconsistent state.

Fix:
- Iterate re_class->re hash table (actual regexps in class) during cleanup
  instead of using potentially stale hs_ids
- Split validation and match_type setting into separate loops so we only
  set match_types after ALL IDs are validated

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