-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
reg_read from xzr / wzr on Arm64 / AArch64 broken in Unicorn 2.1: "Invalid argument (UC_ERR_ARG)" #2019
Comments
I got the similar feedbacks of this behavior change from various sources, which I admit I should have highlight in the changelog. Generally, I’m thinking of printing a warning to stderr (probably in the incoming 2.1.2) and changing this to an error in next minor version like 2.2.0. |
That fix looks like it will work for us, thanks. Looking forward to a point release with that fix included. |
Hi, its almost two months after this fix has been applied. Any chance we can get it released? Otherwise, we have to due an if/else internally as we did in pwndbg/pwndbg#2548 ;). |
Thanks for reaching out. The new release is almost ready but I'm not feeling very well recently and thus I can't assure you a release date unfortunately. Personally, I will try to release a new point release (2.1.2) before mid Dec. |
Previously in Unicorn 2.0.1.post1, you could call
reg_read
onxzr
andwzr
on Arm64 / Aarch64. In Unicorn 2.1.0 / 2.1.1 you cannot.I've bisected the code and it works in commit d7a806c and fails in the next commit 4055a5a
This points to #1835 (for #1831).
Looking at the code, I think it's because those registers aren't covered by any of the if statements and the default return value for unhandled registers was also changed from
UC_ERR_OK
toUC_ERR_ARG
, which by itself makes sense.Now, you may ask why do you need to read from
xzr
/wzr
- but it didn't throw an exception before, and now it does. Code that steps through an emulation and reads the source registers of anyldr
/mov
instructions or similar before making a decision about whether to continue stepping further or stop will run into this bug, for example. We could special case it on the consumer side, but there's a lot of code that relied on the previous behaviour, so this is an unexpected compatibility change which would require lots of special handling if not fixed.In my opinion these 2 registers should have their own if / case statement and be handled appropriately by returning 0 (width-appropriate depending on which register was requested).
Minimal testcase based on the existing
sample_arm64.py
code for the binding:This used to return:
But now returns:
And the same is true for
wzr
(const = 6).Thanks for your hard work, hopefully that makes sense.
The text was updated successfully, but these errors were encountered: