Handle T_CP traps from userland by generating SIGILL, with
authorguenther <guenther@openbsd.org>
Sun, 16 Apr 2023 06:38:50 +0000 (06:38 +0000)
committerguenther <guenther@openbsd.org>
Sun, 16 Apr 2023 06:38:50 +0000 (06:38 +0000)
code ILL_ILLOPC or ILL_BADSTK depending on the error from hardware

lack of handling noted by deraadt@
ok jsg@

sys/arch/amd64/amd64/trap.c

index 783184b..8c9abf6 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: trap.c,v 1.98 2023/04/15 01:22:50 jsg Exp $   */
+/*     $OpenBSD: trap.c,v 1.99 2023/04/16 06:38:50 guenther Exp $      */
 /*     $NetBSD: trap.c,v 1.2 2003/05/04 23:51:56 fvdl Exp $    */
 
 /*-
@@ -431,6 +431,11 @@ usertrap(struct trapframe *frame)
                sig = SIGTRAP;
                code = TRAP_BRKPT;
                break;
+       case T_CP:
+               sig = SIGILL;
+               code = (frame->tf_err & 0x7fff) < 4 ? ILL_ILLOPC
+                   : ILL_BADSTK;
+               break;
 
        case T_PAGEFLT:                 /* page fault */
                if (!uvm_map_inentry(p, &p->p_spinentry, PROC_STACK(p),