Fix infinite loops in copy propagation optimizer #876
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I came across a couple of infinite loops in copy_propagation_optimizer.cpp using the attach file.
sslvpnd.zip
The sslvpnd binary should have a
sha256sum
of 856b68307d53d0f20f5c4a91aefc3146382e4e4210c758655d53135669642557 or you can find the binary embedded in this firmware.The infinite loop(s) can be reproduced by fetching retdec master from Github, compiling, and executing retdec-decompiler:
After a couple of minutes, retdec drops into an infinite. The issue appears to be similar to 55d46b5f3a4a5ec038ab33331926a195c7f33250, in that copy_progragation_optimizer is walking backwards through statements that loop. I followed a similar solution as introduced in the previous commit, basically exiting the loop if we see the same statement twice. With this change, sslvpnd is successfully processed after approximately 5 minutes.
I looked at the style guide and I'm not 100% my for loop line break is okay or not. Happy to fix if needed.