]> git.ipfire.org Git - thirdparty/rspamd.git/commit
[Fix] Fuzzy TCP: fix server replies and client event handling
authorVsevolod Stakhov <vsevolod@rspamd.com>
Tue, 7 Oct 2025 18:20:03 +0000 (19:20 +0100)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Tue, 7 Oct 2025 18:20:03 +0000 (19:20 +0100)
commitbb92ef803cac35a5fa61c6398eb24ca895ce8772
tree1ab72ea2c87500856c3e03bd2c4a2e47dd66faec
parenta519cd6171b9de5ac846aca5bb6039fa777615c2
[Fix] Fuzzy TCP: fix server replies and client event handling

Server was accepting TCP connections but never sending replies back,
causing all TCP requests to timeout. The issue had multiple causes:

Server side:
- TCP replies were routed through UDP code path, which doesn't queue
  replies for TCP sessions
- Async backend operations used stack-allocated session, causing
  segfaults when callback executed after stack frame destroyed

Client side:
- Event handler used equality checks (==) instead of bitwise (&)
  for libev event flags, preventing read events from being processed
- Timer initialization used rspamd IO wrapper for pure timer,
  causing fd=-1 assertion failures in ev_io_start
- Pending requests not cleaned up on timeout, causing use-after-free
  when late replies arrived after task completion

Fix by implementing TCP reply queue on server, using heap allocation
for async operations with proper reference counting, fixing event
handling to use bitwise operators, and implementing pure libev timer
for TCP timeout handling.
src/fuzzy_storage.c
src/plugins/fuzzy_check.c