Page MenuHomeFreeBSD

Add a BTI sysarch
ClosedPublic

Authored by andrew on Apr 6 2023, 4:10 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sep 29 2024, 12:57 PM
Unknown Object (File)
Sep 25 2024, 4:14 AM
Unknown Object (File)
Sep 19 2024, 1:05 AM
Unknown Object (File)
Sep 13 2024, 9:31 AM
Unknown Object (File)
Sep 6 2024, 5:31 AM
Unknown Object (File)
Sep 1 2024, 1:43 PM
Unknown Object (File)
Aug 23 2024, 10:37 PM
Unknown Object (File)
Aug 6 2024, 8:54 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.