Enable branch target control flow enforcement on arm64.
authorkettenis <kettenis@openbsd.org>
Mon, 24 Apr 2023 10:22:48 +0000 (10:22 +0000)
committerkettenis <kettenis@openbsd.org>
Mon, 24 Apr 2023 10:22:48 +0000 (10:22 +0000)
ok robert@, deraadt@

sys/arch/arm64/arm64/machdep.c

index ff7886b..20ad76d 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.80 2023/03/30 15:09:01 kn Exp $ */
+/* $OpenBSD: machdep.c,v 1.81 2023/04/24 10:22:48 kettenis Exp $ */
 /*
  * Copyright (c) 2014 Patrick Wildt <patrick@blueri.se>
  * Copyright (c) 2021 Mark Kettenis <kettenis@openbsd.org>
@@ -454,6 +454,11 @@ setregs(struct proc *p, struct exec_package *pack, u_long stack,
        struct pcb *pcb = &p->p_addr->u_pcb;
        struct trapframe *tf = pcb->pcb_tf;
 
+       if (pack->ep_flags & EXEC_NOBTCFI)
+               p->p_vmspace->vm_map.pmap->pm_guarded = 0;
+       else
+               p->p_vmspace->vm_map.pmap->pm_guarded = ATTR_GP;
+
        /* If we were using the FPU, forget about it. */
        memset(&pcb->pcb_fpstate, 0, sizeof(pcb->pcb_fpstate));
        pcb->pcb_flags &= ~PCB_FPU;