angr / patcherex

Shellphish's automated patching engine, originally created for the Cyber Grand Challenge.
BSD 2-Clause "Simplified" License
251 stars 45 forks source link

Fix movable instructions computation in x86-64 detour backend #53

Open dnivra opened 11 months ago

dnivra commented 11 months ago

This PR fixes the movable instructions computation in the x86-64 detour backend (and thus potentially fix #47). Currently, only the last instruction in the block is check if movable or not. As a result, any unmovable instructions in the middle of the block (eg: instructions with RIP relative addressing) will be treated as movable and trigger a fault if moved. This PR fixes the movable instructions computation to exclude such instructions. Technically, RIP relative instructions can be moved - the argument needs to be modified to ensure the reference is still valid. However, I felt excluding them is easier to implement and so went down that route. If we want to treat RIP relative instructions as movable, I can look into doing that.

dnivra commented 11 months ago

I fixed the x86-64 test cases that failed because of changes in this PR. The sole failing test case fails on master as well and so I think this PR can be merged in.

dnivra commented 11 months ago

I fixed the failing test case as well. It seems the test case was incorrectly updated in 29c1c57a and so was failing. Since the change is pretty trivial, I included it in this PR too.