After SIGHUP reload, the global pending_compilations queue retained
stale multipattern pointers from the freed old config. When hs_helper
processed the queue, it accessed freed memory causing heap-buffer-overflow
in rspamd_multipattern_get_npatterns().
Add rspamd_multipattern_clear_pending() alongside the existing
rspamd_regexp_map_clear_pending() call before releasing old config.
#ifdef WITH_HYPERSCAN
#include "libserver/hyperscan_tools.h"
#include "libserver/maps/map_helpers.h"
+#include "libutil/multipattern.h"
#endif
#include "rspamd_simdutf.h"
rspamd_log_close(old_logger);
msg_info_main("replacing config");
#ifdef WITH_HYPERSCAN
- /* Clear pending regexp maps before releasing old config to avoid use-after-free */
+ /* Clear pending multipatterns and regexp maps before releasing old config to avoid use-after-free */
+ rspamd_multipattern_clear_pending();
rspamd_regexp_map_clear_pending();
#endif
CFG_REF_RELEASE(old_cfg);