mirror of https://github.com/OISF/suricata
hs: suppress TOCTOU stat use
To explain a bit more the TOCTOU issue found, we can consider a case where Suricata starts to prune, yet externally somebody also starts erasing cache files. Right after Suricata checks the file age with the stat function, somebody may delete or update the file of our interest. Suricata aging decision doesn't reflect the actual state of the file. This commit additionally adds a check for noent failure of the unlink operation (considered as a success). The code can still delete a file that is recently updated but was considered stale. In the documentation-following deployments this should not happen anyway as one cache folder should only be used by a single Suricata instance (and within Suricata instance only one thread handles cache eviction). Additionally, the `stat` and `unlink` command are immediatelly followed, making this scenario extra unlikely. Additional comment in the code explains problems of using fstat and potential issues on Windows. Ticket: 8243pull/14706/head
parent
7627756360
commit
0fe0390a2f
Loading…
Reference in New Issue