Page MenuHomeFreeBSD

Add a BTI sysarch
ClosedPublic

Authored by andrew on Apr 6 2023, 4:10 PM.
Tags
None
Referenced Files
F106180180: D39453.diff
Thu, Dec 26, 5:23 PM
Unknown Object (File)
Thu, Dec 12, 10:33 PM
Unknown Object (File)
Sun, Dec 8, 1:54 AM
Unknown Object (File)
Sun, Dec 8, 1:54 AM
Unknown Object (File)
Sun, Dec 8, 1:42 AM
Unknown Object (File)
Thu, Dec 5, 6:06 PM
Unknown Object (File)
Nov 18 2024, 10:56 PM
Unknown Object (File)
Nov 7 2024, 11:20 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 Skipped
Unit
Tests Skipped
Build Status
Buildable 54129
Build 51019: 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
49
75

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);
77

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.

78

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
42

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
54

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.