RFR: 8266749: AArch64: Backtracing broken on PAC enabled systems [v2]

Gerard Ziemski gziemski at openjdk.java.net
Thu May 20 21:38:33 UTC 2021


On Wed, 19 May 2021 16:01:11 GMT, Alan Hayward <github.com+4146708+a74nh at openjdk.org> wrote:

>> 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

I don't 100% understand this piece of code on macOS (I stripped non macOS code from it for clarity):


inline address pauth_strip_pointer(address ptr) {
   ptrauth_strip(ptr, ptrauth_key_asib);
   return ptr;
 }


shouldn't it be something more like:


inline address pauth_strip_pointer(address ptr) {
   return ptrauth_strip(ptr, ptrauth_key_asib);
 }


The original code compiles with **"Expression result unused"** for me.

-------------

PR: https://git.openjdk.java.net/jdk/pull/4029


More information about the hotspot-dev mailing list