RFR: 8266749: AArch64: Backtracing broken on PAC enabled systems [v2]
Alan Hayward
github.com+4146708+a74nh at openjdk.java.net
Wed May 19 16:03:42 UTC 2021
On Wed, 19 May 2021 15:27:22 GMT, Gerard Ziemski <gziemski at openjdk.org> wrote:
>> Alan Hayward has updated the pull request incrementally with two additional commits since the last revision:
>>
>> - Add pauth assert to bsd signal handler
>>
>> I could also add the same to windows, but the pauth functions are
>> currently blank for windows.
>>
>> Change-Id: I1093c576ea2e9a94d0d76176d69d28fc2e5e29c1
>> - Split pauth_aarch64.hpp into os_cpu variants
>>
>> Change-Id: Ib39f42e0ed09156b2fc861117f304ef565c25f93
>
> src/hotspot/os_cpu/bsd_aarch64/pauth_bsd_aarch64.inline.hpp line 42:
>
>> 40: inline address pauth_strip_pointer(address ptr) {
>> 41: #ifdef __APPLE__
>> 42: ptrauth_strip(ptr, ptrauth_key_asib);
>
> Wouldn't it be safer to use the alias `ptrauth_key_process_dependent_code` instead of the underlaying primitive enum `ptrauth_key_asib`?
>
> ` ptrauth_strip(ptr, ptrauth_key_process_dependent_code);`
>
> Can you please elaborate on why this particular key was used, for example why not `ptrauth_key_process_independent_code`? There are so many other...
For the values being stripped in this patch, they will always be return addresses saved on the stack. My first choice here was ptrauth_key_return_address, but I wanted it to be a little more generic and:
ptrauth_key_return_address = ptrauth_key_process_dependent_code = ptrauth_key_asib [1]
For a strip function, the key shouldn't matter as xpaci/xaplri instructions work for both IA and IB keys. However when I've dumped my test binaries on mac, it looked like the compiler used generic bitmasking instead of the xpac instructions. So it's possible the relevant key does matter here. Using the IB key ensures ptrauth_strip() always does the stripping (according to ptrauth.h comments), which is probably the safest option for now. I suspect full mac arm64e support would eventually require having multiple strip functions (pauth_strip_retaddr(), pauth_strip_functptr(), etc)
[1] https://opensource.apple.com/source/xnu/xnu-4903.241.1/EXTERNAL_HEADERS/ptrauth.h.auto.html
-------------
PR: https://git.openjdk.java.net/jdk/pull/4029
More information about the hotspot-dev
mailing list