Stream: git-wasmtime

Topic: wasmtime / issue #9290 Wasmtime is not using the recommen...


view this post on Zulip Wasmtime GitHub notifications bot (Sep 20 2024 at 11:03):

matlo607 added the bug label to Issue #9290.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 20 2024 at 11:03):

matlo607 opened issue #9290:

Description

DWARF for the Arm® 64-bit Architecture (AArch64) specifies that the RA state should be set with DW_CFA_AARCH64_negate_ra_state .

The same result can be obtained using DW_CFA_val_expression.

// RA_SIGN_STATE corresponds to the DWARF register number 34.
DW_CFA_val_expression 34, 1, DW_OP_lit1

This behavior was added to libgcc to support unwinding when the RA state is set with DW_CFA_val_expression (Bug 104689).

Current implementation in Wasmtime:
https://github.com/bytecodealliance/wasmtime/blob/37ed724c9da2ee5a516923cf221ade19b78f63eb/cranelift/codegen/src/isa/unwind/systemv.rs#L115-L128

Issue

Armv9.5-A introduced a new extension to PAC for return address signing: PAuth_LR. It adds a new diversifier PC, aside to SP. The value of PC used by PAC2 algorithm corresponds to its value at the time of signing, i.e. the address of the paci<k>sppc instruction, or paci<k>sp if NOP-space instructions are used.

A new DWARF directive DW_CFA_AARCH64_negate_ra_state_with_pc was introduced to record the position of signing and authentication, and to express that PACv2 algorithm was used (vs PACv1 relying on DW_CFA_AARCH64_negate_ra_state). During unwinding, this directive saves the PC diversifier into the frame state, to later use it to authenticate the return address.

In my understanding, the approach based on DW_CFA_val_expression is not working anymore in this context, as the libgcc unwinder cannot know the difference between a DW_CFA_val_expression used for PAC, and another one used for something else, and so cannot save PC at the time of signing.

  1. Is it an issue for your use case ? Do you plan to add support for PAuth_LR ?
  2. Would it be possible to change the CFI directive to the recommended one ?

Links

view this post on Zulip Wasmtime GitHub notifications bot (Sep 20 2024 at 15:21):

alexcrichton commented on issue #9290:

Thanks for the report! AFAIK we don't have strict needs around this related to Wasmtime or Cranelift per se, and so long as things work and pass tests changing should be fine. I believe we unfortunately don't have automated testing for this in that our QEMU emulation in CI I don't think has this enabled, but it might not be too too hard to set up.


Last updated: Nov 22 2024 at 16:03 UTC