Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stop fetching memory blocks when an elf is found #1996

Merged
merged 1 commit into from
Dec 7, 2023

Conversation

vthib
Copy link
Contributor

@vthib vthib commented Oct 29, 2023

When scanning multiple memory blocks, we should stop as soon as a valid elf is found. This was broken as the "break" applies to the switch, and not the outer loop. Fix this by reworking the code to remove the switch.

This bug had two repercutions:

  • instead of parsing the first memory block that contains an elf, it returned the last one, or actually even worse, a mix of all elfs depending on which values are set again or not. This however should not manifest in normal situations, notably during process scanning, as I suppose only one memory region would contain an elf executable.

  • the module caused the fetch of all memory blocks instead of stopping as soon as one was found, which is worse performance wise.

When scanning multiple memory blocks, we should stop as soon as a valid
elf is found. This was broken as the "break" applies to the switch, and
not the outer loop. Fix this by reworking the code to remove the switch.

This bug had two repercutions:

- instead of parsing the first memory block that contains an elf, it
  returned the last one, or actually even worse, a mix of all elfs
  depending on which values are set again or not. This however should
  not manifest in normal situations, notably during process scanning, as
  I suppose only one memory region would contain an elf executable.

- the module caused the fetch of all memory blocks instead of stopping
  as soon as one was found, which is worse performance wise.
@vthib vthib force-pushed the fix-elf-fetch-memory-blocks branch from cb70996 to 98ea874 Compare November 19, 2023 20:28
@vthib
Copy link
Contributor Author

vthib commented Dec 1, 2023

@plusvic anything blocking this MR that I need to modify?

@plusvic plusvic merged commit 6cdc3fd into VirusTotal:master Dec 7, 2023
10 checks passed
@vthib vthib deleted the fix-elf-fetch-memory-blocks branch December 8, 2023 21:56
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