Skip to content

Avoid NT_ARM_PAC_MASK on older Linux kernels#887

Merged
bregma merged 2 commits intolibunwind:masterfrom
phongn:fix-NT_ARM_PAC_MASK-old-linux
Jun 13, 2025
Merged

Avoid NT_ARM_PAC_MASK on older Linux kernels#887
bregma merged 2 commits intolibunwind:masterfrom
phongn:fix-NT_ARM_PAC_MASK-old-linux

Conversation

@phongn
Copy link
Copy Markdown
Contributor

@phongn phongn commented Jun 9, 2025

Older kernels still in wide use (e.g. Enterprise Linux 8) do not have NT_ARM_PAC_MASK support or the associated structs. Compilation fails:

ptrace/_UPT_ptrauth_insn_mask.c: In function ‘_UPT_ptrauth_insn_mask’:
ptrace/_UPT_ptrauth_insn_mask.c:38:40: error: ‘NT_ARM_PAC_MASK’ undeclared (first use in this function); did you mean ‘EF_ARM_EABIMASK’?
   ret = ptrace (PTRACE_GETREGSET, pid, NT_ARM_PAC_MASK, &iovec);
                                        ^~~~~~~~~~~~~~~
                                        EF_ARM_EABIMASK
ptrace/_UPT_ptrauth_insn_mask.c:38:40: note: each undeclared identifier is reported only once for each function it appears in

This patch disables this codepath unless this is a Linux host and NT_ARM_PAC_MASK is defined in elf.h.

See also #873 which proposes a fix for FreeBSD platforms. This patch is a superset of #870.

@bregma
Copy link
Copy Markdown
Member

bregma commented Jun 10, 2025

If a check for NT_ARM_PAC_MASK not enough (ie is the check for the OS kernel necessary)?

@phongn
Copy link
Copy Markdown
Contributor Author

phongn commented Jun 10, 2025

If a check for NT_ARM_PAC_MASK not enough (ie is the check for the OS kernel necessary)?

FreeBSD has its own different call (linked) and perhaps this way it could be more cleanly separated.

@bregma
Copy link
Copy Markdown
Member

bregma commented Jun 11, 2025

After some investigation I believe it should be #if defined(UNW_TARGET_AARCH64) && defined(NT_ARM_PAC_MASK). Compilation support for that macro is independent of the target operating system.

Please make that change and I would be happy to commit.

@phongn
Copy link
Copy Markdown
Contributor Author

phongn commented Jun 11, 2025

After some investigation I believe it should be #if defined(UNW_TARGET_AARCH64) && defined(NT_ARM_PAC_MASK). Compilation support for that macro is independent of the target operating system.

Please make that change and I would be happy to commit.

Requested changed committed. Once merged I'd like to issue a PR to backport this change and some of the UNUSED fixes into v1.8-stable

@bregma bregma merged commit 7886dbb into libunwind:master Jun 13, 2025
16 of 29 checks passed
@bregma bregma mentioned this pull request Jun 13, 2025
@phongn phongn deleted the fix-NT_ARM_PAC_MASK-old-linux branch June 30, 2025 23:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants