Page MenuHomeFreeBSD

Add a BTI sysarch
ClosedPublic

Authored by andrew on Apr 6 2023, 4:10 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Jun 29, 1:39 PM
Unknown Object (File)
Sun, Jun 29, 1:39 PM
Unknown Object (File)
Sun, Jun 29, 1:39 PM
Unknown Object (File)
Fri, Jun 27, 3:37 AM
Unknown Object (File)
Thu, Jun 26, 1:29 AM
Unknown Object (File)
Wed, Jun 25, 10:30 PM
Unknown Object (File)
Wed, Jun 25, 3:10 PM
Unknown Object (File)
Wed, Jun 25, 11:40 AM
Subscribers

Details

Reviewers
kib
markj
manu
Group Reviewers
arm64
Commits
rGc4e4a7596beb: Add a BTI sysarch
Summary

This is used to enable the guard page when an elf binary is built with
BTI instructions.

Sponsored by: Arm Ltd
Sponsored by: The FreeBSD Foundation

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 50798
Build 47689: arc lint + arc unit

Event Timeline

andrew requested review of this revision.Apr 6 2023, 4:10 PM
andrew added a parent revision: D39452: Support BTI in rtld.
  • Rebase on D42328
  • Move ARM64_GUARD_PAGE from 0 to ensure userspace intends to set it

Where will BTI be documented? Perhaps bti.3 and mitigations.7?

sys/arm64/arm64/sys_machdep.c
63
89

IMO it is clearer to write this in terms of a range:

sva = trunc_page(gp_args.addr);
eva = round_page(gp_args.addr + gp_args.len);
if (sva > eva || eva > VM_MAX_USER_ADDRESS)
    return (EINVAL);
error = pmap_pti_set(pmap, sva, eva);
91

Shouldn't the pmap should be derived from td, not using pcpu? This looks strange, I don't know why PKRU does it this way.

92

pmap_bti_set() returns 0 if the executable didn't have BTI configured. Don't we want to return an error here in that case?

sys/arm64/include/sysarch.h
39

What is this constant for?

Updates based on feedback from @markj.

Only page align the start and end address when calling pmap_bti_set to ensure we catch address space overflows

markj added inline comments.
sys/arm64/arm64/sys_machdep.c
68

All of the other error cases below are handled by returning directly.

This revision is now accepted and ready to land.Feb 15 2024, 2:26 PM
This revision was automatically updated to reflect the committed changes.