From e4a406d375bad00ea4d73d49cb1ad777042c105c Mon Sep 17 00:00:00 2001 From: Lukas Sismis Date: Tue, 22 Jul 2025 09:57:38 +0200 Subject: [PATCH] hyperscan: prevent LTO opmitizing out hash calculation Since cached_hash was updated through reference (hash), it seems LTO did not notice this and optimized the whole code block, returning zero. This in turn caused all caches to have the same name and to overwrite. On subsequent runs, only the last cache was loaded for all SGHs causing wrong MPM assignment. Ticket: 7824 --- src/util-mpm-hs-cache.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/util-mpm-hs-cache.c b/src/util-mpm-hs-cache.c index 4aaf5da84c..2e58676fa9 100644 --- a/src/util-mpm-hs-cache.c +++ b/src/util-mpm-hs-cache.c @@ -222,14 +222,12 @@ cleanup: uint64_t HSHashDb(const PatternDatabase *pd) { - uint64_t cached_hash = 0; - uint32_t *hash = (uint32_t *)(&cached_hash); + uint32_t hash[2] = { 0 }; hashword2(&pd->pattern_cnt, 1, &hash[0], &hash[1]); for (uint32_t i = 0; i < pd->pattern_cnt; i++) { SCHSCachePatternHash(pd->parray[i], &hash[0], &hash[1]); } - - return cached_hash; + return ((uint64_t)hash[1] << 32) | hash[0]; } void HSSaveCacheIterator(void *data, void *aux) -- 2.47.2