Page MenuHomeFreeBSD

arm64: Enable kernel branch protection
ClosedPublic

Authored by andrew on Oct 4 2023, 3:23 PM.
Tags
None
Referenced Files
F104668826: D42079.diff
Sun, Dec 8, 4:54 PM
Unknown Object (File)
Tue, Dec 3, 6:57 AM
Unknown Object (File)
Wed, Nov 27, 1:15 AM
Unknown Object (File)
Sat, Nov 16, 1:56 PM
Unknown Object (File)
Sat, Nov 16, 1:47 PM
Unknown Object (File)
Sat, Nov 16, 11:59 AM
Unknown Object (File)
Nov 9 2024, 3:10 AM
Unknown Object (File)
Oct 16 2024, 7:58 AM
Subscribers

Details

Summary

Add the build flags to enable branch protection on arm64. This enable
the use of PAC and BTI in the kernel.

For PAC we already install the kernel keys when entering the kernel
from userspace so this will start using these to sign the stack.

For BTI we need to mark the kernel page tables with a new guarded page
field. As this will require all code that could be reached through a
function pointer with an appropriate branch target instruction we
are enabling this before setting the field.

As the pointer authentication support shouldn't be reached via a
function pointer it is safe to not enable the use of BTI there.

Sponsored by: Arm Ltd

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

andrew requested review of this revision.Oct 4 2023, 3:23 PM
sys/conf/kern.mk
144

Should this work with gcc as well?

sys/conf/kern.mk
144

It works with at least Clang 9+ and GCC 9.3+ https://godbolt.org/z/6MG7vfPWW

This revision is now accepted and ready to land.Oct 6 2023, 2:44 PM
This revision was automatically updated to reflect the committed changes.