Skip to content

Defer or avoid file MD5 calculation when cache is disabled#1167

Merged
val-ms merged 2 commits intoCisco-Talos:mainfrom
antchan2:optimize_clam_cache_disabled_
May 6, 2024
Merged

Defer or avoid file MD5 calculation when cache is disabled#1167
val-ms merged 2 commits intoCisco-Talos:mainfrom
antchan2:optimize_clam_cache_disabled_

Conversation

@antchan2
Copy link
Contributor

@antchan2 antchan2 commented Feb 6, 2024

If the clean cache is not used (CL_ENGINE_DISABLE_CACHE=1), it is not necessary to calculate the file's MD5 checksum in preparation for cache lookup. This change modifies cli_magic_scan to skip the MD5 calculation if the cache is disabled.

@val-ms val-ms marked this pull request as ready for review March 12, 2024 16:44
@val-ms val-ms self-requested a review April 19, 2024 16:21
antchan2 and others added 2 commits May 1, 2024 20:17
If SCAN_COLLECT_METADATA is enabled, and caching is disabled, we zero-out
the hash after recording it.
This results in a non-NULL and invalid-hash that may be passed to
`cli_scan_fmap()` for the "raw mode" scan.
It's an uncommon code path, but would result in comparing hash-sigs with
a zeroed hash rather than the valid hash.
This bug could result in a missed hash-based sig matches.

There is no reason to invalidate or zero-out the hash if we happen to
calculate it. We avoid the cache-lookup by checking the engine setting,
not by checking if we have a hash.
@val-ms val-ms merged commit d628bbc into Cisco-Talos:main May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants