-
Notifications
You must be signed in to change notification settings - Fork 0
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
[PAuth][LLDB] Make signed pointers usable in expressions #61
Comments
I have no clear solution for this right now, below are some observations. As far as I understand the DWARF 5 specification, section 1.3.7, it should be preferable to describe signed pointer values explicitly:
According to aadwarf64 document, there are several AArch64 platform-specific extensions to support PAuth. While To the extent I currently understand DWARF, it looks working to me to introduce something like My initial thought was to look at what is generated for TBI on AArch64, as it is another case of placing something loosely related into the higher bits of address value. This can be achieved by compiling an example program with HWAsan enabled. Unfortunately, I did not find anything interesting in the DWARF description generated for code that uses TBI. And that looks reasonable because TBI by definition makes all those 256 pointer values (differing by 8-bit tag) valid w.r.t. address translation. I tried patching the existing debug information by adding Just in case, it is possible to adjust the debug information manually after it was produced by code generator. The *.s file produced by clang contains lots of |
On the other hand, maybe trying to convey the fact that the pointer is signed via DWARF sections is overengineering. If so, should lldb-server on AArch64 just unconditionally clear top-most 16 bits before dereferencing the pointer (by data load/store or control flow) in jitted code or should such behavior be enabled somehow for the particular target process as a whole. |
Also tagging @DavidSpickett |
Well, this might have some interesting consequences. For example, if for some reason the signature will be wrong, then we will be unable to debug such issue. Debugger will just strip the signature and everything will work, while in the normal runtime we'll end dereferencing invalid pointer. I think we should be explicit that things are signed and IMO it's a property of the type (after all, Also, the things should be organized in some fine-grained basis, e.g. we can easily have a mixture of signed / unsigned pointers in some stub codes. The orthogonal question is expression JIT as here we need to generate properly signed pointers as far as I can see as they could escape. |
This is what happens already (in lldb mostly, though a little bit in lldb-server), it was deemed a decent compromise until we had other signals to go off of to tell whether it was signed. See https://www.linaro.org/blog/lldb-15-and-the-mystery-of-the-non-address-bits/ "Corrupted Pointer or Non-Address Bits?" If we know that we're in this ABI and that there is this annotation, we can use that to be more strict. There is also the issue of whether you want to be able to give signed pointers to commands like Another command example, do you expect My vague thought here is that you would make the AArch64 ABI plugin aware of whether the PAuth ABI is being used, and it would change its So:
|
A couple of thoughts how signing schema might be encoded in Dwarf. The most straight-forward and simple way that comes into mind is adding a new attribute, say, If a The place where we obtain the context for a user expression is
As far as I can see now, such a Update. It turns out that we already have
It could be used instead of |
Make possible to transparently use signed pointers fetched from the target process in LLDB expressions. Presently, LLDB doesn't take into account pointers being signed when dereferencing them (resulting in SEGV or some other sort of "invalid pointer" error).
Let's consider the following code:
indirect-call-for-lldb.c:
Compile it using our toolchain (commit 62ce88f) with the following command:
Inside QEMU, segmentation fault is observed when trying to perform indirect call.
Note: I use
-cpu max,pauth=on,pauth-impdef=on
QEMU options to get reasonable simulation performance, so PACs usually don't look very random (0x003c
in the below example).The text was updated successfully, but these errors were encountered: