From 5d9817728da9a7355b02b5966dffd51a0441462e Mon Sep 17 00:00:00 2001 From: sebres Date: Wed, 22 Nov 2023 20:05:02 +0100 Subject: [PATCH] fixes multi-threaded issue on `__pending` dict (caused due to missing lock on `__pending` dict); an entry can be deleted by `_delPending` with 1st thread, while 2nd thread in filter doing `_checkPending` where it still got this key in iterator, but later fails in the cycle because `__pending[path]` may be deleted by 1st thread in-between; closes #3635 --- fail2ban/server/filterpyinotify.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fail2ban/server/filterpyinotify.py b/fail2ban/server/filterpyinotify.py index 2ee49169e..81bc7de39 100644 --- a/fail2ban/server/filterpyinotify.py +++ b/fail2ban/server/filterpyinotify.py @@ -173,7 +173,9 @@ class FilterPyinotify(FileFilter): if not chkpath(path): # not found - prolong for next time if retardTM < 60: retardTM *= 2 if minTime > retardTM: minTime = retardTM - self.__pending[path][0] = retardTM + try: + self.__pending[path][0] = retardTM + except KeyError: pass continue logSys.log(logging.MSG, "Log presence detected for %s %s", "directory" if isDir else "file", path)