Page MenuHomeFreeBSD

Add a BTI sysarch
ClosedPublic

Authored by andrew on Apr 6 2023, 4:10 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, May 6, 11:29 AM
Unknown Object (File)
Sat, May 4, 11:52 PM
Unknown Object (File)
Tue, Apr 30, 6:57 PM
Unknown Object (File)
Tue, Apr 30, 6:57 PM
Unknown Object (File)
Tue, Apr 30, 6:57 PM
Unknown Object (File)
Tue, Apr 30, 6:55 PM
Unknown Object (File)
Tue, Apr 30, 6:55 PM
Unknown Object (File)
Tue, Apr 30, 4:50 PM
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 Not Applicable
Unit
Tests Not Applicable

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
48
74

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

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.

77

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
53

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.